-
Notifications
You must be signed in to change notification settings - Fork 803
Fix bad Pure
attributes
#1730
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
base: master
Are you sure you want to change the base?
Fix bad Pure
attributes
#1730
Conversation
These functions all trigger autoloading which may have the effect of definining one or more new symbols. Note this does not apply to `function_exists()` as there is no function autoloading.
Neither of these functions depend on any external state.
Both functions have the side effect of ending the current output buffer. Whilst the latter also writes to the output stream.
As this function takes a callable it should not be marked as pure, this appears to be the convention based on all the other array user intersect/diff functions.
@@ -609,7 +605,7 @@ function get_class_vars(string $class): array {} | |||
* for the specified <i>object</i> in scope. If a property have | |||
* not been assigned a value, it will be returned with a null value. | |||
*/ | |||
#[Pure(true)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this change is also incorrect since function actually depends on global state. The function depends on the structure of the class from which the object was instantiated. If the class definition changes (e.g., due to autoloading), the result can change. Also if string property names or values are affected by locale settings (e.g., setlocale()), it might affect the output. Please correct me if I'm wrong
This PR is based on my interpretation of the documentation on the attribute that
Pure(true)
means a function:This contradicts with the interpretation in #1724 by @zonuexe which was accepted:
The reasoning for each change is documented in the commit messages.
As such it reverts some of the changes made in that PR. If my interpretation is wrong then reject this, but please improve the documentation.