@@ -287,4 +287,101 @@ public function testBug10822(): void
287
287
$ this ->analyse ([__DIR__ . '/data/bug-10822.php ' ], []);
288
288
}
289
289
290
+ public function testRedeclaredReadonlyProperties (): void
291
+ {
292
+ if (PHP_VERSION_ID < 80100 ) {
293
+ $ this ->markTestSkipped ('Test requires PHP 8.1. ' );
294
+ }
295
+
296
+ $ this ->analyse ([__DIR__ . '/data/redeclare-readonly-property.php ' ], [
297
+ [
298
+ 'Readonly property RedeclareReadonlyProperty\B1::$myProp is already assigned. ' ,
299
+ 16 ,
300
+ ],
301
+ [
302
+ 'Readonly property RedeclareReadonlyProperty\B5::$myProp is already assigned. ' ,
303
+ 50 ,
304
+ ],
305
+ [
306
+ 'Readonly property RedeclareReadonlyProperty\B7::$myProp is already assigned. ' ,
307
+ 70 ,
308
+ ],
309
+ [
310
+ 'Readonly property class@anonymous/tests/PHPStan/Rules/Properties/data/redeclare-readonly-property.php:117::$myProp is already assigned. ' ,
311
+ 121 ,
312
+ ],
313
+ [
314
+ 'Class RedeclareReadonlyProperty\B16 has an uninitialized readonly property $myProp. Assign it in the constructor. ' ,
315
+ 195 ,
316
+ ],
317
+ [
318
+ 'Class RedeclareReadonlyProperty\C17 has an uninitialized readonly property $aProp. Assign it in the constructor. ' ,
319
+ 218 ,
320
+ ],
321
+ [
322
+ 'Class RedeclareReadonlyProperty\B18 has an uninitialized readonly property $aProp. Assign it in the constructor. ' ,
323
+ 233 ,
324
+ ],
325
+ ]);
326
+ }
327
+
328
+ public function testRedeclaredPropertiesOfReadonlyClass (): void
329
+ {
330
+ if (PHP_VERSION_ID < 80200 ) {
331
+ $ this ->markTestSkipped ('Test requires PHP 8.2. ' );
332
+ }
333
+
334
+ $ this ->analyse ([__DIR__ . '/data/redeclare-property-of-readonly-class.php ' ], [
335
+ [
336
+ 'Readonly property RedeclarePropertyOfReadonlyClass\B1::$promotedProp is already assigned. ' ,
337
+ 15 ,
338
+ ],
339
+ ]);
340
+ }
341
+
342
+ public function testBug8101 (): void
343
+ {
344
+ if (PHP_VERSION_ID < 80100 ) {
345
+ $ this ->markTestSkipped ('Test requires PHP 8.1. ' );
346
+ }
347
+
348
+ $ this ->analyse ([__DIR__ . '/data/bug-8101.php ' ], [
349
+ [
350
+ 'Readonly property Bug8101\B::$myProp is already assigned. ' ,
351
+ 12 ,
352
+ ],
353
+ ]);
354
+ }
355
+
356
+ public function testBug9863 (): void
357
+ {
358
+ if (PHP_VERSION_ID < 80100 ) {
359
+ $ this ->markTestSkipped ('Test requires PHP 8.1. ' );
360
+ }
361
+
362
+ $ this ->analyse ([__DIR__ . '/data/bug-9863.php ' ], [
363
+ [
364
+ 'Readonly property Bug9863\ReadonlyChildWithoutIsset::$foo is already assigned. ' ,
365
+ 17 ,
366
+ ],
367
+ [
368
+ 'Class Bug9863\ReadonlyParentWithIsset has an uninitialized readonly property $foo. Assign it in the constructor. ' ,
369
+ 23 ,
370
+ ],
371
+ [
372
+ 'Access to an uninitialized readonly property Bug9863\ReadonlyParentWithIsset::$foo. ' ,
373
+ 28 ,
374
+ ],
375
+ ]);
376
+ }
377
+
378
+ public function testBug9864 (): void
379
+ {
380
+ if (PHP_VERSION_ID < 80100 ) {
381
+ $ this ->markTestSkipped ('Test requires PHP 8.1. ' );
382
+ }
383
+
384
+ $ this ->analyse ([__DIR__ . '/data/bug-9864.php ' ], []);
385
+ }
386
+
290
387
}
0 commit comments