--- /dev/null
+--TEST--
+Bug #65419 (Inside trait, self::class != __CLASS__)
+--FILE--
+<?php
+trait abc
+{
+ static function def()
+ {
+ echo self::class, "\n";
+ echo __CLASS__, "\n";
+ }
+}
+
+class ghi
+{
+ use abc;
+}
+
+ghi::def();
+?>
+--EXPECTF--
+ghi
+ghi
\ No newline at end of file
if (!CG(active_class_entry)) {
zend_error(E_COMPILE_ERROR, "Cannot access self::class when no class scope is active");
}
+ if (CG(active_class_entry)->ce_flags & ZEND_ACC_TRAIT) {
+ constant_name.op_type = IS_CONST;
+ ZVAL_STRINGL(&constant_name.u.constant, "class", sizeof("class")-1, 1);
+ zend_do_fetch_constant(result, class_name, &constant_name, ZEND_RT, 1 TSRMLS_CC);
+ break;
+ }
zval_dtor(&class_name->u.constant);
class_name->op_type = IS_CONST;
ZVAL_STRINGL(&class_name->u.constant, CG(active_class_entry)->name, CG(active_class_entry)->name_length, 1);