File tree Expand file tree Collapse file tree 3 files changed +72
-0
lines changed Expand file tree Collapse file tree 3 files changed +72
-0
lines changed Original file line number Diff line number Diff line change @@ -1184,6 +1184,12 @@ public function testBug5091(): void
1184
1184
$ this ->assertNoErrors ($ errors );
1185
1185
}
1186
1186
1187
+ public function testBug9346 (): void
1188
+ {
1189
+ $ errors = $ this ->runAnalyse (__DIR__ . '/data/bug-9346.php ' );
1190
+ $ this ->assertNoErrors ($ errors );
1191
+ }
1192
+
1187
1193
public function testBug9459 (): void
1188
1194
{
1189
1195
$ errors = $ this ->runAnalyse (__DIR__ . '/data/bug-9459.php ' );
Original file line number Diff line number Diff line change @@ -181,6 +181,8 @@ public function dataFileAsserts(): iterable
181
181
yield from $ this ->gatherAssertTypes (__DIR__ . '/../Rules/Methods/data/bug-9542.php ' );
182
182
yield from $ this ->gatherAssertTypes (__DIR__ . '/../Rules/Functions/data/bug-9803.php ' );
183
183
yield from $ this ->gatherAssertTypes (__DIR__ . '/../Rules/PhpDoc/data/bug-10594.php ' );
184
+
185
+ yield from $ this ->gatherAssertTypes (__DIR__ . '/../Rules/Methods/data/bug-9346.php ' );
184
186
}
185
187
186
188
/**
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Bug9346 ;
4
+
5
+ use DateTime ;
6
+
7
+ /**
8
+ * @phpstan-type MyType array{
9
+ * key?: string,
10
+ * }
11
+ */
12
+ class Test
13
+ {
14
+ /**
15
+ * @param MyType $params
16
+ */
17
+ public function create (array $ params = []): object
18
+ {
19
+ return new class ($ params ) {
20
+ /**
21
+ * @param MyType $params
22
+ */
23
+ public function __construct (private array $ params )
24
+ {
25
+ }
26
+ };
27
+ }
28
+ }
29
+
30
+ /**
31
+ * @phpstan-type FooJson array{bar: string}
32
+ */
33
+ interface Foo
34
+ {
35
+ /**
36
+ * @phpstan-return FooJson
37
+ */
38
+ public function sayHello (DateTime $ date ): array ;
39
+ }
40
+
41
+ /**
42
+ * @phpstan-import-type FooJson from Foo
43
+ */
44
+ class HelloWorld
45
+ {
46
+ public function createFoo (): Foo
47
+ {
48
+ $ foo = new class () implements Foo {
49
+ /**
50
+ * @phpstan-var FooJson $var
51
+ */
52
+ private array $ var = ['bar ' => 'baz ' ];
53
+
54
+ /**
55
+ * @phpstan-return FooJson
56
+ */
57
+ public function sayHello (DateTime $ date ): array
58
+ {
59
+ return $ this ->var ;
60
+ }
61
+ };
62
+ return $ foo ;
63
+ }
64
+ }
You can’t perform that action at this time.
0 commit comments