Doc #63915 [NEW]: Fatal error before spl_autoloading a trait
| From: | necktrox at gmail dot com | Date: | Sun, 06 Jan 2013 01:53:59 +0000 |
| Subject: | Doc #63915 [NEW]: Fatal error before spl_autoloading a trait | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-9355@lists.php.net to get a copy of this message | ||
From: necktrox at gmail dot com
Operating system: Windows 8 x64
PHP version: 5.4.10
Package: Dynamic loading
Bug Type: Documentation Problem
Bug description:Fatal error before spl_autoloading a trait
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 bug report at https://bugs.php.net/bug.php?id=63915&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63915&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63915&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63915&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=63915&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=63915&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=63915&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=63915&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=63915&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=63915&r=support
Expected behavior: https://bugs.php.net/fix.php?id=63915&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=63915&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=63915&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=63915&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63915&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=63915&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=63915&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=63915&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63915&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=63915&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=63915&r=mysqlcfg