Advertisement
Guest User

Untitled

a guest
Oct 19th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. <?php
  2.  
  3. class AAA{}
  4. class BBB extends AAA{}
  5.  
  6. class X{
  7. protected AAA $foo;
  8. function __construct(AAA $foo){
  9. $this->foo = $foo;
  10. }
  11. function set(AAA $foo){
  12. $this->foo = $foo;
  13. }
  14. }
  15.  
  16. class Y extends X{
  17. protected BBB $foo;
  18. function __construct(BBB $foo){
  19. parent::__construct($foo);
  20. }
  21. function set(BBB $foo){ // cannot do this
  22. $this->foo = $foo;
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement