File tree Expand file tree Collapse file tree
tests/PHPStan/Rules/Generics Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -290,4 +290,9 @@ public function testBug7021(): void
290290 $ this ->analyse ([__DIR__ . '/data/bug-7021.php ' ], []);
291291 }
292292
293+ public function testBug7152 (): void
294+ {
295+ $ this ->analyse ([__DIR__ . '/data/bug-7152.php ' ], []);
296+ }
297+
293298}
Original file line number Diff line number Diff line change @@ -151,4 +151,20 @@ public function testBug10049(): void
151151 ]);
152152 }
153153
154+ public function testBug11314 (): void
155+ {
156+ $ this ->analyse ([__DIR__ . '/data/bug-11314.php ' ], []);
157+ }
158+
159+ #[RequiresPhp('>= 8.1.0 ' )]
160+ public function testBug13332 (): void
161+ {
162+ $ this ->analyse ([__DIR__ . '/data/bug-13332.php ' ], []);
163+ }
164+
165+ public function testBug7152 (): void
166+ {
167+ $ this ->analyse ([__DIR__ . '/data/bug-7152.php ' ], []);
168+ }
169+
154170}
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace Bug11314Generics ;
4+
5+ /**
6+ * @phpstan-type Breed 'Siamese'|'British Shorthair'|'Maine Coon'
7+ */
8+ class Cat
9+ {
10+ /**
11+ * @var Breed
12+ */
13+ public string $ breed ;
14+ }
15+
16+ /**
17+ * @phpstan-import-type Breed from Cat
18+ *
19+ * @template T of Breed
20+ */
21+ class Cat2
22+ {
23+ /**
24+ * @var Breed
25+ */
26+ public string $ breed ;
27+ }
28+
29+ /**
30+ * @phpstan-import-type Breed from Cat
31+ */
32+ class Cat3
33+ {
34+ /**
35+ * @var Breed
36+ */
37+ public string $ breed ;
38+ }
Original file line number Diff line number Diff line change 1+ <?php // lint >= 8.1
2+
3+ declare (strict_types = 1 );
4+
5+ namespace Bug13332Generics ;
6+
7+ enum TestEnum {
8+ case A;
9+ case B;
10+ }
11+
12+ /**
13+ * @phpstan-type KeyType string|int|\UnitEnum|object
14+ *
15+ * @template K of KeyType
16+ */
17+ class TestError
18+ {
19+ /** @param K $key */
20+ public function __construct (private readonly mixed $ key )
21+ {
22+ }
23+
24+ /** @return self<TestEnum> */
25+ public static function makeEnum (): self
26+ {
27+ return new self (TestEnum::A);
28+ }
29+
30+ /** @return self<string> */
31+ public static function makeString (): self
32+ {
33+ return new self ('foo ' );
34+ }
35+ }
36+
37+ /**
38+ * @template K of string|int|\UnitEnum|object
39+ */
40+ class TestOk
41+ {
42+ /** @param K $key */
43+ public function __construct (private readonly mixed $ key )
44+ {
45+ }
46+
47+ /** @return self<TestEnum> */
48+ public static function makeEnum (): self
49+ {
50+ return new self (TestEnum::A);
51+ }
52+ }
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace Bug7152Generics ;
4+
5+ /**
6+ * @template T of array<mixed>
7+ */
8+ class Root
9+ {
10+ /** @var T */
11+ public array $ value ;
12+ }
13+
14+ /**
15+ * @phpstan-type Foo array<int>
16+ * @template T of Foo
17+ * @extends Root<T>
18+ */
19+ class Middle extends Root
20+ {
21+ }
22+
23+ /**
24+ * @template T of array<int>
25+ * @extends Root<T>
26+ */
27+ class Middle2 extends Root
28+ {
29+ }
You can’t perform that action at this time.
0 commit comments