Bug #65419 [Com]: Inside trait, self::class != __CLASS__

From: Date: Tue, 18 Feb 2014 08:34:13 +0000
Subject: Bug #65419 [Com]: Inside trait, self::class != __CLASS__
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184343@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=65419&edit=1 ID: 65419 Comment by: nicolas dot grekas+php at gmail dot com Reported by: nicolas dot grekas+php at gmail dot com Summary: Inside trait, self::class != __CLASS__ Status: Verified Type: Bug Package: Scripting Engine problem PHP Version: 5.5.1 Assigned To: ralphschindler Block user comment: N Private report: N New Comment: It would be nice if this could be resolved for 5.6. I fear people could start relying on this buggy behavior... Previous Comments: ------------------------------------------------------------------------ [2013-09-12 16:52:28] ralphschindler@php.net Ill work up a patch that will demonstrate ::class resolving in traits similar to how __CLASS__ works in traits. This seems to be the consensus (correct me if I am wrong), and consistent with __CLASS__ (to some degree) in traits. ------------------------------------------------------------------------ [2013-08-14 10:10:48] nicolas dot grekas+php at gmail dot com Why remove ::class support inside traits? It mostly works today, and it is as usefull there than inside classes or anywhere else, am I wrong? Would it be possible to replace self::class occurences by __CLASS__ at compile time so that the code path for __CLASS__ is also used here? ------------------------------------------------------------------------ [2013-08-11 15:31:06] laruence@php.net I prefer to trigger a COMPILE ERROR prevent from using ::class in a traits ------------------------------------------------------------------------ [2013-08-09 07:57:41] gron@php.net Yes, that looks wrong. It should indeed behave as __CLASS__. ------------------------------------------------------------------------ [2013-08-09 07:55:23] nicolas dot grekas+php at gmail dot com I totally agree with you. This reminds me the discussion that happened in https://bugs.php.net/55214 and that led to this special handling for __CLASS__. I think that the very same arguments apply here also. Concerning parent and static, they are free from this problem because they are resolved at run-time (tested, it works). ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=65419 -- Edit this bug report at https://bugs.php.net/bug.php?id=65419&edit=1

« previous php.bugs (#184343) next »