[ 'code' => 'bar = "hello"; } } echo (new A)->bar;' ], 'readonlyPropertySetInConstructor' => [ 'code' => 'bar = "hello"; } } echo (new A)->bar;', 'assertions' => [], 'ignored_issues' => [], 'php_version' => '8.1' ], 'docblockReadonlyWithPrivateMutationsAllowedPropertySetInAnotherMethod' => [ 'code' => 'bar = $s; } } echo (new A)->bar;' ], 'readonlyPublicPropertySetInAnotherMethod' => [ 'code' => 'bar = $s; } } echo (new A)->bar;' ], 'docblockReadonlyWithPrivateMutationsAllowedConstructorPropertySetInAnotherMethod' => [ 'code' => 'bar = $s; } } echo (new A)->bar;' ], 'readonlyPublicConstructorPropertySetInAnotherMethod' => [ 'code' => 'bar = $s; } } echo (new A)->bar;' ], 'readonlyPropertySetChildClass' => [ 'code' => 'bar = "hello"; } } echo (new B)->bar;' ], ]; } /** * */ public function providerInvalidCodeParse(): iterable { return [ 'readonlyPropertySetInConstructorAndAlsoAnotherMethodInsideClass' => [ 'code' => 'bar = "hello"; } public function setBar() : void { $this->bar = "goodbye"; } }', 'error_message' => 'InaccessibleProperty', ], 'readonlyPropertySetInConstructorAndAlsoAnotherMethodInSublass' => [ 'code' => 'bar = "hello"; } } class B extends A { public function setBar() : void { $this->bar = "hello"; } }', 'error_message' => 'InaccessibleProperty', ], 'docblockReadonlyPropertySetInConstructorAndAlsoOutsideClass' => [ 'code' => 'bar = "hello"; } } $a = new A(); $a->bar = "goodbye";', 'error_message' => 'InaccessibleProperty - src' . DIRECTORY_SEPARATOR . 'somefile.php:14:21', ], 'readonlyPropertySetInConstructorAndAlsoOutsideClass' => [ 'code' => 'bar = "hello"; } } $a = new A(); $a->bar = "goodbye";', 'error_message' => 'InaccessibleProperty - src' . DIRECTORY_SEPARATOR . 'somefile.php:11:21', 'ignored_issues' => [], 'php_version' => '8.1', ], 'readonlyPropertySetInConstructorAndAlsoOutsideClassWithAllowPrivate' => [ 'code' => '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' => [ 'code' => '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' => [ 'code' => 'prop = $prop; } } $test = new Test(5); $test->prop += 1;', 'error_message' => 'InaccessibleProperty' ], 'readonlyPropertyWithDefault' => [ 'code' => ' 'InvalidPropertyAssignment', 'ignored_issues' => [], 'php_version' => '8.1', ], 'readonlyPromotedPropertyAssignOperator' => [ 'code' => 'bar = "goodbye";', 'error_message' => 'InaccessibleProperty - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:21', 'ignored_issues' => [], 'php_version' => '8.1', ], 'readonlyPromotedPropertyAccess' => [ 'code' => 'bar;', 'error_message' => 'InaccessibleProperty - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:26', 'ignored_issues' => [], 'php_version' => '8.1', ], 'readonlyPhpDocPromotedPropertyAssignOperator' => [ 'code' => 'string = ""; } }', 'error_message' => 'InaccessibleProperty', 'ignored_issues' => [], 'php_version' => '8.1', ], ]; } }