From c31ea7e8d68f94964f73cec95caa9be746837e56 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 1 Dec 2025 15:35:53 +0100 Subject: [PATCH 1/3] Implement remaining Magic-Const Handlers --- .../ExprHandler/MagicClassHandler.php | 55 +++++++++++++++++++ .../ExprHandler/MagicFunctionHandler.php | 55 +++++++++++++++++++ .../ExprHandler/MagicMethodHandler.php | 55 +++++++++++++++++++ .../ExprHandler/MagicNamespaceHandler.php | 55 +++++++++++++++++++ .../ExprHandler/MagicPropertyHandler.php | 55 +++++++++++++++++++ .../ExprHandler/MagicTraitHandler.php | 55 +++++++++++++++++++ .../PHPStan/Analyser/Generator/data/gnsr.php | 6 ++ 7 files changed, 336 insertions(+) create mode 100644 src/Analyser/Generator/ExprHandler/MagicClassHandler.php create mode 100644 src/Analyser/Generator/ExprHandler/MagicFunctionHandler.php create mode 100644 src/Analyser/Generator/ExprHandler/MagicMethodHandler.php create mode 100644 src/Analyser/Generator/ExprHandler/MagicNamespaceHandler.php create mode 100644 src/Analyser/Generator/ExprHandler/MagicPropertyHandler.php create mode 100644 src/Analyser/Generator/ExprHandler/MagicTraitHandler.php diff --git a/src/Analyser/Generator/ExprHandler/MagicClassHandler.php b/src/Analyser/Generator/ExprHandler/MagicClassHandler.php new file mode 100644 index 0000000000..5ab1fd5427 --- /dev/null +++ b/src/Analyser/Generator/ExprHandler/MagicClassHandler.php @@ -0,0 +1,55 @@ + + */ +#[AutowiredService] +final class MagicClassHandler implements ExprHandler +{ + + public function __construct(private InitializerExprTypeResolver $initializerExprTypeResolver) + { + } + + public function supports(Expr $expr): bool + { + return $expr instanceof Class_; + } + + public function analyseExpr(Stmt $stmt, Expr $expr, GeneratorScope $scope, ExpressionContext $context, ?callable $alternativeNodeCallback): Generator + { + yield from []; + + $initializerContext = InitializerExprContext::fromScope($scope); + $type = $this->initializerExprTypeResolver->getType($expr, $initializerContext); + + return new ExprAnalysisResult( + $type, + $type, + $scope, + hasYield: false, + isAlwaysTerminating: false, + throwPoints: [], + impurePoints: [], + specifiedTruthyTypes: new SpecifiedTypes(), + specifiedFalseyTypes: new SpecifiedTypes(), + specifiedNullTypes: new SpecifiedTypes(), + ); + } + +} diff --git a/src/Analyser/Generator/ExprHandler/MagicFunctionHandler.php b/src/Analyser/Generator/ExprHandler/MagicFunctionHandler.php new file mode 100644 index 0000000000..427ca98f32 --- /dev/null +++ b/src/Analyser/Generator/ExprHandler/MagicFunctionHandler.php @@ -0,0 +1,55 @@ + + */ +#[AutowiredService] +final class MagicFunctionHandler implements ExprHandler +{ + + public function __construct(private InitializerExprTypeResolver $initializerExprTypeResolver) + { + } + + public function supports(Expr $expr): bool + { + return $expr instanceof Function_; + } + + public function analyseExpr(Stmt $stmt, Expr $expr, GeneratorScope $scope, ExpressionContext $context, ?callable $alternativeNodeCallback): Generator + { + yield from []; + + $initializerContext = InitializerExprContext::fromScope($scope); + $type = $this->initializerExprTypeResolver->getType($expr, $initializerContext); + + return new ExprAnalysisResult( + $type, + $type, + $scope, + hasYield: false, + isAlwaysTerminating: false, + throwPoints: [], + impurePoints: [], + specifiedTruthyTypes: new SpecifiedTypes(), + specifiedFalseyTypes: new SpecifiedTypes(), + specifiedNullTypes: new SpecifiedTypes(), + ); + } + +} diff --git a/src/Analyser/Generator/ExprHandler/MagicMethodHandler.php b/src/Analyser/Generator/ExprHandler/MagicMethodHandler.php new file mode 100644 index 0000000000..89fed70404 --- /dev/null +++ b/src/Analyser/Generator/ExprHandler/MagicMethodHandler.php @@ -0,0 +1,55 @@ + + */ +#[AutowiredService] +final class MagicMethodHandler implements ExprHandler +{ + + public function __construct(private InitializerExprTypeResolver $initializerExprTypeResolver) + { + } + + public function supports(Expr $expr): bool + { + return $expr instanceof Method; + } + + public function analyseExpr(Stmt $stmt, Expr $expr, GeneratorScope $scope, ExpressionContext $context, ?callable $alternativeNodeCallback): Generator + { + yield from []; + + $initializerContext = InitializerExprContext::fromScope($scope); + $type = $this->initializerExprTypeResolver->getType($expr, $initializerContext); + + return new ExprAnalysisResult( + $type, + $type, + $scope, + hasYield: false, + isAlwaysTerminating: false, + throwPoints: [], + impurePoints: [], + specifiedTruthyTypes: new SpecifiedTypes(), + specifiedFalseyTypes: new SpecifiedTypes(), + specifiedNullTypes: new SpecifiedTypes(), + ); + } + +} diff --git a/src/Analyser/Generator/ExprHandler/MagicNamespaceHandler.php b/src/Analyser/Generator/ExprHandler/MagicNamespaceHandler.php new file mode 100644 index 0000000000..937800723f --- /dev/null +++ b/src/Analyser/Generator/ExprHandler/MagicNamespaceHandler.php @@ -0,0 +1,55 @@ + + */ +#[AutowiredService] +final class MagicNamespaceHandler implements ExprHandler +{ + + public function __construct(private InitializerExprTypeResolver $initializerExprTypeResolver) + { + } + + public function supports(Expr $expr): bool + { + return $expr instanceof Namespace_; + } + + public function analyseExpr(Stmt $stmt, Expr $expr, GeneratorScope $scope, ExpressionContext $context, ?callable $alternativeNodeCallback): Generator + { + yield from []; + + $initializerContext = InitializerExprContext::fromScope($scope); + $type = $this->initializerExprTypeResolver->getType($expr, $initializerContext); + + return new ExprAnalysisResult( + $type, + $type, + $scope, + hasYield: false, + isAlwaysTerminating: false, + throwPoints: [], + impurePoints: [], + specifiedTruthyTypes: new SpecifiedTypes(), + specifiedFalseyTypes: new SpecifiedTypes(), + specifiedNullTypes: new SpecifiedTypes(), + ); + } + +} diff --git a/src/Analyser/Generator/ExprHandler/MagicPropertyHandler.php b/src/Analyser/Generator/ExprHandler/MagicPropertyHandler.php new file mode 100644 index 0000000000..99b4263d4f --- /dev/null +++ b/src/Analyser/Generator/ExprHandler/MagicPropertyHandler.php @@ -0,0 +1,55 @@ + + */ +#[AutowiredService] +final class MagicPropertyHandler implements ExprHandler +{ + + public function __construct(private InitializerExprTypeResolver $initializerExprTypeResolver) + { + } + + public function supports(Expr $expr): bool + { + return $expr instanceof Property; + } + + public function analyseExpr(Stmt $stmt, Expr $expr, GeneratorScope $scope, ExpressionContext $context, ?callable $alternativeNodeCallback): Generator + { + yield from []; + + $initializerContext = InitializerExprContext::fromScope($scope); + $type = $this->initializerExprTypeResolver->getType($expr, $initializerContext); + + return new ExprAnalysisResult( + $type, + $type, + $scope, + hasYield: false, + isAlwaysTerminating: false, + throwPoints: [], + impurePoints: [], + specifiedTruthyTypes: new SpecifiedTypes(), + specifiedFalseyTypes: new SpecifiedTypes(), + specifiedNullTypes: new SpecifiedTypes(), + ); + } + +} diff --git a/src/Analyser/Generator/ExprHandler/MagicTraitHandler.php b/src/Analyser/Generator/ExprHandler/MagicTraitHandler.php new file mode 100644 index 0000000000..80212291cf --- /dev/null +++ b/src/Analyser/Generator/ExprHandler/MagicTraitHandler.php @@ -0,0 +1,55 @@ + + */ +#[AutowiredService] +final class MagicTraitHandler implements ExprHandler +{ + + public function __construct(private InitializerExprTypeResolver $initializerExprTypeResolver) + { + } + + public function supports(Expr $expr): bool + { + return $expr instanceof Trait_; + } + + public function analyseExpr(Stmt $stmt, Expr $expr, GeneratorScope $scope, ExpressionContext $context, ?callable $alternativeNodeCallback): Generator + { + yield from []; + + $initializerContext = InitializerExprContext::fromScope($scope); + $type = $this->initializerExprTypeResolver->getType($expr, $initializerContext); + + return new ExprAnalysisResult( + $type, + $type, + $scope, + hasYield: false, + isAlwaysTerminating: false, + throwPoints: [], + impurePoints: [], + specifiedTruthyTypes: new SpecifiedTypes(), + specifiedFalseyTypes: new SpecifiedTypes(), + specifiedNullTypes: new SpecifiedTypes(), + ); + } + +} diff --git a/tests/PHPStan/Analyser/Generator/data/gnsr.php b/tests/PHPStan/Analyser/Generator/data/gnsr.php index 42f2192425..f6f31ea313 100644 --- a/tests/PHPStan/Analyser/Generator/data/gnsr.php +++ b/tests/PHPStan/Analyser/Generator/data/gnsr.php @@ -469,6 +469,12 @@ function doFoo(): void { assertType('literal-string&non-falsy-string', __DIR__); assertType('literal-string&non-falsy-string', __FILE__); assertType('471', __LINE__); + assertType("'GeneratorNodeScopeResolverTest'", __NAMESPACE__); + assertType("'GeneratorNodeScopeResolverTest\\\\MagicConstUser'", __CLASS__); + assertType("''", __TRAIT__); + assertType("'doFoo'", __FUNCTION__); + assertType("'GeneratorNodeScopeResolverTest\\\\MagicConstUser::doFoo'", __METHOD__); + assertType("''", __PROPERTY__); } } From b5cd2b24842292fde01fb51ef0f7f89a4282ad32 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 1 Dec 2025 15:46:19 +0100 Subject: [PATCH 2/3] Refactor into MagicConstHandler --- .../ExprHandler/MagicClassHandler.php | 55 ------------------- ...spaceHandler.php => MagicConstHandler.php} | 24 +++++++- .../Generator/ExprHandler/MagicDirHandler.php | 55 ------------------- .../ExprHandler/MagicFileHandler.php | 55 ------------------- .../ExprHandler/MagicFunctionHandler.php | 55 ------------------- .../ExprHandler/MagicLineHandler.php | 55 ------------------- .../ExprHandler/MagicMethodHandler.php | 55 ------------------- .../ExprHandler/MagicPropertyHandler.php | 55 ------------------- .../ExprHandler/MagicTraitHandler.php | 55 ------------------- 9 files changed, 21 insertions(+), 443 deletions(-) delete mode 100644 src/Analyser/Generator/ExprHandler/MagicClassHandler.php rename src/Analyser/Generator/ExprHandler/{MagicNamespaceHandler.php => MagicConstHandler.php} (63%) delete mode 100644 src/Analyser/Generator/ExprHandler/MagicDirHandler.php delete mode 100644 src/Analyser/Generator/ExprHandler/MagicFileHandler.php delete mode 100644 src/Analyser/Generator/ExprHandler/MagicFunctionHandler.php delete mode 100644 src/Analyser/Generator/ExprHandler/MagicLineHandler.php delete mode 100644 src/Analyser/Generator/ExprHandler/MagicMethodHandler.php delete mode 100644 src/Analyser/Generator/ExprHandler/MagicPropertyHandler.php delete mode 100644 src/Analyser/Generator/ExprHandler/MagicTraitHandler.php diff --git a/src/Analyser/Generator/ExprHandler/MagicClassHandler.php b/src/Analyser/Generator/ExprHandler/MagicClassHandler.php deleted file mode 100644 index 5ab1fd5427..0000000000 --- a/src/Analyser/Generator/ExprHandler/MagicClassHandler.php +++ /dev/null @@ -1,55 +0,0 @@ - - */ -#[AutowiredService] -final class MagicClassHandler implements ExprHandler -{ - - public function __construct(private InitializerExprTypeResolver $initializerExprTypeResolver) - { - } - - public function supports(Expr $expr): bool - { - return $expr instanceof Class_; - } - - public function analyseExpr(Stmt $stmt, Expr $expr, GeneratorScope $scope, ExpressionContext $context, ?callable $alternativeNodeCallback): Generator - { - yield from []; - - $initializerContext = InitializerExprContext::fromScope($scope); - $type = $this->initializerExprTypeResolver->getType($expr, $initializerContext); - - return new ExprAnalysisResult( - $type, - $type, - $scope, - hasYield: false, - isAlwaysTerminating: false, - throwPoints: [], - impurePoints: [], - specifiedTruthyTypes: new SpecifiedTypes(), - specifiedFalseyTypes: new SpecifiedTypes(), - specifiedNullTypes: new SpecifiedTypes(), - ); - } - -} diff --git a/src/Analyser/Generator/ExprHandler/MagicNamespaceHandler.php b/src/Analyser/Generator/ExprHandler/MagicConstHandler.php similarity index 63% rename from src/Analyser/Generator/ExprHandler/MagicNamespaceHandler.php rename to src/Analyser/Generator/ExprHandler/MagicConstHandler.php index 937800723f..c40589c1ed 100644 --- a/src/Analyser/Generator/ExprHandler/MagicNamespaceHandler.php +++ b/src/Analyser/Generator/ExprHandler/MagicConstHandler.php @@ -4,7 +4,15 @@ use Generator; use PhpParser\Node\Expr; +use PhpParser\Node\Scalar\MagicConst\Class_; +use PhpParser\Node\Scalar\MagicConst\Dir; +use PhpParser\Node\Scalar\MagicConst\File; +use PhpParser\Node\Scalar\MagicConst\Function_; +use PhpParser\Node\Scalar\MagicConst\Line; +use PhpParser\Node\Scalar\MagicConst\Method; use PhpParser\Node\Scalar\MagicConst\Namespace_; +use PhpParser\Node\Scalar\MagicConst\Property; +use PhpParser\Node\Scalar\MagicConst\Trait_; use PhpParser\Node\Stmt; use PHPStan\Analyser\ExpressionContext; use PHPStan\Analyser\Generator\ExprAnalysisResult; @@ -16,10 +24,10 @@ use PHPStan\Reflection\InitializerExprTypeResolver; /** - * @implements ExprHandler + * @implements ExprHandler */ #[AutowiredService] -final class MagicNamespaceHandler implements ExprHandler +final class MagicConstHandler implements ExprHandler { public function __construct(private InitializerExprTypeResolver $initializerExprTypeResolver) @@ -28,7 +36,17 @@ public function __construct(private InitializerExprTypeResolver $initializerExpr public function supports(Expr $expr): bool { - return $expr instanceof Namespace_; + return + $expr instanceof Dir + || $expr instanceof File + || $expr instanceof Line + || $expr instanceof Namespace_ + || $expr instanceof Class_ + || $expr instanceof Property + || $expr instanceof Function_ + || $expr instanceof Method + || $expr instanceof Trait_ + ; } public function analyseExpr(Stmt $stmt, Expr $expr, GeneratorScope $scope, ExpressionContext $context, ?callable $alternativeNodeCallback): Generator diff --git a/src/Analyser/Generator/ExprHandler/MagicDirHandler.php b/src/Analyser/Generator/ExprHandler/MagicDirHandler.php deleted file mode 100644 index 8b4f1a2538..0000000000 --- a/src/Analyser/Generator/ExprHandler/MagicDirHandler.php +++ /dev/null @@ -1,55 +0,0 @@ - - */ -#[AutowiredService] -final class MagicDirHandler implements ExprHandler -{ - - public function __construct(private InitializerExprTypeResolver $initializerExprTypeResolver) - { - } - - public function supports(Expr $expr): bool - { - return $expr instanceof Dir; - } - - public function analyseExpr(Stmt $stmt, Expr $expr, GeneratorScope $scope, ExpressionContext $context, ?callable $alternativeNodeCallback): Generator - { - yield from []; - - $initializerContext = InitializerExprContext::fromScope($scope); - $type = $this->initializerExprTypeResolver->getType($expr, $initializerContext); - - return new ExprAnalysisResult( - $type, - $type, - $scope, - hasYield: false, - isAlwaysTerminating: false, - throwPoints: [], - impurePoints: [], - specifiedTruthyTypes: new SpecifiedTypes(), - specifiedFalseyTypes: new SpecifiedTypes(), - specifiedNullTypes: new SpecifiedTypes(), - ); - } - -} diff --git a/src/Analyser/Generator/ExprHandler/MagicFileHandler.php b/src/Analyser/Generator/ExprHandler/MagicFileHandler.php deleted file mode 100644 index 0c71915c9b..0000000000 --- a/src/Analyser/Generator/ExprHandler/MagicFileHandler.php +++ /dev/null @@ -1,55 +0,0 @@ - - */ -#[AutowiredService] -final class MagicFileHandler implements ExprHandler -{ - - public function __construct(private InitializerExprTypeResolver $initializerExprTypeResolver) - { - } - - public function supports(Expr $expr): bool - { - return $expr instanceof File; - } - - public function analyseExpr(Stmt $stmt, Expr $expr, GeneratorScope $scope, ExpressionContext $context, ?callable $alternativeNodeCallback): Generator - { - yield from []; - - $initializerContext = InitializerExprContext::fromScope($scope); - $type = $this->initializerExprTypeResolver->getType($expr, $initializerContext); - - return new ExprAnalysisResult( - $type, - $type, - $scope, - hasYield: false, - isAlwaysTerminating: false, - throwPoints: [], - impurePoints: [], - specifiedTruthyTypes: new SpecifiedTypes(), - specifiedFalseyTypes: new SpecifiedTypes(), - specifiedNullTypes: new SpecifiedTypes(), - ); - } - -} diff --git a/src/Analyser/Generator/ExprHandler/MagicFunctionHandler.php b/src/Analyser/Generator/ExprHandler/MagicFunctionHandler.php deleted file mode 100644 index 427ca98f32..0000000000 --- a/src/Analyser/Generator/ExprHandler/MagicFunctionHandler.php +++ /dev/null @@ -1,55 +0,0 @@ - - */ -#[AutowiredService] -final class MagicFunctionHandler implements ExprHandler -{ - - public function __construct(private InitializerExprTypeResolver $initializerExprTypeResolver) - { - } - - public function supports(Expr $expr): bool - { - return $expr instanceof Function_; - } - - public function analyseExpr(Stmt $stmt, Expr $expr, GeneratorScope $scope, ExpressionContext $context, ?callable $alternativeNodeCallback): Generator - { - yield from []; - - $initializerContext = InitializerExprContext::fromScope($scope); - $type = $this->initializerExprTypeResolver->getType($expr, $initializerContext); - - return new ExprAnalysisResult( - $type, - $type, - $scope, - hasYield: false, - isAlwaysTerminating: false, - throwPoints: [], - impurePoints: [], - specifiedTruthyTypes: new SpecifiedTypes(), - specifiedFalseyTypes: new SpecifiedTypes(), - specifiedNullTypes: new SpecifiedTypes(), - ); - } - -} diff --git a/src/Analyser/Generator/ExprHandler/MagicLineHandler.php b/src/Analyser/Generator/ExprHandler/MagicLineHandler.php deleted file mode 100644 index e4c16e4d25..0000000000 --- a/src/Analyser/Generator/ExprHandler/MagicLineHandler.php +++ /dev/null @@ -1,55 +0,0 @@ - - */ -#[AutowiredService] -final class MagicLineHandler implements ExprHandler -{ - - public function __construct(private InitializerExprTypeResolver $initializerExprTypeResolver) - { - } - - public function supports(Expr $expr): bool - { - return $expr instanceof Line; - } - - public function analyseExpr(Stmt $stmt, Expr $expr, GeneratorScope $scope, ExpressionContext $context, ?callable $alternativeNodeCallback): Generator - { - yield from []; - - $initializerContext = InitializerExprContext::fromScope($scope); - $type = $this->initializerExprTypeResolver->getType($expr, $initializerContext); - - return new ExprAnalysisResult( - $type, - $type, - $scope, - hasYield: false, - isAlwaysTerminating: false, - throwPoints: [], - impurePoints: [], - specifiedTruthyTypes: new SpecifiedTypes(), - specifiedFalseyTypes: new SpecifiedTypes(), - specifiedNullTypes: new SpecifiedTypes(), - ); - } - -} diff --git a/src/Analyser/Generator/ExprHandler/MagicMethodHandler.php b/src/Analyser/Generator/ExprHandler/MagicMethodHandler.php deleted file mode 100644 index 89fed70404..0000000000 --- a/src/Analyser/Generator/ExprHandler/MagicMethodHandler.php +++ /dev/null @@ -1,55 +0,0 @@ - - */ -#[AutowiredService] -final class MagicMethodHandler implements ExprHandler -{ - - public function __construct(private InitializerExprTypeResolver $initializerExprTypeResolver) - { - } - - public function supports(Expr $expr): bool - { - return $expr instanceof Method; - } - - public function analyseExpr(Stmt $stmt, Expr $expr, GeneratorScope $scope, ExpressionContext $context, ?callable $alternativeNodeCallback): Generator - { - yield from []; - - $initializerContext = InitializerExprContext::fromScope($scope); - $type = $this->initializerExprTypeResolver->getType($expr, $initializerContext); - - return new ExprAnalysisResult( - $type, - $type, - $scope, - hasYield: false, - isAlwaysTerminating: false, - throwPoints: [], - impurePoints: [], - specifiedTruthyTypes: new SpecifiedTypes(), - specifiedFalseyTypes: new SpecifiedTypes(), - specifiedNullTypes: new SpecifiedTypes(), - ); - } - -} diff --git a/src/Analyser/Generator/ExprHandler/MagicPropertyHandler.php b/src/Analyser/Generator/ExprHandler/MagicPropertyHandler.php deleted file mode 100644 index 99b4263d4f..0000000000 --- a/src/Analyser/Generator/ExprHandler/MagicPropertyHandler.php +++ /dev/null @@ -1,55 +0,0 @@ - - */ -#[AutowiredService] -final class MagicPropertyHandler implements ExprHandler -{ - - public function __construct(private InitializerExprTypeResolver $initializerExprTypeResolver) - { - } - - public function supports(Expr $expr): bool - { - return $expr instanceof Property; - } - - public function analyseExpr(Stmt $stmt, Expr $expr, GeneratorScope $scope, ExpressionContext $context, ?callable $alternativeNodeCallback): Generator - { - yield from []; - - $initializerContext = InitializerExprContext::fromScope($scope); - $type = $this->initializerExprTypeResolver->getType($expr, $initializerContext); - - return new ExprAnalysisResult( - $type, - $type, - $scope, - hasYield: false, - isAlwaysTerminating: false, - throwPoints: [], - impurePoints: [], - specifiedTruthyTypes: new SpecifiedTypes(), - specifiedFalseyTypes: new SpecifiedTypes(), - specifiedNullTypes: new SpecifiedTypes(), - ); - } - -} diff --git a/src/Analyser/Generator/ExprHandler/MagicTraitHandler.php b/src/Analyser/Generator/ExprHandler/MagicTraitHandler.php deleted file mode 100644 index 80212291cf..0000000000 --- a/src/Analyser/Generator/ExprHandler/MagicTraitHandler.php +++ /dev/null @@ -1,55 +0,0 @@ - - */ -#[AutowiredService] -final class MagicTraitHandler implements ExprHandler -{ - - public function __construct(private InitializerExprTypeResolver $initializerExprTypeResolver) - { - } - - public function supports(Expr $expr): bool - { - return $expr instanceof Trait_; - } - - public function analyseExpr(Stmt $stmt, Expr $expr, GeneratorScope $scope, ExpressionContext $context, ?callable $alternativeNodeCallback): Generator - { - yield from []; - - $initializerContext = InitializerExprContext::fromScope($scope); - $type = $this->initializerExprTypeResolver->getType($expr, $initializerContext); - - return new ExprAnalysisResult( - $type, - $type, - $scope, - hasYield: false, - isAlwaysTerminating: false, - throwPoints: [], - impurePoints: [], - specifiedTruthyTypes: new SpecifiedTypes(), - specifiedFalseyTypes: new SpecifiedTypes(), - specifiedNullTypes: new SpecifiedTypes(), - ); - } - -} From a1ff3ce16d9d54322ba91ba47134d74f349b5e36 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 1 Dec 2025 15:46:54 +0100 Subject: [PATCH 3/3] Update MagicConstHandler.php --- src/Analyser/Generator/ExprHandler/MagicConstHandler.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Analyser/Generator/ExprHandler/MagicConstHandler.php b/src/Analyser/Generator/ExprHandler/MagicConstHandler.php index c40589c1ed..e69794698e 100644 --- a/src/Analyser/Generator/ExprHandler/MagicConstHandler.php +++ b/src/Analyser/Generator/ExprHandler/MagicConstHandler.php @@ -36,8 +36,7 @@ public function __construct(private InitializerExprTypeResolver $initializerExpr public function supports(Expr $expr): bool { - return - $expr instanceof Dir + return $expr instanceof Dir || $expr instanceof File || $expr instanceof Line || $expr instanceof Namespace_ @@ -45,8 +44,7 @@ public function supports(Expr $expr): bool || $expr instanceof Property || $expr instanceof Function_ || $expr instanceof Method - || $expr instanceof Trait_ - ; + || $expr instanceof Trait_; } public function analyseExpr(Stmt $stmt, Expr $expr, GeneratorScope $scope, ExpressionContext $context, ?callable $alternativeNodeCallback): Generator