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

From: Date: Mon, 07 Jan 2019 14:56:27 +0000
Subject: Bug #77424 [Com]: Classname length affects constructor inheritance from trait
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218831@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77424&edit=1 ID: 77424 Comment by: danack@php.net Reported by: tom at inflatablecookie dot com Summary: Classname length affects constructor inheritance from trait Status: Open Type: Bug Package: Scripting Engine problem Operating System: Mac OS Mojave PHP Version: 7.3.0 Block user comment: N Private report: N New Comment: This is quite possibly the same issue as https://bugs.php.net/bug.php?id=77291 The good news is that if it is, then it has been fixed in master. Would it be possible for you to test against the current master? Previous Comments: ------------------------------------------------------------------------ [2019-01-07 14:52:47] tom at inflatablecookie dot com 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 this bug report at https://bugs.php.net/bug.php?id=77424&edit=1

« previous php.bugs (#218831) next »