File tree Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 20
20
use PHPStan \ShouldNotHappenException ;
21
21
use PHPStan \TrinaryLogic ;
22
22
use PHPStan \Type \Generic \GenericClassStringType ;
23
+ use PHPStan \Type \Generic \TemplateIterableType ;
23
24
use PHPStan \Type \Generic \TemplateMixedType ;
24
25
use PHPStan \Type \Generic \TemplateType ;
25
26
use PHPStan \Type \Generic \TemplateTypeMap ;
@@ -236,7 +237,7 @@ public function isSuperTypeOfWithReason(Type $otherType): IsSuperTypeOfResult
236
237
{
237
238
if (
238
239
($ otherType instanceof self && !$ otherType instanceof TemplateUnionType)
239
- || $ otherType instanceof IterableType
240
+ || ( $ otherType instanceof IterableType && ! $ otherType instanceof TemplateIterableType)
240
241
|| $ otherType instanceof NeverType
241
242
|| $ otherType instanceof ConditionalType
242
243
|| $ otherType instanceof ConditionalTypeForParameter
Original file line number Diff line number Diff line change @@ -451,6 +451,16 @@ public function testBug5231Two(): void
451
451
$ this ->assertNotEmpty ($ errors );
452
452
}
453
453
454
+ public function testBug13218 (): void
455
+ {
456
+ if (PHP_VERSION_ID < 80000 ) {
457
+ $ this ->markTestSkipped ('Test requires PHP 8.0. ' );
458
+ }
459
+
460
+ $ errors = $ this ->runAnalyse (__DIR__ . '/data/bug-13218.php ' );
461
+ $ this ->assertNoErrors ($ errors );
462
+ }
463
+
454
464
public function testBug5529 (): void
455
465
{
456
466
$ errors = $ this ->runAnalyse (__DIR__ . '/nsrt/bug-5529.php ' );
Original file line number Diff line number Diff line change
1
+ <?php // lint >= 8.0
2
+
3
+ declare (strict_types = 1 );
4
+
5
+ namespace Bug13218 ;
6
+
7
+ /**
8
+ * @template TSteps of iterable<mixed>|int
9
+ */
10
+ class Progress
11
+ {
12
+ public mixed $ total = 0 ;
13
+
14
+ /**
15
+ * Create a new ProgressBar instance.
16
+ *
17
+ * @param TSteps $steps
18
+ */
19
+ public function __construct (public string $ label , public iterable |int $ steps , public string $ hint = '' )
20
+ {
21
+ $ this ->total = match (true ) {
22
+ is_int ($ this ->steps ) => $ this ->steps ,
23
+ is_countable ($ this ->steps ) => count ($ this ->steps ),
24
+ is_iterable ($ this ->steps ) => iterator_count ($ this ->steps ),
25
+ };
26
+ }
27
+ }
You can’t perform that action at this time.
0 commit comments