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:
18121812 -
18131813 message : ' #^Doing instanceof PHPStan\\Type\\Constant\\ConstantArrayType is error\-prone and deprecated\. Use Type\:\:getConstantArrays\(\) instead\.$#'
18141814 identifier : phpstanApi.instanceofType
1815- count : 3
1815+ count : 1
18161816 path : src/Type/TypehintHelper.php
18171817
18181818 -
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ public static function decideType(
101101 if ($ phpDocType instanceof UnionType) {
102102 $ innerTypes = [];
103103 foreach ($ phpDocType ->getTypes () as $ innerType ) {
104- if ($ innerType instanceof ArrayType || $ innerType instanceof ConstantArrayType ) {
104+ if ($ innerType instanceof ArrayType && $ innerType-> getKeyType ()-> describe (VerbosityLevel:: typeOnly ()) === ' mixed ' ) {
105105 $ innerTypes [] = new IterableType (
106106 $ innerType ->getIterableKeyType (),
107107 $ innerType ->getItemType (),
@@ -111,7 +111,7 @@ public static function decideType(
111111 }
112112 }
113113 $ phpDocType = new UnionType ($ innerTypes );
114- } elseif ($ phpDocType instanceof ArrayType || $ phpDocType instanceof ConstantArrayType ) {
114+ } elseif ($ phpDocType instanceof ArrayType && $ phpDocType-> getKeyType ()-> describe (VerbosityLevel:: typeOnly ()) === ' mixed ' ) {
115115 $ phpDocType = new IterableType (
116116 $ phpDocType ->getKeyType (),
117117 $ 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