Skip to content
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

Merged
merged 2 commits into from
Oct 6, 2015

Conversation

daniel-rose
Copy link
Contributor

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).

@@ -225,12 +225,12 @@ public function getData($key = '', $index = null)
* Prepare Data Source
*
* @param array $dataSource
* @return void
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove it

Copy link
Contributor Author

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.

Copy link
Contributor

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)

@maxwhite-ua
Copy link
Contributor

accepted

@maxwhite-ua
Copy link
Contributor

@daniel-rose, thank you for contribution. This PR will be merged soon in scope of MAGETWO-43236

@magento-cicd2
Copy link
Contributor

We have automated a Magento Contributor License Agreement verifier for contributions sent to our GitHub projects.
Please see the CLA agreement in the Pull Request comments below.

@magento-cicd2 magento-cicd2 reopened this Oct 1, 2015
@magento-team magento-team merged commit eebdcb7 into magento:develop Oct 6, 2015
magento-team pushed a commit that referenced this pull request Dec 11, 2017
[EngCom] Public Pull Requests - develop
 - MAGETWO-85225: [2.3] - Add schedule backlog to indexer:status #12592
 - MAGETWO-85096: [Backport 2.3] Added namespace to product videos fotorama events #12556
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.

5 participants