Doc #63915 [Fbk->NoF]: Fatal error before spl_autoloading a trait

From: Date: Mon, 18 Feb 2013 00:36:11 +0000
Subject: Doc #63915 [Fbk->NoF]: Fatal error before spl_autoloading a trait
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-9554@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63915&edit=1 ID: 63915 Updated by: php-bugs@lists.php.net Reported by: necktrox at gmail dot com Summary: Fatal error before spl_autoloading a trait -Status: Feedback +Status: No Feedback Type: Documentation Problem Package: Dynamic loading Operating System: Windows 8 x64 PHP Version: 5.4.10 New Comment: No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Open". Thank you. Previous Comments: ------------------------------------------------------------------------ [2013-01-06 06:18:31] laruence@php.net I think it should not be a "autoload" issue: function autoload($name) { var_dump($name); } spl_autoload_register("autoload"); class A { use T; } //output: "T" could you please give us a simple reproduce script? ------------------------------------------------------------------------ [2013-01-06 01:53:58] necktrox at gmail dot com Description: ------------ --- From manual page: http://www.php.net/language.oop5.traits --- Traits are not handled as classes and spl_autoload won't autoload them when they are needed / when the class which uses it gets loaded. Test script: --------------- // File: /system/traits/Singleton.trait.php namespace system\traits; trait Singleton { public static function getInstance() { /* ... */ } } // File: /system/classes/MyClass.class.php namespace system\classes; class MyClass { use Singleton; } // File: /index.php use system\traits; use system\classes; // My autoload takes the namespaces and use them as folders // Autoload::registerLoader(BASE_PATH); // Autoload::registerExtension("class"); // Autoload::registerExtension("trait"); $obj = Bootstrap::getInstance(); // Fatal error: Call to undefined method system\classes\Bootstrap::getInstance() in [Filepath] on line [Line] //> When I include the Singleton-file in the MyClass-file there is no error Expected result: ---------------- // No Error Actual result: -------------- Fatal error: Call to undefined method system\classes\Bootstrap::getInstance() in C:\xampp\htdocs\~\index.php on line 13 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63915&edit=1

« previous php.doc.bugs (#9554) next »