Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. <?php
  2.  
  3. class ParentClass {
  4. /**
  5. * Says 'hi' to the world.
  6. * @return ParentClass Returns itself for chaining.
  7. */
  8. public function say_hi(){
  9. echo 'hi';
  10. return $this;
  11. }
  12. }
  13.  
  14. class ChildClass extends ParentClass {
  15. /**
  16. * Says 'bye' to the world.
  17. * @return ChildClass Returns itself for chaining.
  18. */
  19. public function say_bye(){
  20. echo 'bye';
  21. return $this;
  22. }
  23. }
  24.  
  25. $c = new ChildClass;
  26. $c->say_hi()->say_b| <- type hinting won't suggest "say_bye" here
  27.  
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement