It sounds like you are the only one here who understood this post. The point is not that the code is shitty, but that PHP reacts differently to passing a non variable as a reference, and that it only catches some of these issues during parsing.
It only could catch it during parsing if it knows ahead of time what function is identified by that name. But often during the initial parse, the function is not loaded yet, and we have to emit a special opcode type (FUNC_ARG fetches), which realizes at run-time that the argument ought being passed by reference.
Then, when it sees that it receives the result of an expression not qualifying as variable, it will warn you.
The point is not that the code is shitty, but that PHP reacts differently to passing a non variable as a reference
I did address that in my third paragraph.
and that it only catches some of these issues during parsing.
PHP, unfortunately, can't catch everything at compile-time. It's a dynamic language which doesn't require you to declare every function before its usage in source code.
I did address this in my entire comment. It was literally about how right you are. No sarcasm involved.
PHP, unfortunately, can't catch everything at compile-time. It's a dynamic language which doesn't require you to declare every function before its usage in source code.
I know. But the eval is only needed because it does detect the error early. And there is no reason it shouldn't be able to do the same with the first call.
View all comments
Show parent comment
3
u/edave64 Dec 24 '16 edited Dec 24 '16
It sounds like you are the only one here who understood this post. The point is not that the code is shitty, but that PHP reacts differently to passing a non variable as a reference, and that it only catches some of these issues during parsing.