add bitset operations and tests
[hiphop-php.git] / hphp / test / slow / class_type_constant / reflect_type_constant2.php
blob759e2a1f042a721776ba511988ec5ed88bc31050
1 <?hh
3 interface I {
4 const type TypeI = C::T;
5 abstract const type TypeAbsI;
8 abstract class C implements I {
9 const type T = int;
10 abstract const type X as int;
11 const TYPE = 0;
14 $rc = new ReflectionClass(C::class);
16 echo "=== ReflectionClass::getTypeConstant('T') ===" . PHP_EOL;
17 var_dump((string)$rc->getTypeConstant('T'));
19 echo "=== ReflectionClass::getTypeConstant('X') ===" . PHP_EOL;
20 var_dump((string)$rc->getTypeConstant('X'));
22 echo "=== ReflectionClass::hasTypeConstant('TypeAbsI') ===" . PHP_EOL;
23 var_dump($rc->hasTypeConstant('TypeAbsI'));
25 echo "=== ReflectionClass::hasTypeConstant('TYPE') ===" . PHP_EOL;
26 var_dump($rc->hasTypeConstant('TYPE'));
28 echo PHP_EOL;
30 // Test non-interned string
31 $tc = new ReflectionTypeConstant(C::class, trim(' TypeI '));
32 echo '=== <C::TypeI>::getDeclaringClass() ===' . PHP_EOL;
33 var_dump($tc->getDeclaringClass()->getName());
35 echo '=== <C::TypeI>::getName() ===' . PHP_EOL;
36 var_dump($tc->getName());
38 echo '=== <C::TypeI>::getAssignedTypeText() ===' . PHP_EOL;
39 var_dump($tc->getAssignedTypeText());
41 echo '=== <C::TypeI>::isAbstract() ===' . PHP_EOL;
42 var_dump($tc->isAbstract());
44 echo PHP_EOL;
45 $tc = new ReflectionTypeConstant(C::class, 'X');
46 echo '=== <C::X>::getDeclaringClass() ===' . PHP_EOL;
47 var_dump($tc->getDeclaringClass()->getName());
49 echo '=== <C::X>::getName() ===' . PHP_EOL;
50 var_dump($tc->getName());
52 echo '=== <C::X>::getAssignedTypeText() ===' . PHP_EOL;
53 var_dump($tc->getAssignedTypeText());
55 echo '=== <C::X>::isAbstract() ===' . PHP_EOL;
56 var_dump($tc->isAbstract());
58 echo PHP_EOL;
59 echo '=== ReflectionTypeConstant(C, x) ===' . PHP_EOL;
60 // Type Constants are case sensitive
61 try {
62 new ReflectionTypeConstant(C::class, 'x');
63 } catch (ReflectionException $e) {
64 var_dump($e->getMessage());