,error_levels?:string[]}> */ public function providerValidCodeParse(): iterable { return [ 'docblockReadonlyPropertySetInConstructor' => [ 'bar = "hello"; } } echo (new A)->bar;' ], 'readonlyPropertySetInConstructor' => [ 'bar = "hello"; } } echo (new A)->bar;', [], [], '8.1' ], 'docblockReadonlyWithPrivateMutationsAllowedPropertySetInAnotherMethod' => [ 'bar = $s; } } echo (new A)->bar;' ], 'readonlyPublicPropertySetInAnotherMEthod' => [ 'bar = $s; } } echo (new A)->bar;' ], 'readonlyPropertySetChildClass' => [ 'bar = "hello"; } } echo (new B)->bar;' ], ]; } /** * @return iterable */ public function providerInvalidCodeParse(): iterable { return [ 'readonlyPropertySetInConstructorAndAlsoAnotherMethodInsideClass' => [ 'bar = "hello"; } public function setBar() : void { $this->bar = "goodbye"; } }', 'error_message' => 'InaccessibleProperty', ], 'readonlyPropertySetInConstructorAndAlsoAnotherMethodInSublass' => [ 'bar = "hello"; } } class B extends A { public function setBar() : void { $this->bar = "hello"; } }', 'error_message' => 'InaccessibleProperty', ], 'docblockReadonlyPropertySetInConstructorAndAlsoOutsideClass' => [ 'bar = "hello"; } } $a = new A(); $a->bar = "goodbye";', 'error_message' => 'InaccessibleProperty - src' . DIRECTORY_SEPARATOR . 'somefile.php:14:21', ], 'readonlyPropertySetInConstructorAndAlsoOutsideClass' => [ 'bar = "hello"; } } $a = new A(); $a->bar = "goodbye";', 'error_message' => 'InaccessibleProperty - src' . DIRECTORY_SEPARATOR . 'somefile.php:11:21', [], false, '8.1', ], 'readonlyPropertySetInConstructorAndAlsoOutsideClassWithAllowPrivate' => [ 'bar = "hello"; } public function setAgain() : void { $this->bar = "hello"; } } $a = new A(); $a->bar = "goodbye";', 'error_message' => 'InaccessibleProperty - src' . DIRECTORY_SEPARATOR . 'somefile.php:19:21', ], 'readonlyPublicPropertySetInConstructorAndAlsoOutsideClass' => [ 'bar = "hello"; } public function setAgain() : void { $this->bar = "hello"; } } $a = new A(); $a->bar = "goodbye";', 'error_message' => 'InaccessibleProperty - src' . DIRECTORY_SEPARATOR . 'somefile.php:18:21', ], 'readonlyPropertyAssignOperator' => [ 'prop = $prop; } } $test = new Test(5); $test->prop += 1;', 'error_message' => 'InaccessibleProperty' ], 'readonlyPropertyWithDefault' => [ ' 'InvalidPropertyAssignment', [], false, '8.1', ], 'readonlyPromotedPropertyAssignOperator' => [ 'bar = "goodbye";', 'error_message' => 'InaccessibleProperty - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:21', [], false, '8.1', ], 'readonlyPromotedPropertyAccess' => [ 'bar;', 'error_message' => 'InaccessibleProperty - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:26', [], false, '8.1', ], ]; } }