5
5
use PhpParser \Node \Expr \MethodCall ;
6
6
use PHPStan \Analyser \Scope ;
7
7
use PHPStan \Reflection \MethodReflection ;
8
+ use PHPStan \Type \Accessory \AccessoryArrayListType ;
8
9
use PHPStan \Type \ArrayType ;
9
10
use PHPStan \Type \Constant \ConstantStringType ;
10
11
use PHPStan \Type \DynamicMethodReturnTypeExtension ;
11
- use PHPStan \Type \MixedType ;
12
+ use PHPStan \Type \Generic \GenericClassStringType ;
13
+ use PHPStan \Type \IntegerType ;
12
14
use PHPStan \Type \ObjectType ;
13
15
use PHPStan \Type \Type ;
14
16
use function count ;
@@ -33,15 +35,18 @@ public function getTypeFromMethodCall(
33
35
): Type
34
36
{
35
37
if (count ($ methodCall ->getArgs ()) === 0 ) {
36
- return new ArrayType (new MixedType (), new ArrayType (new MixedType (), new ObjectType ('Symfony\Component\Messenger\Stamp\StampInterface ' )));
38
+ return new ArrayType (
39
+ new GenericClassStringType (new ObjectType ('Symfony\Component\Messenger\Stamp\StampInterface ' )),
40
+ AccessoryArrayListType::intersectWith (new ArrayType (new IntegerType (), new ObjectType ('Symfony\Component\Messenger\Stamp\StampInterface ' )))
41
+ );
37
42
}
38
43
39
44
$ argType = $ scope ->getType ($ methodCall ->getArgs ()[0 ]->value );
40
45
if (!$ argType instanceof ConstantStringType) {
41
- return new ArrayType (new MixedType (), new ObjectType ('Symfony\Component\Messenger\Stamp\StampInterface ' ));
46
+ return AccessoryArrayListType:: intersectWith ( new ArrayType (new IntegerType (), new ObjectType ('Symfony\Component\Messenger\Stamp\StampInterface ' ) ));
42
47
}
43
48
44
- return new ArrayType (new MixedType (), new ObjectType ($ argType ->getValue ()));
49
+ return AccessoryArrayListType:: intersectWith ( new ArrayType (new IntegerType (), new ObjectType ($ argType ->getValue () )));
45
50
}
46
51
47
52
}
0 commit comments