-
-
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
Proxies for __set/__unset need special handling if the parent implementation return type is explicitly declared as void #778
Comments
Yes, this depends on the parent implementation regardless. The PHP documentation is really mostly irrelevant: tests and php-src code are authoritative. |
I suggest reproducing this on a test in the ProxyManager test suite: AFAIK, |
@Ocramius Not sure why this issue was closed as it is still present/not fixed. I've just run into the same issue as the author of this issue during the generation of a proxy of the There's no check at all whether the parent has a |
Using LazyGhostTrait together with this lib is likely going to explode. You need to figure out why you end up using both on the same class and keep only one of them. |
@nicolas-grekas We are not using both on the same class. Only proxy manager is being used on that class. |
I'd be happy to have a look at a reproducer if you can provide one please, to confirm whether there's something to fix in this repo or another. |
@nicolas-grekas 👍 I'll try to create a reproducer soon. |
@nicolas-grekas Here's a reproducer https://github.com/X-Coder264/proxy-reproducer-bug It blows up when the repository service is fetched from the container. In our case that happens during the |
Thanks, makes sense now. The issue is indeed in this repo, which generates this code: public function __set($name, $value) : void
{
$this->initializer480f6 && ($this->initializer480f6->__invoke($valueHolderd4bf6, $this, '__set', array('name' => $name, 'value' => $value), $this->initializer480f6) || 1) && $this->valueHolderd4bf6 = $valueHolderd4bf6;
return $this->valueHolderd4bf6->__set($name, $value);
} The The work around is to not make your repository lazy. It should not be needed anyway. |
The PHP documentation says that
__set
and__unset
should returnvoid
, that their return values are ignored, and suggests these signatures:But if I actually declare the return types in my
__set
and__unset
, the generated proxy methods still try toreturn
the result of the proxied call. This results in aCompile Error: A void function must not return a value
:The text was updated successfully, but these errors were encountered: