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

From: Date: Sun, 06 Jan 2013 06:18:31 +0000
Subject: Doc #63915 [Opn->Fbk]: Fatal error before spl_autoloading a trait
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-9356@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: laruence@php.net Reported by: necktrox at gmail dot com Summary: Fatal error before spl_autoloading a trait -Status: Open +Status: Feedback Type: Documentation Problem Package: Dynamic loading Operating System: Windows 8 x64 PHP Version: 5.4.10 Block user comment: N Private report: N New Comment: 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? Previous Comments: ------------------------------------------------------------------------ [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 (#9356) next »