Re: __invokeStatic() method

From: Date: Tue, 19 Mar 2013 07:26:04 +0000
Subject: Re: __invokeStatic() method
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-66693@lists.php.net to get a copy of this message
Hi, Le Mon, 18 Mar 2013 09:07:43 +0200, Matīss Roberts Treinis a écrit : > Not only that. This potentially might break compatibility with many > software products already out there. I don't see how it could break existing software as it is not a modification of an existing method but a brand new one. > Also, this might lead to many > misunderstandings and, in fact, ambiguous code. Consider the sample. > > $name = 'something'; > $something = $name(); // What is this - a function call or object? > > Fact is, we can not know that unless a) do a search in code b) var_dump? As long as you use syntax like $foo = new $bar() or $foo = $bar(), you'll always wonder if the function/class behind $bar exist or not, etc... And it is easy to remove any ambiguity by using $something = $functionName () or $something = $className() or add proper comments. It's only up to the dev. I find that __invokeStatic() could be a quite cool syntactic sugar. My 2 cents. Bruno

« previous php.internals (#66693) next »