Advertisement
Guest User

Untitled

a guest
Sep 17th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. <?php
  2.  
  3. interface AnInterface
  4. {
  5. public function method();
  6. }
  7.  
  8. class AClass implements AnInterface
  9. {
  10. public function method()
  11. {
  12. echo __METHOD__;
  13. }
  14. }
  15.  
  16. abstract class AnAbstractClass
  17. {
  18. abstract public function method( AnInterface $Object );
  19. }
  20.  
  21. class ConcreteClass extends AnAbstractClass
  22. {
  23. public function method( AClass $Object )
  24. {
  25. $Object->method();
  26. }
  27. }
  28.  
  29. $Object1 = new ConcreteClass();
  30. $Object2 = new AClass();
  31.  
  32. $Object1->method( $Object2 );
  33.  
  34. assert( is_a($Object, "AClass") );
  35.  
  36. <?php
  37. class BClass implements AnInterface { }
  38.  
  39. function moo(AnAbstractClass $abstract)
  40. {
  41. $b = new BClass();
  42. $abstract->method($b);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement