File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -900,6 +900,8 @@ services:
900900 class : PHPStan\Type\Php\CompactFunctionReturnTypeExtension
901901 tags :
902902 - phpstan.broker.dynamicFunctionReturnTypeExtension
903+ arguments :
904+ checkMaybeUndefinedVariables : %checkMaybeUndefinedVariables%
903905
904906 -
905907 class : PHPStan\Type\Php\CountFunctionReturnTypeExtension
Original file line number Diff line number Diff line change 1515class CompactFunctionReturnTypeExtension implements DynamicFunctionReturnTypeExtension
1616{
1717
18+ private bool $ checkMaybeUndefinedVariables ;
19+
20+ public function __construct (bool $ checkMaybeUndefinedVariables )
21+ {
22+ $ this ->checkMaybeUndefinedVariables = $ checkMaybeUndefinedVariables ;
23+ }
24+
1825 public function isFunctionSupported (FunctionReflection $ functionReflection ): bool
1926 {
2027 return $ functionReflection ->getName () === 'compact ' ;
@@ -31,7 +38,7 @@ public function getTypeFromFunctionCall(
3138 return $ defaultReturnType ;
3239 }
3340
34- if ($ scope ->canAnyVariableExist ()) {
41+ if ($ scope ->canAnyVariableExist () && ! $ this -> checkMaybeUndefinedVariables ) {
3542 return $ defaultReturnType ;
3643 }
3744
You can’t perform that action at this time.
0 commit comments