Re: [RFC] !instanceof operator - reaction measuremen

From: Date: Mon, 13 Dec 2021 11:19:04 +0000
Subject: Re: [RFC] !instanceof operator - reaction measuremen
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-116637@lists.php.net to get a copy of this message
pon., 13 gru 2021 o 12:10 Lynn <kjarli@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

« previous php.internals (#116637) next »