-
Notifications
You must be signed in to change notification settings - Fork 7.8k
[RFC] Final Property Promotion #17861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This does not appear to be explicitly specified in the RFC and is a language change. I'm not sure this is an appropriate bugfix for 8.4. |
/cc @Crell |
This came up, and there were some concerns it could imply const parameters as in Java. So we just left it out. |
So no, this is not a bug. If you think |
e3cee1b
to
ad6d15a
Compare
final
in constructor property promotionclass B extends A { | ||
public $prop { get {} set {} } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class B extends A { | |
public $prop { get {} set {} } | |
} | |
class B extends A { | |
public $prop = 5 | |
} |
class B extends A { | |
public $prop { get {} set {} } | |
} | |
class B extends A { | |
public function __construct( | |
public $prop | |
) {} | |
} |
class B extends A { | |
public $prop { get {} set {} } | |
} | |
class B extends A { | |
public function __construct( | |
$prop | |
) {} | |
} |
Is this allowed after this PR? If yes, is it tested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitHub's display is a bit confusing - are you suggesting that the code be
class B extends A {
$prop
}
? That isn't valid PHP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(edited)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class B extends A {
public function __construct(
$prop
) {}
}
doesn't involve property promotion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does in A class and I would like to get this tested.
https://wiki.php.net/rfc/final_promotion