-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delegate
get_called_class()
to static::class
Closes phpstan/phpstan#9341
- Loading branch information
1 parent
4e19347
commit 188acf4
Showing
4 changed files
with
42 additions
and
4 deletions.
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,32 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Bug9341; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
interface MyInterface {} | ||
|
||
trait MyTrait | ||
{ | ||
public static function parse(): mixed | ||
{ | ||
$class = get_called_class(); | ||
assertType('class-string<static(Bug9341\MyAbstractBase)>', $class); | ||
if (!is_a($class, MyInterface::class, true)) { | ||
return false; | ||
} | ||
assertType('class-string<Bug9341\MyInterface&static(Bug9341\MyAbstractBase)>', $class); | ||
$fileObject = new $class(); | ||
assertType('Bug9341\MyInterface&static(Bug9341\MyAbstractBase)', $fileObject); | ||
return $fileObject; | ||
} | ||
} | ||
|
||
abstract class MyAbstractBase { | ||
use MyTrait; | ||
} | ||
|
||
class MyClass extends MyAbstractBase implements MyInterface | ||
{ | ||
|
||
} |
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