Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91642 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71824 invoked from network); 12 Mar 2016 16:01:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Mar 2016 16:01:45 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.175 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.161.175 mail-yw0-f175.google.com Received: from [209.85.161.175] ([209.85.161.175:33875] helo=mail-yw0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0C/46-14237-86D34E65 for ; Sat, 12 Mar 2016 11:01:44 -0500 Received: by mail-yw0-f175.google.com with SMTP id h129so123414148ywb.1 for ; Sat, 12 Mar 2016 08:01:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to; bh=xjZQePEntiEkLHwqx9T0+gF3FeA+nmJporDHKDgSFSw=; b=0ji4JmKRm+LtEKaQRohB9HcTdNH6fbMa7zmbxdyGlLqwFxTI8I20iom+OdMSH6YtXL /vfBqnwwYqDtnb0y/cwDY4F4mHVlNre4ZGMV1Mmm8pZ24cie54iRvbJq22ijLG32jI+q VwKJ3AZoRBzj7RmYPbBYes/IylYIiOXNlB24Z8vkdrvZrZT9klWXw2xX0lE3LrgzRlj9 JcTo4M7/8MT7i555ezmLakeYrW/N8Ta/GQHlVQ6yJYHmt0tu/SN5gD2+uf7/pd4tt/1w zS1X6UYT2Hz4+cts91OCdIazeU5az7cWzadxRR4wQ62O1jGcj5RXDAtg/+uHMYwlhJTF c03w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=xjZQePEntiEkLHwqx9T0+gF3FeA+nmJporDHKDgSFSw=; b=VdLmluSy3kRsB9JuEoXRFBqIPeeQ5CrE/XW3aQo6kGRhSSwze742bnbCkv3Q6KPVo/ smJYJmyK+P17tE2Q4L0KVS2LdiaSkKujNbhpQ4axShg1IUpTnMNMOq9D569FD46YuYpH +EPHBQvOcEIrtXVhNBhFcr0r+VFFX0bMYHMSBaTEBfkmpcyr7kzo3oRsh41ESbuR2Nu+ M1fxSbJPx2LSljAHL14hhur0pPhIGzijKmYuz499Y6mAv+WbGQjK5CvwpDynLJ1QBSt1 ihS6YKoMU7oLoiHFqo94DFSBvRbdQG2Egk/4UBqKiSceFwX43qJtuSzQH8vOXwet+ZOf w43A== X-Gm-Message-State: AD7BkJLzxe+d3HBQ9p+RY7fxa58jM2evCxa8D3b1DNksAVfQAU77xrkKNU8MbaW3peJUEPiagxeULMJpHZm2Gg== MIME-Version: 1.0 X-Received: by 10.129.44.212 with SMTP id s203mr8890555yws.280.1457798501614; Sat, 12 Mar 2016 08:01:41 -0800 (PST) Received: by 10.129.148.70 with HTTP; Sat, 12 Mar 2016 08:01:41 -0800 (PST) Date: Sat, 12 Mar 2016 17:01:41 +0100 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary=001a1141fa82d7cd3f052ddc2905 Subject: Evaluate arguments of new for classes without constructors From: nikita.ppv@gmail.com (Nikita Popov) --001a1141fa82d7cd3f052ddc2905 Content-Type: text/plain; charset=UTF-8 Hi internals, Currently 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 class Foo { function __construct() {} } new Foo(print 'xyz'); *will* print "xyz". This behavior is confusing, especially if the code is new $class(...) where $class may or may not have a constructor and thus the side effects of "..." may or may not occur, leading to a hard to identify failure mode. I do not believe this behavior is intentional, it is simply an artifact of the precise way in which "new" was implemented. HHVM does not implement "new" in this way, they always evaluate the arguments. We regularly get bug reports about this behavior. A sample of recent ones I was able to track down: #54162, #54170, #65930, #67829 and #70698. I'd like to fix this behavior, so that new arguments are always evaluated. Here's a patch: https://github.com/php/php-src/pull/1802 As this is technically a BC affecting change (even if of the lowest impact), I'm running it past the list first. Thanks, Nikita --001a1141fa82d7cd3f052ddc2905--