File tree Expand file tree Collapse file tree 9 files changed +293
-6
lines changed
tests/PHPStan/Rules/TooWideTypehints Expand file tree Collapse file tree 9 files changed +293
-6
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,11 @@ protected function getRule(): Rule
16
16
return new TooWideClosureReturnTypehintRule ();
17
17
}
18
18
19
+ public function testBug10312e (): void
20
+ {
21
+ $ this ->analyse ([__DIR__ . '/data/bug-10312e.php ' ], []);
22
+ }
23
+
19
24
public function testRule (): void
20
25
{
21
26
$ this ->analyse ([__DIR__ . '/data/tooWideClosureReturnType.php ' ], [
Original file line number Diff line number Diff line change @@ -61,4 +61,9 @@ public function testBug11980(): void
61
61
]);
62
62
}
63
63
64
+ public function testBug10312a (): void
65
+ {
66
+ $ this ->analyse ([__DIR__ . '/data/bug-10312a.php ' ], []);
67
+ }
68
+
64
69
}
Original file line number Diff line number Diff line change @@ -88,12 +88,7 @@ public function testPublicProtectedWithInheritance(): void
88
88
89
89
public function testBug5095 (): void
90
90
{
91
- $ this ->analyse ([__DIR__ . '/data/bug-5095.php ' ], [
92
- [
93
- 'Method Bug5095\Parser::unaryOperatorFor() never returns \'not \' so it can be removed from the return type. ' ,
94
- 21 ,
95
- ],
96
- ]);
91
+ $ this ->analyse ([__DIR__ . '/data/bug-5095.php ' ], []);
97
92
}
98
93
99
94
#[RequiresPhp('>= 8.0 ' )]
@@ -199,4 +194,28 @@ public function testBug11980(): void
199
194
]);
200
195
}
201
196
197
+ public function testBug10312 (): void
198
+ {
199
+ $ this ->checkProtectedAndPublicMethods = true ;
200
+ $ this ->analyse ([__DIR__ . '/data/bug-10312.php ' ], []);
201
+ }
202
+
203
+ public function testBug10312b (): void
204
+ {
205
+ $ this ->checkProtectedAndPublicMethods = true ;
206
+ $ this ->analyse ([__DIR__ . '/data/bug-10312b.php ' ], []);
207
+ }
208
+
209
+ public function testBug10312c (): void
210
+ {
211
+ $ this ->checkProtectedAndPublicMethods = true ;
212
+ $ this ->analyse ([__DIR__ . '/data/bug-10312c.php ' ], []);
213
+ }
214
+
215
+ public function testBug10312d (): void
216
+ {
217
+ $ this ->checkProtectedAndPublicMethods = true ;
218
+ $ this ->analyse ([__DIR__ . '/data/bug-10312d.php ' ], []);
219
+ }
220
+
202
221
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Bug10312 ;
4
+
5
+ class Cmsissue
6
+ {
7
+ public const LANE_BACKLOG = 'Backlog ' ;
8
+
9
+ public const LANE_READY_FOR_IMPL = 'Bereit zur Entwicklung ' ;
10
+
11
+ public const LANE_IN_IMPL = 'In Entwicklung ' ;
12
+
13
+ public const LANE_READY_FOR_UAT = 'Bereit zur Abnahme ' ;
14
+
15
+ public const LANE_READY_FOR_UAT_KANBAN = 'Test ' ;
16
+
17
+ public const LANE_PROJECT_BACKLOG = 'Backlog ' ;
18
+
19
+ public const LANE_PROJECT_IN_IMPL = 'Projekt in Umsetzung ' ;
20
+
21
+ public const LANE_SKIP = '' ;
22
+ }
23
+
24
+
25
+ final class Mapper
26
+ {
27
+
28
+ /**
29
+ * @return Cmsissue::LANE_*
30
+ */
31
+ public function mapIssueStatus (): string
32
+ {
33
+ if (rand (0 ,1 ) === 0 ) {
34
+ return Cmsissue::LANE_BACKLOG ;
35
+ }
36
+ if (rand (0 ,1 ) === 0 ) {
37
+ return Cmsissue::LANE_READY_FOR_IMPL ;
38
+ }
39
+ if (rand (0 ,1 ) === 0 ) {
40
+ return Cmsissue::LANE_IN_IMPL ;
41
+ }
42
+ if (rand (0 ,1 ) === 0 ) {
43
+ return Cmsissue::LANE_READY_FOR_UAT ;
44
+ }
45
+
46
+ return Cmsissue::LANE_SKIP ;
47
+ }
48
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Bug10312a ;
4
+
5
+ class Cmsissue
6
+ {
7
+ public const LANE_BACKLOG = 'Backlog ' ;
8
+
9
+ public const LANE_READY_FOR_IMPL = 'Bereit zur Entwicklung ' ;
10
+
11
+ public const LANE_IN_IMPL = 'In Entwicklung ' ;
12
+
13
+ public const LANE_READY_FOR_UAT = 'Bereit zur Abnahme ' ;
14
+
15
+ public const LANE_READY_FOR_UAT_KANBAN = 'Test ' ;
16
+
17
+ public const LANE_PROJECT_BACKLOG = 'Backlog ' ;
18
+
19
+ public const LANE_PROJECT_IN_IMPL = 'Projekt in Umsetzung ' ;
20
+
21
+ public const LANE_SKIP = '' ;
22
+ }
23
+
24
+
25
+ /**
26
+ * @return Cmsissue::LANE_*
27
+ */
28
+ function mapIssueStatus (): string
29
+ {
30
+ if (rand (0 ,1 ) === 0 ) {
31
+ return Cmsissue::LANE_BACKLOG ;
32
+ }
33
+ if (rand (0 ,1 ) === 0 ) {
34
+ return Cmsissue::LANE_READY_FOR_IMPL ;
35
+ }
36
+ if (rand (0 ,1 ) === 0 ) {
37
+ return Cmsissue::LANE_IN_IMPL ;
38
+ }
39
+ if (rand (0 ,1 ) === 0 ) {
40
+ return Cmsissue::LANE_READY_FOR_UAT ;
41
+ }
42
+
43
+ return Cmsissue::LANE_SKIP ;
44
+ }
45
+
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Bug10312b ;
4
+
5
+ interface MinPhpVersionInterface
6
+ {
7
+ /**
8
+ * @return PhpVersion::*
9
+ */
10
+ public function provideMinPhpVersion () : int ;
11
+ }
12
+
13
+ final class PhpVersion
14
+ {
15
+ /**
16
+ * @var int
17
+ */
18
+ public const PHP_52 = 50200 ;
19
+ /**
20
+ * @var int
21
+ */
22
+ public const PHP_53 = 50300 ;
23
+ /**
24
+ * @var int
25
+ */
26
+ public const PHP_54 = 50400 ;
27
+ /**
28
+ * @var int
29
+ */
30
+ public const PHP_55 = 50500 ;
31
+ }
32
+
33
+ final class TypedPropertyFromStrictConstructorReadonlyClassRector implements MinPhpVersionInterface
34
+ {
35
+ public function provideMinPhpVersion (): int
36
+ {
37
+ return PhpVersion::PHP_55 ;
38
+ }
39
+
40
+ }
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types = 1 );
2
+
3
+ namespace Bug10312c ;
4
+
5
+ enum Foo: int
6
+ {
7
+ case BAR = 1 ;
8
+ case BAZ = 2 ;
9
+ }
10
+
11
+ interface ReturnsFoo
12
+ {
13
+ /** @return value-of<Foo> */
14
+ public function returnsFooValue (): int ;
15
+ }
16
+
17
+ class ReturnsBar implements ReturnsFoo
18
+ {
19
+ #[\Override]
20
+ public function returnsFooValue (): int
21
+ {
22
+ return Foo::BAR ->value ;
23
+ }
24
+ }
25
+
26
+ class ReturnsBarWithFinalMethod implements ReturnsFoo
27
+ {
28
+ #[\Override]
29
+ final public function returnsFooValue (): int
30
+ {
31
+ return Foo::BAR ->value ;
32
+ }
33
+ }
34
+
35
+ final class ReturnsBaz implements ReturnsFoo
36
+ {
37
+ #[\Override]
38
+ public function returnsFooValue (): int
39
+ {
40
+ return Foo::BAZ ->value ;
41
+ }
42
+ }
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types = 1 );
2
+
3
+ namespace Bug10312d ;
4
+
5
+ enum Foo: int
6
+ {
7
+ case BAR = 1 ;
8
+ case BAZ = 2 ;
9
+ }
10
+
11
+ class FooBar {
12
+ public ?Foo $ foo = null ;
13
+ }
14
+
15
+ interface ReturnsFoo
16
+ {
17
+ /** @return value-of<Foo> */
18
+ public function returnsFooValue (): int ;
19
+
20
+ /** @return value-of<Foo>|null */
21
+ public function returnsFooOrNullValue (): ?int ;
22
+ }
23
+
24
+ final class ReturnsNullsafeBaz implements ReturnsFoo
25
+ {
26
+ #[\Override]
27
+ public function returnsFooValue (): int
28
+ {
29
+ $ f = new FooBar ();
30
+ return $ f ->foo ?->value;
31
+ }
32
+
33
+ #[\Override]
34
+ public function returnsFooOrNullValue (): ?int
35
+ {
36
+ $ f = new FooBar ();
37
+ return $ f ->foo ?->value;
38
+ }
39
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Bug10312a ;
4
+
5
+ class Cmsissue
6
+ {
7
+ public const LANE_BACKLOG = 'Backlog ' ;
8
+
9
+ public const LANE_READY_FOR_IMPL = 'Bereit zur Entwicklung ' ;
10
+
11
+ public const LANE_IN_IMPL = 'In Entwicklung ' ;
12
+
13
+ public const LANE_READY_FOR_UAT = 'Bereit zur Abnahme ' ;
14
+
15
+ public const LANE_READY_FOR_UAT_KANBAN = 'Test ' ;
16
+
17
+ public const LANE_PROJECT_BACKLOG = 'Backlog ' ;
18
+
19
+ public const LANE_PROJECT_IN_IMPL = 'Projekt in Umsetzung ' ;
20
+
21
+ public const LANE_SKIP = '' ;
22
+ }
23
+
24
+
25
+ /**
26
+ * @return Cmsissue::LANE_*
27
+ */
28
+ $ x = function (): string
29
+ {
30
+ if (rand (0 ,1 ) === 0 ) {
31
+ return Cmsissue::LANE_BACKLOG ;
32
+ }
33
+ if (rand (0 ,1 ) === 0 ) {
34
+ return Cmsissue::LANE_READY_FOR_IMPL ;
35
+ }
36
+ if (rand (0 ,1 ) === 0 ) {
37
+ return Cmsissue::LANE_IN_IMPL ;
38
+ }
39
+ if (rand (0 ,1 ) === 0 ) {
40
+ return Cmsissue::LANE_READY_FOR_UAT ;
41
+ }
42
+
43
+ return Cmsissue::LANE_SKIP ;
44
+ };
You can’t perform that action at this time.
0 commit comments