File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -1812,7 +1812,7 @@ parameters:
1812
1812
-
1813
1813
message : ' #^Doing instanceof PHPStan\\Type\\Constant\\ConstantArrayType is error\-prone and deprecated\. Use Type\:\:getConstantArrays\(\) instead\.$#'
1814
1814
identifier : phpstanApi.instanceofType
1815
- count : 3
1815
+ count : 1
1816
1816
path : src/Type/TypehintHelper.php
1817
1817
1818
1818
-
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ public static function decideType(
101
101
if ($ phpDocType instanceof UnionType) {
102
102
$ innerTypes = [];
103
103
foreach ($ phpDocType ->getTypes () as $ innerType ) {
104
- if ($ innerType instanceof ArrayType || $ innerType instanceof ConstantArrayType ) {
104
+ if ($ innerType instanceof ArrayType && $ innerType-> getKeyType ()-> describe (VerbosityLevel:: typeOnly ()) === ' mixed ' ) {
105
105
$ innerTypes [] = new IterableType (
106
106
$ innerType ->getIterableKeyType (),
107
107
$ innerType ->getItemType (),
@@ -111,7 +111,7 @@ public static function decideType(
111
111
}
112
112
}
113
113
$ phpDocType = new UnionType ($ innerTypes );
114
- } elseif ($ phpDocType instanceof ArrayType || $ phpDocType instanceof ConstantArrayType ) {
114
+ } elseif ($ phpDocType instanceof ArrayType && $ phpDocType-> getKeyType ()-> describe (VerbosityLevel:: typeOnly ()) === ' mixed ' ) {
115
115
$ phpDocType = new IterableType (
116
116
$ phpDocType ->getKeyType (),
117
117
$ phpDocType ->getItemType (),
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types = 1 );
2
+
3
+ namespace Bug13411 ;
4
+
5
+ use SplFixedArray ;
6
+ use function PHPStan \Testing \assertType ;
7
+
8
+ class Token {}
9
+
10
+ /** @extends SplFixedArray<Token> */
11
+ class Tokens extends SplFixedArray {}
12
+
13
+ /** @param array<int, Token>|Tokens $tokens */
14
+ function x (iterable $ tokens ): int {
15
+ assertType ('array<int, Bug13411 \\Token>|Bug13411 \\Tokens ' , $ tokens );
16
+ return count ($ tokens );
17
+ }
You can’t perform that action at this time.
0 commit comments