File tree Expand file tree Collapse file tree 3 files changed +72
-0
lines changed
tests/PHPStan/Rules/Comparison Expand file tree Collapse file tree 3 files changed +72
-0
lines changed Original file line number Diff line number Diff line change @@ -1068,4 +1068,16 @@ public function testBug9666(): void
1068
1068
]);
1069
1069
}
1070
1070
1071
+ public function testBug9445 (): void
1072
+ {
1073
+ $ this ->treatPhpDocTypesAsCertain = true ;
1074
+ $ this ->analyse ([__DIR__ . '/data/bug-9445.php ' ], []);
1075
+ }
1076
+
1077
+ public function testBug7773 (): void
1078
+ {
1079
+ $ this ->treatPhpDocTypesAsCertain = true ;
1080
+ $ this ->analyse ([__DIR__ . '/data/bug-7773.php ' ], []);
1081
+ }
1082
+
1071
1083
}
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types=1 );
2
+
3
+ namespace Bug7773 ;
4
+
5
+ class JSONEncodingException extends \Exception
6
+ {
7
+ }
8
+
9
+ class JSONDecodingException extends \Exception
10
+ {
11
+ }
12
+
13
+ class HelloWorld
14
+ {
15
+ /**
16
+ * Encodes the data as JSON
17
+ * @param array<mixed> $data json array
18
+ * @return string json string
19
+ * @throws JSONEncodingException
20
+ */
21
+ public static function JSONEncode (array $ data ): string
22
+ {
23
+ if (!is_string ($ data = json_encode ($ data )))
24
+ throw new JSONEncodingException ();
25
+ return $ data ;
26
+ }
27
+
28
+ /**
29
+ * Decodes the JSON data as an array
30
+ * @param string $data json string
31
+ * @return array<mixed> json array
32
+ * @throws JSONDecodingException
33
+ */
34
+ public static function JSONDecode (string $ data ): array
35
+ {
36
+ if (!is_array ($ data = json_decode ($ data , true )))
37
+ throw new JSONDecodingException ();
38
+ return $ data ;
39
+ }
40
+ }
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types=1 );
2
+
3
+ namespace Bug9445 ;
4
+
5
+ class Foo
6
+ {
7
+ public int $ id ;
8
+ public null |self $ parent ;
9
+
10
+ public function contains (self $ foo ): bool
11
+ {
12
+ do {
13
+ if ($ this ->id === $ foo ->id ) {
14
+ return true ;
15
+ }
16
+ } while (!is_null ($ foo = $ foo ->parent ));
17
+
18
+ return false ;
19
+ }
20
+ }
You can’t perform that action at this time.
0 commit comments