Closed as not planned
Closed as not planned
Description
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
require __DIR__ . '/vendor/autoload.php';
use Symfony\Component\VarExporter\ProxyHelper;
function prepare(string $foo): string
{
echo "calling prepare\n";
return 'prepared ' . $foo;
}
class Foobar
{
public function __construct(
public private(set) string $foo,
) {
}
public private(set) string $fooPrepared {
get => $this->fooPrepared ??= prepare($this->foo);
}
// this version works
// public private(set) string $fooPrepared = 'prepared foo';
}
$foobar = new Foobar('foo');
dump($foobar->fooPrepared);
dump($foobar->fooPrepared);
$code = ProxyHelper::generateLazyGhost(new ReflectionClass(Foobar::class));
echo $code;
Possible Solution
No response
Additional Context
No response