Skip to content

AbstractArrayDeclarationSniff: improve the property reset #477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2023

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented May 27, 2023

Unsetting a property leaves a property in a different PHP internal state then (re)setting it to an empty value.

Most notably, an unset property triggers the magic __set()/__get() etc methods if available, and while this abstract doesn't declare those methods, a sniff implementing the abstract may.

This change maintains the target behaviour (resetting the property values to save memory), while preventing side-effects from using unset() on these properties.

Unsetting a property leaves a property in a different PHP internal state then (re)setting it to an empty value.

Most notably, an unset property triggers the magic `__set()`/`__get()` etc methods if available, and while this abstract doesn't declare those methods, a sniff implementing the abstract _may_.

This change maintains the target behaviour (resetting the property values to save memory), while preventing side-effects from using `unset()` on these properties.
@jrfnl jrfnl added this to the 1.0.6 milestone May 27, 2023
@jrfnl jrfnl merged commit 2b06f54 into develop May 27, 2023
@jrfnl jrfnl deleted the feature/abstractarraydeclaration-minor-tweak branch May 27, 2023 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant