|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #63915 Fatal error before spl_autoloading a trait
Submitted: 2013-01-06 01:53 UTC Modified: 2013-02-18 00:36 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: necktrox at gmail dot com Assigned:
Status: No Feedback Package: Dynamic loading
PHP Version: 5.4.10 OS: Windows 8 x64
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-01-06 01:53 UTC] necktrox at gmail dot com
From manual page:

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-06 06:18 UTC]
-Status: Open +Status: Feedback
 [2013-01-06 06:18 UTC]
I think it should not be a "autoload" issue:

function autoload($name) {


class A {
    use T;



could you please give us a simple reproduce script?
 [2013-02-18 00:36 UTC] php-bugs at lists dot php dot net
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.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jul 23 01:01:28 2024 UTC