Bug Report
| Subject |
Details |
| Rector version |
2.4.2 |
Private/promoted properties get removed when get_object_vars is used without JsonSerializable, e.g. in a toArray method.
Issue #8904 was solved by handling only the JsonSerializable special case via rectorphp/rector-src#6472.
I think the way to go is to mimic PHPStan which recognizes get_objects_vars and array_walk as property enumerating functions anywhere, see phpstan/phpstan-src#1902.
Minimal PHP Code Causing Issue
https://getrector.com/demo/88db4b68-2d1f-44c6-a2e8-8bc2ae803990
e.g. toArray due to implementing Illuminate\Contracts\Support\Arrayable, but not necessarily.
Expected Behaviour
No change
Workaround
List affected files in withSkip for both RemoveUnusedPrivatePropertyRector and RemoveUnusedPromotedPropertyRector (as applicable).
Bug Report
Private/promoted properties get removed when get_object_vars is used without JsonSerializable, e.g. in a toArray method.
Issue #8904 was solved by handling only the JsonSerializable special case via rectorphp/rector-src#6472.
I think the way to go is to mimic PHPStan which recognizes get_objects_vars and array_walk as property enumerating functions anywhere, see phpstan/phpstan-src#1902.
Minimal PHP Code Causing Issue
https://getrector.com/demo/88db4b68-2d1f-44c6-a2e8-8bc2ae803990
e.g. toArray due to implementing Illuminate\Contracts\Support\Arrayable, but not necessarily.
Expected Behaviour
No change
Workaround
List affected files in withSkip for both RemoveUnusedPrivatePropertyRector and RemoveUnusedPromotedPropertyRector (as applicable).