php-src/Zend/tests/traits/trait_constant_002.phpt
Stefan Marr dbc6849bca Added __TRAIT__ magic constant [TRAITS] [DOC]
# __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.
2011-07-31 17:39:30 +00:00

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) ""