Skip to content

Commit f74f499

Browse files
committed
Merge remote-tracking branch 'origin/1.12.x' into 2.1.x
2 parents 888056e + 400ba6d commit f74f499

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

src/Type/UnionType.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use PHPStan\ShouldNotHappenException;
2323
use PHPStan\TrinaryLogic;
2424
use PHPStan\Type\Generic\GenericClassStringType;
25+
use PHPStan\Type\Generic\TemplateIterableType;
2526
use PHPStan\Type\Generic\TemplateMixedType;
2627
use PHPStan\Type\Generic\TemplateType;
2728
use PHPStan\Type\Generic\TemplateTypeMap;
@@ -235,7 +236,7 @@ public function isSuperTypeOf(Type $otherType): IsSuperTypeOfResult
235236
{
236237
if (
237238
($otherType instanceof self && !$otherType instanceof TemplateUnionType)
238-
|| $otherType instanceof IterableType
239+
|| ($otherType instanceof IterableType && !$otherType instanceof TemplateIterableType)
239240
|| $otherType instanceof NeverType
240241
|| $otherType instanceof ConditionalType
241242
|| $otherType instanceof ConditionalTypeForParameter

tests/PHPStan/Analyser/AnalyserIntegrationTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,13 @@ public function testBug12512(): void
451451
$this->assertNoErrors($errors);
452452
}
453453

454+
#[RequiresPhp('>= 8.0')]
455+
public function testBug13218(): void
456+
{
457+
$errors = $this->runAnalyse(__DIR__ . '/data/bug-13218.php');
458+
$this->assertNoErrors($errors);
459+
}
460+
454461
public function testBug5529(): void
455462
{
456463
$errors = $this->runAnalyse(__DIR__ . '/nsrt/bug-5529.php');
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
}

0 commit comments

Comments
 (0)