|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patches__CLASS__-in-traits.002.patch (last revision 2011-07-24 18:28 UTC by gron@php.net)__CLASS__-in-traits.patch (last revision 2011-07-23 17:45 UTC by gron@php.net) Pull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-07-15 06:32 UTC] felipe@php.net
-Package: *General Issues
+Package: Documentation problem
[2011-07-15 06:32 UTC] felipe@php.net
[2011-07-15 06:44 UTC] chris dot rutledge at gmail dot com
[2011-07-22 04:56 UTC] gron@php.net
[2011-07-23 08:17 UTC] gron@php.net
-Status: Open
+Status: Assigned
-Package: Documentation problem
+Package: Scripting Engine problem
-Assigned To:
+Assigned To: gron
[2011-07-23 14:17 UTC] felipe@php.net
[2011-07-23 17:45 UTC] gron@php.net
[2011-07-23 17:53 UTC] gron@php.net
[2011-07-24 18:28 UTC] gron@php.net
[2011-07-24 18:31 UTC] gron@php.net
[2011-07-31 18:18 UTC] gron@php.net
[2011-07-31 18:23 UTC] gron@php.net
-Status: Assigned
+Status: To be documented
-Assigned To: gron
+Assigned To:
[2011-07-31 18:23 UTC] gron@php.net
[2011-08-15 08:29 UTC] gron@php.net
[2011-10-16 18:46 UTC] gron@php.net
-Status: Open
+Status: To be documented
[2011-10-16 18:46 UTC] gron@php.net
[2011-10-17 22:12 UTC] gron@php.net
-Status: To be documented
+Status: Closed
-Assigned To:
+Assigned To: gron
[2012-04-18 09:49 UTC] laruence@php.net
[2012-07-24 23:40 UTC] rasmus@php.net
[2013-11-17 09:37 UTC] laruence@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 23 22:00:01 2025 UTC |
Description: ------------ use of __CLASS__ within trait returns trait name not class name. Test script: --------------- trait Singleton { private static $instance; public static function Load() { if(!isset(self::$instance)) { $c = __CLASS__; self::$instance = new $c; } return self::$instance; } } class Test { use Singleton; private function __construct() { } } Test::Load(); Expected result: ---------------- Expected __CLASS__ to return the name of the class that required the trait ('Test'), so that the singleton object could be instantiated Actual result: -------------- __CLASS__ returned 'Singleton', this caused a Fatel error: Fatal error: Cannot instantiate trait Singleton in /home/dshed/public/northie/index.php on line 7