Re: Evaluate arguments of new for classes without constructors

From: Date: Sat, 12 Mar 2016 17:27:45 +0000
Subject: Re: Evaluate arguments of new for classes without constructors
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-91643@lists.php.net to get a copy of this message
On Sat, Mar 12, 2016 at 8:01 AM, Nikita Popov <nikita.ppv@gmail.com> wrote: > class Foo {} > new Foo(print 'xyz'); > > will not print "xyz", because the arguments to "new" are not evaluated if > the class has no constructor. Conversely > I recall someone once dubbing this "The Rasmus Optimization". I don't know if that means it was intentional, or just a lazy jibe, but yeah. It's a long known issue, so it's probably good that you posted about it first, as someone may have a legit reason for not wanting to fix it. (I don't, I regard this as a php sadness) > HHVM does not implement "new" in this way, they always evaluate the arguments. > Which, if it helps, means that we already know a lot of frameworks /don't/ break as a result of fixing this behavior. > As this is technically a BC affecting change (even if of the lowest > impact), I'm running it past the list first. > Technically a BC break that justifies waiting till a major version. Given the extremely specific requirements to hit this edge case however, passing side-effect args to a non-existent constructor, I personally think a minor version is fine. +1 (without having looked at the patch) -Sara

« previous php.internals (#91643) next »