Advertisement
Guest User

Untitled

a guest
Sep 15th, 2014
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.50 KB | None | 0 0
  1. <?php
  2.  
  3. interface Dynamic
  4. {
  5.     function __call($name, $arguments);
  6. }
  7.  
  8. class Foo
  9. {
  10.     public function sing()
  11.     {
  12.         var_dump('Do re mi!');
  13.     }
  14.  
  15.     public function dance()
  16.     {
  17.         var_dump('Cha cha cha!');
  18.     }
  19. }
  20.  
  21. class Bar implements Dynamic
  22. {
  23.     public function __call($name, $arguments)
  24.     {
  25.         // @todo; magic
  26.     }
  27. }
  28.  
  29. function gimmeFoo(Foo $foo)
  30. {
  31.     $foo->sing();
  32.     $foo->dance();
  33. }
  34.  
  35. gimmeFoo(new Bar()); // works because Dynamic dodges typechecks
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement