Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84350 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89787 invoked from network); 5 Mar 2015 19:40:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Mar 2015 19:40:43 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.175 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.223.175 mail-ie0-f175.google.com Received: from [209.85.223.175] ([209.85.223.175:44160] helo=mail-ie0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5C/98-40418-A31B8F45 for ; Thu, 05 Mar 2015 14:40:42 -0500 Received: by iecar1 with SMTP id ar1so79519053iec.11 for ; Thu, 05 Mar 2015 11:40:39 -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:content-type; bh=DUMqGqpNdLjdEOH5qKdKAxpm/3fLmReTwUv0FaUNKAU=; b=07AuEfj7B8pRqADlG2eOlKXosLpsEyzftDNnqigm7i4qJdSe95l2sFupcCbhqtHuTS 7EQxvxIEtS+xmOOWyl0iu0QRNcJL16Snb31lmSWPa+un5aQJY440gk/9GcIRUdX/u2Y7 oajd5EihHAPIL7uLmssf9QCuW4s509DlHKy9HwS4R3jUD/kgnpCW+iZ5fGoG4CG7HOLk nQOJUOlQQG41dfajFX10xKFk2wDtRgeOLcKiYanNfvFoPS2G3jzOqo/AU3Q/jCNcqnuE 1/Ikdmid9OWBNH+VddIl/V7Ytw4MNSz8hMvD+w+6QSuM+skZKNQ8NBVGBpA4mwOEpcNF pATQ== MIME-Version: 1.0 X-Received: by 10.42.76.205 with SMTP id f13mr5874902ick.42.1425584439835; Thu, 05 Mar 2015 11:40:39 -0800 (PST) Received: by 10.36.62.133 with HTTP; Thu, 5 Mar 2015 11:40:39 -0800 (PST) Date: Thu, 5 Mar 2015 14:40:39 -0500 Message-ID: To: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Use behavior thoughts From: ircmaxell@gmail.com (Anthony Ferrara) All, Currently, use has a few error cases that are rather fragile. For example: namespace Biz { class Bar {}; } namespace Foo { use Biz\Bar; $a = new Bar; var_dump($a); } namespace Foo { class Bar {}; } http://3v4l.org/IPTiQ That works 100% of the time, on 5.3.0 -> present. But if we change the order of the two Foo blocks: namespace Biz { class Bar {}; } namespace Foo { class Bar {}; } namespace Foo { use Biz\Bar; $a = new Bar; var_dump($a); } http://3v4l.org/KlXUq We get a Fatal error that "Cannot use Biz\Bar as Bar because the name is already in use. Basically, zend_compile.c is doing a check of the current symbol table to see if the class is already defined when doing the use. This is problematic not just for the example above, but when combined with opcache. Opcache nulls out the symbol tables for file compilation. So that means that file inclusion order matters when it's disabled, but not when it's enabled. This was discovered last night by Drupal 8 developers, when they noticed that some developers claimed fatal errors, while they weren't able to reproduce. After some debugging, it turned out that disabling opcache caused the fatal errors. It was because of this symbol table change. The error is fragile. And IMHO it's not really protecting anything significant, since it's clear within the file what each symbol refers to (you need to look at use declarations for that anyway). So, I created a PR to remove this error: https://github.com/php/php-src/pull/1149 Note that there is no BC break here, as it's removing an error condition today. This results in a weird edge case (which is 100% valid, but feels odd):