-
-
Notifications
You must be signed in to change notification settings - Fork 188
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
Better support for internal PHP classes default parameters #162
Comments
Ping @mnapoli you were interested in this. |
Thanks. What is the value of |
In Java you would use something like |
OK if it's a specific object instance then that's fine, I was afraid it was going to be something like |
(using |
@mnapoli +1, I also thought about $value = ...
if ($value !== $value) { // happy debug
echo "It's crazy NaN value";
} |
Risky :p |
how about a float with a lot of number behind the comma, so it gets very unlikely it can match any existing real world numbers..? |
It will just be a string ;-) |
Deferred to 2.0.0: too much of an edge case, and |
Removed from 2.0.0 milestone: while this can be implemented, I'd rather have something like https://github.com/Roave/BetterReflection deal with this sort of problem instead. |
Sorry, but unless you have practical advice on how to resolve the issue, this is not constructive feedback. Patches welcome, but I can't do much about internal symbols reflection being incomplete, because that's just how the engine behaves for types not defined in userland. |
For your specific Redis issues, check the related issues here:
Specifically, from that last issue:
|
Trying to be constructive through a proposal: what about loading class definitions for these edge-cases from a stub file? Could it be viable? |
Please re-read your comment, then, and perhaps ask someone to analyze it for you, so you can understand why it is not an acceptable human interaction:
|
@alekitto yes, see:
Beware that any mis-alignment between stubs and actual runtime symbols can still lead to problems. Using something like |
I think the best approach would be to use a combination of time, current directory/filename, and a pseudo random id. $placeholder = uniqid(true, '__proxy_manager') . time() . hash('md5', __FILE__);
|
There's only one sensible way fix to the issue with As far as this issue is concerned, what about closing it @Ocramius, for the reason I just gave? The PHP engine is getting stricter and stricter regarding type declarations, it's not like extension authors have any excuses. |
It seems that issue has already been resolved. Proper reflection should be available as of 5.3.5RC1 in combination with PHP 8. |
Depends on whether this can still occur in the engine at all 🤔 |
I think yes, having reflection out of sync from actual declaration is still possible, but it's now way easier to have them in sync AFAIK. |
Yes, it still can happen. In some cases, a default cannot be specified (in this case because the parameter has no default; in other cases because the function may be overloaded like |
Yeah, problem is potentially still with |
Idea (likely a bad one): use a variadic argument in place of this UNKNOWN default? |
actually that's a pretty good one, using
for
could work, people get auto-completion based on the original class, so the signature of the proxy doesn't matter. |
Overall potentially feasible, need to build some trickery for point-cut proxies, where the parameters are passed to interceptor callables (and keys may be missing), but it is likely feasible 🤔 |
Another idea: set |
As @guilhermeblanco suggested, we can fully support internal PHP classes methods' default parameter values by using a trick like following.
Assuming this is an internal php class, and that we cannot discover the default value for
$foo
via reflection:This code should become like following in the proxy:
That will allow us to fully support default values in proxies for internal PHP classes.
Please note that this does not apply to class-hinted parameters, as the default value for a class-hinted parameter can only be
null
The text was updated successfully, but these errors were encountered: