Skip to content

Commit faa8fc9

Browse files
phpstan-botclaude
andcommitted
Add non-regression test for varTag.type rule with generic @var tag
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9f0da34 commit faa8fc9

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

tests/PHPStan/Rules/PhpDoc/VarTagChangedExpressionTypeRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ public function testBug10130(): void
7979
]);
8080
}
8181

82+
public function testBug14429(): void
83+
{
84+
$this->analyse([__DIR__ . '/data/bug-14429-var-tag.php'], []);
85+
}
86+
8287
public function testBug12708(): void
8388
{
8489
$this->analyse([__DIR__ . '/data/bug-12708.php'], [
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
namespace Bug14429VarTag;
6+
7+
/** @template E of IEntity */
8+
class ICollection {}
9+
10+
class IEntity {
11+
/** @return ICollection<IEntity> */
12+
public function getCollection(): ICollection { return new ICollection(); }
13+
}
14+
15+
/**
16+
* @template E of IEntity
17+
*/
18+
class OneHasOne
19+
{
20+
/**
21+
* @return ICollection<E>
22+
*/
23+
protected function createCollection(IEntity $e): ICollection
24+
{
25+
/** @var ICollection<E> $collection */
26+
$collection = $e->getCollection();
27+
return $collection;
28+
}
29+
}

0 commit comments

Comments
 (0)