008.phpt 476 B

123456789101112131415161718192021222324
  1. --TEST--
  2. testing static access for methods and properties in anon classes
  3. --FILE--
  4. <?php
  5. $anonClass = new class("cats", "dogs") {
  6. public static $foo;
  7. private static $bar;
  8. public function __construct($foo, $bar) {
  9. static::$foo = $foo;
  10. static::$bar = $bar;
  11. }
  12. public static function getBar() {
  13. return static::$bar;
  14. }
  15. };
  16. var_dump($anonClass::$foo);
  17. var_dump($anonClass::getBar());
  18. ?>
  19. --EXPECT--
  20. string(4) "cats"
  21. string(4) "dogs"