mirror of
https://github.com/php/php-src.git
synced 2024-10-16 22:12:33 +00:00
0158804a15
# __TRAIT__ behaves like __CLASS__ more or less but is constraint to traits. # Since traits are not types, there are not many valid use cases, and trying # to use __TRAIT__ to make traits more like classes is discouraged.
27 lines
363 B
PHP
27 lines
363 B
PHP
--TEST--
|
|
__TRAIT__: Use outside of traits.
|
|
--FILE--
|
|
<?php
|
|
|
|
class MyClass {
|
|
static function test() {
|
|
return __TRAIT__;
|
|
}
|
|
}
|
|
|
|
function someFun() {
|
|
return __TRAIT__;
|
|
}
|
|
|
|
|
|
$t = __TRAIT__;
|
|
var_dump($t);
|
|
$t = MyClass::test();
|
|
var_dump($t);
|
|
$t = someFun();
|
|
var_dump($t);
|
|
?>
|
|
--EXPECT--
|
|
string(0) ""
|
|
string(0) ""
|
|
string(0) ""
|