Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Gordons RFC
- ===========
- //initial code
- class A {
- private $f;
- function __construct($this->f) {
- }
- }
- class B extends A {
- function __construct($this->f) {
- //Sets $f and also calls constructor
- parent::__construct($f);
- }
- }
- //Constructor of A is changed - only need to change how constructor is called, everything else still works
- class A {
- private $f;
- function __construct() {
- }
- }
- class B extends A {
- function __construct($this->f) {
- parent::__construct();
- }
- }
- Facebook RFC
- ============
- //Initial code
- class A {
- private $f;
- function __construct(private $f) {
- $this->f = $f;
- }
- }
- class B extends A {
- //can't declare parameters as 'private $f' as it will created duplicate variable in class B
- function __construct($f) {
- parent::__construct($f);
- }
- }
- //Constructor of A is changed - now need to change how constructor of B is defined, as well as how it calls A::__construct
- class A {
- private $f;
- function __construct() {
- }
- }
- class B extends A {
- function __construct(private $f) {
- //Creates $f on B - does not set it on A. We are fubared.
- parent::__construct();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement