Skip to content

Commit e58f686

Browse files
committed
Fix tests
1 parent d0a55f3 commit e58f686

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

‎tests/PHPStan/Analyser/data/generics.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1395,7 +1395,7 @@ class CarFactoryProcessor {
13951395
*/
13961396
public function process($class): void {
13971397
$car = $class::create();
1398-
assertType(Car::class, $car);
1398+
assertType(T::class, $car); // @template T is unknown in static method
13991399
}
14001400
}
14011401

‎tests/PHPStan/Rules/Methods/CallStaticMethodsRuleTest.php‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,12 @@ public function testBug6249(): void
470470
// discussion https://github.com/phpstan/phpstan/discussions/6249
471471
$this->checkThisOnly = false;
472472
$this->checkExplicitMixed = true;
473-
$this->analyse([__DIR__ . '/data/bug-6249.php'], []);
473+
$this->analyse([__DIR__ . '/data/bug-6249.php'], [
474+
[
475+
'Parameter #1 $iterable of static method Bug6249N3\Cw<(int|string),mixed>::fromIterable() expects iterable<Bug6249N3\TKey, Bug6249N3\T>, Bug6249N2\Eii given.',
476+
145,
477+
],
478+
]);
474479
}
475480

476481
public function testBug5749(): void

‎tests/PHPStan/Rules/Methods/data/bug-6249.php‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ public static function fromIterable(iterable $iterable): self
106106
return new self($iterable);
107107
}
108108

109+
/**
110+
* @template UKey of array-key
111+
* @template U
112+
* @param iterable<UKey, U> $iterable
113+
*
114+
* @return self<UKey, U>
115+
*/
116+
public static function fromIterableCorrect(iterable $iterable): self
117+
{
118+
return new self($iterable);
119+
}
120+
109121
public function count(): int
110122
{
111123
if (is_array($this->iterable) || $this->iterable instanceof Countable) {
@@ -131,6 +143,7 @@ class Foo
131143
public function doFoo()
132144
{
133145
\Bug6249N3\Cw::fromIterable(new \Bug6249N2\Eii([]));
146+
\Bug6249N3\Cw::fromIterableCorrect(new \Bug6249N2\Eii([]));
134147
}
135148

136149
}

0 commit comments

Comments
 (0)