Bug #77424 [NEW]: Classname length affects constructor inheritance from trait

From: Date: Mon, 07 Jan 2019 14:52:47 +0000
Subject: Bug #77424 [NEW]: Classname length affects constructor inheritance from trait
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218830@lists.php.net to get a copy of this message
From: tom at inflatablecookie dot com Operating system: Mac OS Mojave PHP version: 7.3.0 Package: Scripting Engine problem Bug Type: Bug Bug description:Classname length affects constructor inheritance from trait Description: ------------ This is a -very- odd one.. Inheriting a __construct method from a trait in an implementing class does not work correctly if the fully qualified name of the class is of a certain combination of namespace and classname length - apparently 11 characters total. When applied, if the class is inspected via Reflection, the __construct method appears in the method list, however it is not considered a constructor by isConstructor(), and is not called on object instantiation. Disabling OpCache does not appear to have any effect on the issue. I'm running the stock homebrew packaged version of PHP 7.3.0 on Mac OS Mojave - a few PECL extensions have been added to the installation, though disabling all of them makes no difference to the issue. Test script: --------------- <?php namespace ab\abc { class Abc { use test; } class Abcd { use test; } trait test { public function __construct() { echo '__construct '.get_class($this)."\n"; } } new Abc(); new Abcd(); } Expected result: ---------------- Console output should be: > __construct ab\abc\Abc > __construct ab\abc\Abcd Actual result: -------------- > __construct ab\abc\Abc Only the first line is echoed, the constructor for Abcd is never called (order of instantiation of the two classes is irrelevant). Changing the namespace to "abc\abcd" for example however fixes the issue and both lines are echoed. The name of the trait does not appear to have any effect. The characters used in namespace or classname do not matter, only the combined length. -- Edit bug report at https://bugs.php.net/bug.php?id=77424&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77424&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77424&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77424&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77424&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77424&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77424&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77424&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77424&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77424&r=support Expected behavior: https://bugs.php.net/fix.php?id=77424&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77424&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77424&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77424&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77424&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77424&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77424&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77424&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77424&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77424&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77424&r=mysqlcfg

« previous php.bugs (#218830) next »