Re: RFC: Locked Classes

From: Date: Sun, 10 Mar 2019 21:09:09 +0000
Subject: Re: RFC: Locked Classes
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-104636@lists.php.net to get a copy of this message
Still feasible though: PRs to https://github.com/Roave/Dont/tree/master/src/Dont welcome On Sun, 10 Mar 2019, 21:56 Rowan Collins, <rowan.collins@gmail.com> wrote: > 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 > >

« previous php.internals (#104636) next »