php-src/Zend/tests/traits/trait_constant_001.phpt
Stefan Marr 0158804a15 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

37 lines
515 B
PHP

--TEST--
__TRAIT__: Basics, a constant denoiting the trait of definition.
--FILE--
<?php
trait TestTrait {
public static function test() {
return __TRAIT__;
}
}
class Direct {
use TestTrait;
}
class IndirectInheritance extends Direct {
}
trait TestTraitIndirect {
use TestTrait;
}
class Indirect {
use TestTraitIndirect;
}
echo Direct::test()."\n";
echo IndirectInheritance::test()."\n";
echo Indirect::test()."\n";
?>
--EXPECT--
TestTrait
TestTrait
TestTrait