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

[VarDumper] Fix global dump function return value for PHP7 #28497

Merged

Conversation

Projects
None yet
3 participants
@patrickcarlohickman
Copy link
Contributor

commented Sep 18, 2018

Retarget of PR #28491. Reposting description below, with relevant updates.

Q A
Branch? 3.4
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

In 3.4, the global dump() helper function in the VarDumper component was updated to return the arguments passed in to it. However, due to reusing the argument variable in the function, this introduces a bug in PHP7 in the return value of the function.

The variable used in the foreach loop overwrites the value passed in by the first argument. In PHP5, this is okay. In PHP7, even though the argument is passed by value, the value returned by func_get_args() is affected by changes to the arguments inside the function. This is a change from PHP5.

From the documentation for func_get_args():

If the arguments are passed by reference, any changes to the arguments will be reflected in the values returned by this function. As of PHP 7 the current values will also be returned if the arguments are passed by value.

This PR simply changes the name of the variable used in the foreach loop. It also adds a test file to test the return value of the global dump() function.

This is my first contribution to Symfony, so please let me know if the issue should be resolved in a different manner, or if the test should be modified in any way.

Thanks,
Patrick

@nicolas-grekas nicolas-grekas changed the title [3.4] - Bug Fix - Fix global dump function return value for PHP7 [VarDumper] Fix global dump function return value for PHP7 Sep 18, 2018

@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Sep 18, 2018

@nicolas-grekas nicolas-grekas force-pushed the patrickcarlohickman:fix-dump-helper-return branch from fdbeb64 to 0def211 Sep 18, 2018

@nicolas-grekas

This comment has been minimized.

Copy link
Member

commented Sep 18, 2018

@nicolas-grekas nicolas-grekas merged commit 0def211 into symfony:3.4 Sep 18, 2018

1 of 3 checks passed

continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
fabbot.io Your code looks good.
Details

nicolas-grekas added a commit that referenced this pull request Sep 18, 2018

bug #28497 [VarDumper] Fix global dump function return value for PHP7…
… (patrickcarlohickman)

This PR was squashed before being merged into the 3.4 branch (closes #28497).

Discussion
----------

[VarDumper] Fix global dump function return value for PHP7

Retarget of PR #28491. Reposting description below, with relevant updates.

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

In 3.4, the global `dump()` helper function in the VarDumper component was updated to return the arguments passed in to it. However, due to reusing the argument variable in the function, this introduces a bug in PHP7 in the return value of the function.

The variable used in the `foreach` loop overwrites the value passed in by the first argument. In PHP5, this is okay. In PHP7, even though the argument is passed by value, the value returned by `func_get_args()` is affected by changes to the arguments inside the function. This is a change from PHP5.

From the documentation for [`func_get_args()`](http://php.net/manual/en/function.func-get-args.php):

> If the arguments are passed by reference, any changes to the arguments will be reflected in the values returned by this function. As of PHP 7 the current values will also be returned if the arguments are passed by value.

This PR simply changes the name of the variable used in the `foreach` loop. It also adds a test file to test the return value of the global `dump()` function.

This is my first contribution to Symfony, so please let me know if the issue should be resolved in a different manner, or if the test should be modified in any way.

Thanks,
Patrick

Commits
-------

0def211 [VarDumper] Fix global dump function return value for PHP7

This was referenced Sep 30, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.