-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
use return value instead of reference parameter #1818
Conversation
@@ -225,12 +225,12 @@ public function getData($key = '', $index = null) | |||
* Prepare Data Source | |||
* | |||
* @param array $dataSource | |||
* @return void | |||
* @return array | |||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) |
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.
Please remove it
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.
Why should i remove it? The method will return an array.
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.
I mean @SuppressWarnings(PHPMD.UnusedFormalParameter)
accepted |
@daniel-rose, thank you for contribution. This PR will be merged soon in scope of MAGETWO-43236 |
We have automated a Magento Contributor License Agreement verifier for contributions sent to our GitHub projects. |
Plugins can not listen on methods with reference parameters. The reason for this is the usage of the php function "call_user_func_array". I found this call in the method "___callPlugins" of the trait "Magento\Framework\Interception\Interceptor".
Note on php.net for "call_user_func_array":
Before PHP 5.4, referenced variables in param_arr are passed to the function by reference, regardless of whether the function expects the respective parameter to be passed by reference. This form of call-time pass by reference does not emit a deprecation notice, but it is nonetheless deprecated, and has been removed in PHP 5.4. Furthermore, this does not apply to internal functions, for which the function signature is honored. Passing by value when the function expects a parameter by reference results in a warning and having call_user_func() return FALSE (there is, however, an exception for passed values with reference count = 1, such as in literals, as these can be turned into references without ill effects — but also without writes to that value having any effect —; do not rely in this behavior, though, as the reference count is an implementation detail and the soundness of this behavior is questionable).