-
Notifications
You must be signed in to change notification settings - Fork 476
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent false-positive in get_parent_class() on interfaces
- Loading branch information
Showing
5 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Bug4302b; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
class HelloWorld | ||
{ | ||
public function theMethod(MyInterface $interface, MyClass $class, MySubClass $subclass) { | ||
assertType('class-string|false', get_parent_class($interface)); | ||
assertType('false', get_parent_class($class)); | ||
assertType("'Bug4302b\\\\MyClass'", get_parent_class($subclass)); | ||
} | ||
} | ||
|
||
interface MyInterface {} | ||
|
||
class MyClass implements MyInterface {} | ||
|
||
class MySubClass extends MyClass {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Bug4302; | ||
|
||
class HelloWorld | ||
{ | ||
public function theMethod(MyInterface $object) { | ||
if (get_parent_class($object)) { | ||
return 1; | ||
} | ||
} | ||
} | ||
|
||
interface MyInterface {} |