You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm playing with property hook from PHP 8.4, and VarExporter component is not able to process my code.
I use a backed property, with a private(set) modifier, and a hook. This blocks the VarExporter to generate a ghost object.
I'm not sure how I could solve this, except by changing the visibility. And I fail to see why the hook change everything 🤔
How to reproduce
require__DIR__ . '/vendor/autoload.php';
useSymfony\Component\VarExporter\ProxyHelper;
functionprepare(string$foo): string
{
echo"calling prepare\n";
return'prepared ' . $foo;
}
class Foobar
{
publicfunction__construct(
public private(set) string$foo,
) {
}
publicprivate(set)string$fooPrepared {
get => $this->fooPrepared ??= prepare($this->foo);
}
// this version works// public private(set) string $fooPrepared = 'prepared foo';
}
$foobar = newFoobar('foo');
dump($foobar->fooPrepared);
dump($foobar->fooPrepared);
$code = ProxyHelper::generateLazyGhost(newReflectionClass(Foobar::class));
echo$code;
Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered:
Actually, the issue is in doctrine. I made a very simple reproducer, but I have such code in my entity.
I fail to see why it works without hook, but it does not with. More over, I have not set hook, so VarExporter could set one that throw an exception for example
Symfony version(s) affected
7.3 (maybe older too)
Description
I'm playing with property hook from PHP 8.4, and VarExporter component is not able to process my code.
I use a backed property, with a private(set) modifier, and a hook. This blocks the VarExporter to generate a ghost object.
I'm not sure how I could solve this, except by changing the visibility. And I fail to see why the hook change everything 🤔
How to reproduce
Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: