global statement removal: hphp/test [7/x]
[hiphop-php.git] / hphp / test / quick / class_abstract_final1.php
blob3a3f9b948c75273b9fd9bad72c5ecc1fd0eb5573
1 <?hh
3 class C {
4 public $nonStaticInheritedProp;
6 public function nonStaticInheritedMethod() {
7 echo __METHOD__, ' of ', static::class, "\n";
8 echo 'this: ', isset($this) ? 'defined' : 'undefined', "\n";
12 trait Tr {
13 require extends C;
15 public $nonStaticTraitProp;
17 public function nonStaticTraitMethod() {
18 echo __METHOD__, ' of ', static::class, "\n";
19 echo 'this: ', isset($this) ? 'defined' : 'undefined', "\n";
21 public static function staticTraitMethod() {
23 echo __METHOD__, "\n";
26 abstract public function nonStaticAbstract();
29 abstract final class Utils extends C {
30 use Tr;
32 public static function staticMethod() {
33 echo __METHOD__, "\n";
34 static::protStaticMethod();
37 private static function privStaticMethod() {
38 echo __METHOD__, ' ', self::$prop, "\n";
41 protected static function protStaticMethod() {
42 echo __METHOD__, "\n";
43 self::privStaticMethod();
46 private static $prop = __CLASS__.'::prop';
49 function main() {
50 Utils::staticMethod();
51 Utils::staticTraitMethod();
52 Utils::nonStaticInheritedMethod(); // works because $this isn't accessed
53 Utils::nonStaticTraitMethod(); // works because $this isn't accessed
55 $rc = new ReflectionClass(Utils::class);
56 echo 'ReflectionClass::isAbstract', ' => ';
57 var_dump($rc->isAbstract());
58 echo 'ReflectionClass::isFinal', ' => ';
59 var_dump($rc->isFinal());
60 echo 'ReflectionClass::isInstantiable', ' => ';
61 var_dump($rc->isInstantiable());
64 main();
65 echo 'Done', "\n";