> Ah, I see now what you meant, Robert. This already doesn't hold.
>
> class Foo {
> public int $prop;
> }
> $foo = new Foo();
> $value = '42';
> $foo->prop = $value;
> var_dump($value === $foo->prop);
> // false
I don’t know if this has been closed or discussed further in private but this
has just came to me:
This could be solved with some kind of an operator overloading for the
property, but then it would just raise more questions to answer / problems to
solve. But the problem mentioned above can well happen even if one would use
the same types.
class Baz {
public function clone(): self {
// create new instance into which I copy all my properties.
}
}
class Foo {
public Baz $val {
beforeSet(Baz $new) => $new->clone();
}
}
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php