-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Fix misleading pass by reference error message #10639
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
Fix misleading pass by reference error message #10639
Conversation
Zend/tests/bug73663_2.phpt
Outdated
@@ -12,7 +12,7 @@ change(list($val) = $array); | |||
var_dump($array); | |||
?> | |||
--EXPECTF-- | |||
Fatal error: Uncaught Error: change(): Argument #1 ($ref) cannot be passed by reference in %s:%d | |||
Fatal error: Uncaught Error: change(): Argument #1 ($ref) must be passed by reference in %s:%d |
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 don't agree with the wording, the issue is that the thing being passed to the function parameter is a value for which a reference cannot be taken, as it's only variables that can be passed by references.
Your wording suggests that I should do something like change(&(list($val) = $array))
which is non sensical.
Better wording may be: Argument #1 ($ref) is a value and therefore cannot be passed by reference in %s:%d
I guess the most clear would be something like
|
|
Maybe Also, light blue is a great colour. |
How would Edit: maybe |
Is it accurate though? References can be created from properties or array DIMs too. |
Duh. I'm out of ideas then.. |
This suggestion specifically adds the |
"Temporary value cannot be used as a reference" might also be an option. |
My 2 cents: |
What about |
@kocsismate That sounds better, I'd just go for "could not" as we generally seem to avoid abbreviations. |
b9b38db
to
23b831c
Compare
Currently, when a reference parameter is passed by value, the
Argument #x ($y) cannot be passed by reference
is written in the error message. This is utterly misleading, since I would assume that the argument mustn't be passed by reference. Now, this is fixed by using themust be passed by reference
wording..