|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-01-07 04:52 UTC] spam2 at rhsoft dot net
[2018-01-07 10:43 UTC] sybrew at gmail dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 16:00:01 2025 UTC |
Description: ------------ When a class is called from the same file it's written, you should be able to call them in any order. However, when a class uses a trait, the order is strict. Test script: --------------- <?php new A; // good. new B; // fatal error. class A { function __construct() { echo 'constructed A', "<br>\n"; } } class B { use T; function __construct() { echo 'constructed B', "<br>\n"; $this->traitfunc(); } } new B; // good. trait T { function traitfunc() { echo 'traitfunc called', "<br>\n"; } } Expected result: ---------------- constructed A constructed B traitfunc called Actual result: -------------- constructed A FATAL ERROR Class 'B' not found on line number 4