7
7
use PHPStan \Reflection \ReflectionProvider ;
8
8
use PHPStan \Type \BenevolentUnionType ;
9
9
use PHPStan \Type \CompoundType ;
10
- use PHPStan \Type \Constant \ConstantArrayType ;
11
10
use PHPStan \Type \ErrorType ;
12
11
use PHPStan \Type \MixedType ;
13
12
use PHPStan \Type \NeverType ;
@@ -63,52 +62,6 @@ public function accepts(Type $acceptingType, Type $acceptedType, bool $strictTyp
63
62
$ acceptedType = TypeCombinator::removeNull ($ acceptedType );
64
63
}
65
64
66
- if (
67
- $ acceptedType ->isArray ()->yes ()
68
- && $ acceptingType ->isArray ()->yes ()
69
- && !$ acceptingType instanceof ConstantArrayType
70
- ) {
71
- $ acceptedConstantArrays = TypeUtils::getConstantArrays ($ acceptedType );
72
- if (count ($ acceptedConstantArrays ) > 0 ) {
73
- foreach ($ acceptedConstantArrays as $ acceptedConstantArray ) {
74
- foreach ($ acceptedConstantArray ->getKeyTypes () as $ i => $ keyType ) {
75
- $ valueType = $ acceptedConstantArray ->getValueTypes ()[$ i ];
76
- if (
77
- !self ::accepts (
78
- $ acceptingType ->getIterableKeyType (),
79
- $ keyType ,
80
- $ strictTypes
81
- ) || !self ::accepts (
82
- $ acceptingType ->getIterableValueType (),
83
- $ valueType ,
84
- $ strictTypes
85
- )
86
- ) {
87
- return false ;
88
- }
89
- }
90
- }
91
-
92
- return true ;
93
- }
94
-
95
- if (
96
- !self ::accepts (
97
- $ acceptingType ->getIterableKeyType (),
98
- $ acceptedType ->getIterableKeyType (),
99
- $ strictTypes
100
- ) || !self ::accepts (
101
- $ acceptingType ->getIterableValueType (),
102
- $ acceptedType ->getIterableValueType (),
103
- $ strictTypes
104
- )
105
- ) {
106
- return false ;
107
- }
108
-
109
- return true ;
110
- }
111
-
112
65
if ($ acceptingType instanceof UnionType && !$ acceptedType instanceof CompoundType) {
113
66
foreach ($ acceptingType ->getTypes () as $ innerType ) {
114
67
if (self ::accepts ($ innerType , $ acceptedType , $ strictTypes )) {
@@ -122,7 +75,8 @@ public function accepts(Type $acceptingType, Type $acceptedType, bool $strictTyp
122
75
if (
123
76
$ acceptedType ->isArray ()->yes ()
124
77
&& $ acceptingType ->isArray ()->yes ()
125
- && !$ acceptingType instanceof ConstantArrayType
78
+ && count (TypeUtils::getConstantArrays ($ acceptedType )) === 0
79
+ && count (TypeUtils::getConstantArrays ($ acceptingType )) === 0
126
80
) {
127
81
return self ::accepts (
128
82
$ acceptingType ->getIterableKeyType (),
0 commit comments