File tree Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,7 @@ public function dataFileAsserts(): iterable
119
119
yield from $ this ->gatherAssertTypes (__DIR__ . '/data/bug-3269.php ' );
120
120
yield from $ this ->gatherAssertTypes (__DIR__ . '/data/assign-nested-arrays.php ' );
121
121
yield from $ this ->gatherAssertTypes (__DIR__ . '/data/bug-3276.php ' );
122
+ yield from $ this ->gatherAssertTypes (__DIR__ . '/../Rules/Methods/data/bug-6856.php ' );
122
123
yield from $ this ->gatherAssertTypes (__DIR__ . '/data/shadowed-trait-methods.php ' );
123
124
yield from $ this ->gatherAssertTypes (__DIR__ . '/data/const-in-functions.php ' );
124
125
yield from $ this ->gatherAssertTypes (__DIR__ . '/data/const-in-functions-namespaced.php ' );
Original file line number Diff line number Diff line change @@ -934,4 +934,9 @@ public function testLists(): void
934
934
]);
935
935
}
936
936
937
+ public function testBug6856 (): void
938
+ {
939
+ $ this ->analyse ([__DIR__ . '/data/bug-6856.php ' ], []);
940
+ }
941
+
937
942
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Bug6856 ;
4
+
5
+ use function PHPStan \Testing \assertType ;
6
+
7
+ /**
8
+ * @template T of object
9
+ */
10
+ trait TraitA {
11
+ /**
12
+ * @return T
13
+ */
14
+ public function a (): object {
15
+ return new ClassB ();
16
+ }
17
+
18
+ /**
19
+ * @return T
20
+ */
21
+ public function test (): object {
22
+ return new ClassB ();
23
+ }
24
+ }
25
+
26
+ class ClassA {
27
+ /**
28
+ * @phpstan-use TraitA<ClassB>
29
+ */
30
+ use TraitA {
31
+ a as renamed;
32
+ }
33
+
34
+ public function a (): ClassB {
35
+ return $ this ->renamed ();
36
+ }
37
+
38
+ public function b (): ClassB {
39
+ return $ this ->test ();
40
+ }
41
+ }
42
+
43
+ class ClassB {
44
+ // empty
45
+ }
46
+
47
+ function (ClassA $ a ): void {
48
+ assertType (ClassB::class, $ a ->a ());
49
+ assertType (ClassB::class, $ a ->renamed ());
50
+ assertType (ClassB::class, $ a ->test ());
51
+ assertType (ClassB::class, $ a ->b ());
52
+ };
You can’t perform that action at this time.
0 commit comments