Stanislav Malyshev wrote on 20/11/2014 18:47:
I do not think the standard should require it, as whoever using this for
anything, one way or another, is doing it very, very wrong, but that's
how it works now.
As I said before, I don't see anything "very, very wrong" about assuming
that this code will increment $b, and run function bar():
$foo = new Foo(++$b);
$foo = new Foo( bar() );
The fact that I need to know the internals of class Foo to know whether
it will is pretty weird in a language which has no other lazy evaluation.
If it was the fact the constructor had insufficient parameters that
triggered the laziness, it would be less surprising; but adding a
constructor with no parameters, and an empty body, causes the expression
to be evaluated, even though its result is still thrown away, and the
public API of class Foo is identical.
Intentional or not, I think this is undesirable behaviour, and if it can
be changed without too much difficulty, it should be.
--
Rowan Collins
[IMSoP]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php