On 10/03/2019 20:19, Dan Ackroyd wrote:
trait LockedClass
{
public function __set($name, $value)
{
throw new \Exception("Property [$name] doesn't exist for class [" . get_class($this) . "] so can't set it");
}
public function __get($name)
{
throw new \Exception("Property [$name] doesn't exist for class [" . get_class($this) . "] so can't get it");
}
}


Incidentally, this isn't quite equivalent to the current RFC, because it will also intercept access to private or protected properties from out of scope. It doesn't make much difference other than making the error messages less helpful, but it's an example of how a nice userland implementation isn't quite as trivial as it first looks.

Regards,

--
Rowan Collins
[IMSoP]


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to