pon., 13 gru 2021 o 12:10 Lynn <kja...@gmail.com> napisał(a):

> Heya,
>
> While I definitely agree with this, and after more than 10 years of PHP I
> still have the tendency to write `if ($object !instanceof MyClass)` anyway.
> Would it be possible, or would it collide with constants to do the
> following?
> ```
> $object === MyClass;
> $object !== MyClass;
> ```
> The reason I'm hoping this would be possible, is that I often have brainlag
> trying to write "instanceof" and I either make several typos, or I end up
> with "instance" and it takes me an error message to realize I forgot the
> "of". The "instanceof" is counterintuitive for me compared to operators.
>
> If this isn't possible and `!instanceof` would be adopted, what about the
> following in addition to the proposed example?
> ```
> $object implements MyInterface;
> $object !implements MyInterface;
> $object extends MyClass;
> $object !extends MyClass;
> ```
>

Why not "not" instead? The "!" in front of "i" in "!implements" is almost
not visible which IMO could get easily ignored unintentionally.
Instead constructs like "$foo not implements stdClass" have higher
visibility and are currently a syntax error.

Cheers,
Michał Marcin Brzuchalski

Reply via email to