-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support ::class on expression (PHP 8.0)
- Loading branch information
1 parent
869f27b
commit cec1be7
Showing
7 changed files
with
169 additions
and
6 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
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,23 @@ | ||
<?php | ||
|
||
namespace ClassConstantOnExprAssertType; | ||
|
||
use function PHPStan\Analyser\assertType; | ||
|
||
class Foo | ||
{ | ||
|
||
public function doFoo( | ||
\stdClass $std, | ||
string $string, | ||
?\stdClass $stdOrNull, | ||
?string $stringOrNull | ||
): void | ||
{ | ||
assertType('class-string<stdClass>', $std::class); | ||
assertType('*ERROR*', $string::class); | ||
assertType('class-string<stdClass>', $stdOrNull::class); | ||
assertType('*ERROR*', $stringOrNull::class); | ||
} | ||
|
||
} |
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
21 changes: 21 additions & 0 deletions
21
tests/PHPStan/Rules/Classes/data/class-constant-on-expr.php
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,21 @@ | ||
<?php // lint >= 8.0 | ||
|
||
namespace ClassConstantOnExpr; | ||
|
||
class Foo | ||
{ | ||
|
||
public function doFoo( | ||
\stdClass $std, | ||
string $string, | ||
?\stdClass $stdOrNull, | ||
?string $stringOrNull | ||
): void | ||
{ | ||
echo $std::class; | ||
echo $string::class; | ||
echo $stdOrNull::class; | ||
echo $stringOrNull::class; | ||
} | ||
|
||
} |