On Sun, 10 Mar 2019 at 18:35, Rowan Collins <rowan.coll...@gmail.com> wrote:
>
> Hi all,
>
> - Attempting to set a property on the instance which was not declared in
> the class (or inherited from one of its parent classes) will throw an
> error, and the instance will not be modified.
> - Attempting to read a property on the instance which was not declared
> (or inherited) will throw an error, rather than raising a Notice and
> evaluating to null.

I believe those two parts of the RFC are completely possible already in
user-land with a trait similar to the one below. What would be the
compelling case for making it be a keyword, rather than the user-land
implementation that is already achievable?

Also.....this seems to be a special case of an idea that has come up
repeatedly, of allowing the concept of 'packages' with rules applied to all
of the classes in a package e.g.

* class Friendship which only allows access to certain methods to other
classes in the same package.
* strict enabled by default for a classes in a package.

and now this RFC (or at least 2/3 of it) could be implemented by adding
some traits by default to all classes in a package.

Rather than adding a special case, I'd much rather we looked at providing
the general case.

cheers
Dan
Ack



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");
}
}

Reply via email to