Advertisement
Guest User

PHP: scope resolution not working for static anon functions

a guest
Feb 7th, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. class Father {
  2.   static function hi() {
  3.     echo "Father" . PHP_EOL;
  4.   }
  5. }
  6.  
  7. class Guy extends Father {
  8.  
  9.   static function hi() {
  10.     echo "Guy" . PHP_EOL;
  11.   }
  12.  
  13.   static function test() {
  14.     echo self::class;
  15.     self::hi();
  16.     echo static::class;
  17.     static::hi();
  18.     echo parent::class;
  19.     parent::hi();
  20.     $anon = function() {
  21.       self::hi();
  22.       echo self::class;
  23.       echo static::class;
  24.       static::hi();
  25.       echo parent::class;
  26.       parent::hi();
  27.     };
  28.     $anon();
  29.   }
  30.  
  31. }
  32.  
  33. class Child extends Guy {
  34.   static function hi() {
  35.     echo "Child" . PHP_EOL;
  36.   }
  37. }
  38.  
  39. Child::test();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement