/hphp/test/slow/traits/traits_and_interfaces7.php
PHP | 41 lines | 32 code | 9 blank | 0 comment | 0 complexity | 007c815b49c2327b52abf93ec9aa6a08 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
- <?hh
- interface I {
- const XYZ = 'const from I';
- }
- interface J extends I {
- const ABC = 'const from J';
- }
- trait MyTrait implements J {}
- class C {
- use MyTrait;
- function f() {
- echo self::ABC, "\n";
- echo self::XYZ, "\n";
- }
- }
- function main() {
- $c = new C();
- $c->f();
- }
- function reflect() {
- echo '==========', ' ', __FUNCTION__, ' ', '==========', "\n";
- $rc = new ReflectionClass("C");
- print_r($rc->getInterfaceNames());
- print_r($rc->getConstants());
- print_r(get_class_constants((string)$rc));
- }
- <<__EntryPoint>>
- function main_traits_and_interfaces7() {
- error_reporting(-1);
- main();
- reflect();
- }