Advertisement
Danack

Untitled

Feb 1st, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1.  
  2. Gordons RFC
  3. ===========
  4.  
  5. //initial code
  6.  
  7. class A {
  8. private $f;
  9. function __construct($this->f) {
  10. }
  11. }
  12.  
  13. class B extends A {
  14. function __construct($this->f) {
  15. //Sets $f and also calls constructor
  16. parent::__construct($f);
  17. }
  18. }
  19.  
  20.  
  21. //Constructor of A is changed - only need to change how constructor is called, everything else still works
  22.  
  23. class A {
  24. private $f;
  25. function __construct() {
  26. }
  27. }
  28.  
  29. class B extends A {
  30. function __construct($this->f) {
  31. parent::__construct();
  32. }
  33. }
  34.  
  35.  
  36.  
  37. Facebook RFC
  38. ============
  39.  
  40. //Initial code
  41.  
  42. class A {
  43. private $f;
  44. function __construct(private $f) {
  45. $this->f = $f;
  46. }
  47. }
  48.  
  49. class B extends A {
  50. //can't declare parameters as 'private $f' as it will created duplicate variable in class B
  51. function __construct($f) {
  52. parent::__construct($f);
  53. }
  54. }
  55.  
  56.  
  57.  
  58. //Constructor of A is changed - now need to change how constructor of B is defined, as well as how it calls A::__construct
  59. class A {
  60. private $f;
  61. function __construct() {
  62. }
  63. }
  64.  
  65. class B extends A {
  66. function __construct(private $f) {
  67. //Creates $f on B - does not set it on A. We are fubared.
  68. parent::__construct();
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement