File tree Expand file tree Collapse file tree 4 files changed +44
-2
lines changed
e2e/composer-version-named-args Expand file tree Collapse file tree 4 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -391,6 +391,9 @@ jobs:
391391 cd e2e/composer-version-config
392392 composer install
393393 ../../bin/phpstan analyze test.php --level=0
394+ - script : |
395+ cd e2e/composer-version-named-args
396+ ../../bin/phpstan analyze test.php --level=0
394397
395398 steps :
396399 - name : " Checkout"
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ namespace NamedAttributesPhpversion ;
4+
5+ use Exception ;
6+ use function PHPStan \debugScope ;
7+ use function PHPStan \dumpType ;
8+ use function PHPStan \Testing \assertType ;
9+
10+ class HelloWorld
11+ {
12+ /** @return mixed[] */
13+ public function sayHello (): array |null
14+ {
15+ if (PHP_VERSION_ID >= 80400 ) {
16+ } else {
17+ }
18+ return [
19+ new Exception (previous: new Exception ()),
20+ ];
21+ }
22+ }
23+
24+ class HelloWorld2
25+ {
26+ /** @return mixed[] */
27+ public function sayHello (): array |null
28+ {
29+ return [
30+ PHP_VERSION_ID >= 80400 ? 1 : 0 ,
31+ new Exception (previous: new Exception ()),
32+ ];
33+ }
34+ }
Original file line number Diff line number Diff line change 3434final class ConstantResolver
3535{
3636
37+ public const PHP_MIN_ANALYZABLE_VERSION_ID = 50207 ;
38+
3739 /** @var array<string, true> */
3840 private array $ currentlyResolving = [];
3941
@@ -141,7 +143,7 @@ public function resolvePredefinedConstant(string $resolvedConstantName): ?Type
141143 return $ this ->createInteger ($ minRelease , $ maxRelease );
142144 }
143145 if ($ resolvedConstantName === 'PHP_VERSION_ID ' ) {
144- $ minVersion = 50207 ;
146+ $ minVersion = self :: PHP_MIN_ANALYZABLE_VERSION_ID ;
145147 $ maxVersion = null ;
146148 if ($ minPhpVersion !== null ) {
147149 $ minVersion = max ($ minVersion , $ minPhpVersion ->getVersionId ());
Original file line number Diff line number Diff line change 5252use PHPStan \Parser \NewAssignedToPropertyVisitor ;
5353use PHPStan \Parser \Parser ;
5454use PHPStan \Php \PhpVersion ;
55+ use PHPStan \Php \PhpVersionFactory ;
5556use PHPStan \Php \PhpVersions ;
5657use PHPStan \PhpDoc \Tag \TemplateTag ;
5758use PHPStan \Reflection \Assertions ;
@@ -6235,8 +6236,10 @@ public function getIterableValueType(Type $iteratee): Type
62356236
62366237 public function getPhpVersion (): PhpVersions
62376238 {
6239+ $ overallPhpVersionRange = IntegerRangeType::fromInterval (ConstantResolver::PHP_MIN_ANALYZABLE_VERSION_ID , PhpVersionFactory::MAX_PHP_VERSION );
6240+
62386241 $ constType = $ this ->getGlobalConstantType (new Name ('PHP_VERSION_ID ' ));
6239- if ($ constType !== null ) {
6242+ if ($ constType !== null && ! $ constType -> equals ( $ overallPhpVersionRange ) ) {
62406243 return new PhpVersions ($ constType );
62416244 }
62426245
You can’t perform that action at this time.
0 commit comments