File tree Expand file tree Collapse file tree 3 files changed +21
-4
lines changed Expand file tree Collapse file tree 3 files changed +21
-4
lines changed Original file line number Diff line number Diff line change 2626 "phpstan/phpstan-phpunit" : " ^0.12.16" ,
2727 "phpstan/phpstan-strict-rules" : " ^0.12.5" ,
2828 "phpunit/phpunit" : " ^7.5.20" ,
29- "symfony/console" : " ^4.0 || ^5.0" ,
3029 "symfony/config" : " ^4.2 || ^5.0" ,
31- "symfony/framework-bundle" : " ^4.0 || ^5.0" ,
30+ "symfony/console" : " ^4.0 || ^5.0" ,
31+ "symfony/framework-bundle" : " ^4.4 || ^5.0" ,
3232 "symfony/http-foundation" : " ^4.0 || ^5.0" ,
3333 "symfony/messenger" : " ^4.2 || ^5.0" ,
3434 "symfony/serializer" : " ^4.0 || ^5.0"
Original file line number Diff line number Diff line change 88use PHPStan \Reflection \ParametersAcceptorSelector ;
99use PHPStan \ShouldNotHappenException ;
1010use PHPStan \Symfony \ParameterMap ;
11+ use PHPStan \Type \ArrayType ;
12+ use PHPStan \Type \BooleanType ;
1113use PHPStan \Type \Constant \ConstantBooleanType ;
1214use PHPStan \Type \DynamicMethodReturnTypeExtension ;
15+ use PHPStan \Type \FloatType ;
16+ use PHPStan \Type \IntegerType ;
17+ use PHPStan \Type \MixedType ;
18+ use PHPStan \Type \NullType ;
19+ use PHPStan \Type \StringType ;
1320use PHPStan \Type \Type ;
21+ use PHPStan \Type \UnionType ;
1422use function in_array ;
1523
1624final class ParameterDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
@@ -71,7 +79,16 @@ private function getGetTypeFromMethodCall(
7179 Scope $ scope
7280 ): Type
7381 {
74- $ returnType = ParametersAcceptorSelector::selectSingle ($ methodReflection ->getVariants ())->getReturnType ();
82+ // We don't use the method's return type because this won't work properly with lowest and
83+ // highest versions of Symfony ("mixed" for lowest, "array|bool|float|integer|string|null" for highest).
84+ $ returnType = new UnionType ([
85+ new ArrayType (new MixedType (), new MixedType ()),
86+ new BooleanType (),
87+ new FloatType (),
88+ new IntegerType (),
89+ new StringType (),
90+ new NullType (),
91+ ]);
7592 if (!isset ($ methodCall ->args [0 ])) {
7693 return $ returnType ;
7794 }
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ public function services(): void
2626 public function parameters (ContainerInterface $ container , ParameterBagInterface $ parameterBag ): void
2727 {
2828 assertType ('array|bool|float|int|string|null ' , $ container ->getParameter ('unknown ' ));
29- assertType ('mixed ' , $ parameterBag ->get ('unknown ' ));
29+ assertType ('array|bool|float|int|string|null ' , $ parameterBag ->get ('unknown ' ));
3030 assertType ('array|bool|float|int|string|null ' , $ this ->getParameter ('unknown ' ));
3131 assertType ("'abcdef' " , $ container ->getParameter ('app.string ' ));
3232 assertType ("'abcdef' " , $ parameterBag ->get ('app.string ' ));
You can’t perform that action at this time.
0 commit comments