Advertisement
nikola_petkanski

direct static method invokation within an abstract class

Feb 11th, 2014
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.46 KB | None | 0 0
  1. <?php
  2.  
  3. abstract class A
  4. {
  5.     protected static $something;
  6.  
  7.     abstract static function init();
  8.  
  9.     static function doSomeWork() {
  10.         echo static::$something;
  11.     }
  12. }
  13.  
  14. class B extends A
  15. {
  16.     static function init() {
  17.         static::$something = 'something else';
  18.     }
  19. }
  20.  
  21. // hiding implementation detail; may be DIC or something else
  22. class_alias('A', 'OurImplementation');
  23.  
  24. OurImplementation::init();
  25. OurImplementation::doSomeWork();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement