1515use PhpParser \Node \Stmt \Return_ ;
1616use PHPStan \Analyser \MutatingScope ;
1717use PHPStan \Analyser \Scope ;
18- use PHPStan \Reflection \FunctionReflection ;
1918use PHPStan \Reflection \ReflectionProvider ;
2019use PHPStan \ShouldNotHappenException ;
2120use PHPStan \Type \ArrayType ;
2423use PHPStan \Type \Constant \ConstantArrayTypeBuilder ;
2524use PHPStan \Type \Constant \ConstantBooleanType ;
2625use PHPStan \Type \Constant \ConstantIntegerType ;
27- use PHPStan \Type \DynamicFunctionReturnTypeExtension ;
2826use PHPStan \Type \ErrorType ;
2927use PHPStan \Type \MixedType ;
3028use PHPStan \Type \NeverType ;
4038use function sprintf ;
4139use function substr ;
4240
43- final class ArrayFilterFunctionReturnTypeExtension implements DynamicFunctionReturnTypeExtension
41+ final class ArrayFilterFunctionReturnTypeHelper
4442{
4543
4644 private const USE_BOTH = 1 ;
@@ -51,17 +49,8 @@ public function __construct(private ReflectionProvider $reflectionProvider)
5149 {
5250 }
5351
54- public function isFunctionSupported ( FunctionReflection $ functionReflection ): bool
52+ public function getType ( Scope $ scope , ? Expr $ arrayArg , ? Expr $ callbackArg , ? Expr $ flagArg ): Type
5553 {
56- return $ functionReflection ->getName () === 'array_filter ' ;
57- }
58-
59- public function getTypeFromFunctionCall (FunctionReflection $ functionReflection , FuncCall $ functionCall , Scope $ scope ): Type
60- {
61- $ arrayArg = $ functionCall ->getArgs ()[0 ]->value ?? null ;
62- $ callbackArg = $ functionCall ->getArgs ()[1 ]->value ?? null ;
63- $ flagArg = $ functionCall ->getArgs ()[2 ]->value ?? null ;
64-
6554 if ($ arrayArg === null ) {
6655 return new ArrayType (new MixedType (), new MixedType ());
6756 }
@@ -151,7 +140,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
151140 return new ArrayType ($ keyType , $ itemType );
152141 }
153142
154- public function removeFalsey (Type $ type ): Type
143+ private function removeFalsey (Type $ type ): Type
155144 {
156145 $ falseyTypes = StaticTypeFactory::falsey ();
157146
0 commit comments