rfc:abstract_trait_method_validation
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
rfc:abstract_trait_method_validation [2020/02/07 10:25] – created nikic | rfc:abstract_trait_method_validation [2020/04/23 10:49] (current) – nikic | ||
---|---|---|---|
Line 2: | Line 2: | ||
* Date: 2020-02-07 | * Date: 2020-02-07 | ||
* Author: Nikita Popov < | * Author: Nikita Popov < | ||
- | * Status: | + | * Status: |
* Target Version: PHP 8.0 | * Target Version: PHP 8.0 | ||
* Implementation: | * Implementation: | ||
Line 27: | Line 27: | ||
private function neededByTheTrait(): | private function neededByTheTrait(): | ||
- | // This is also allowed | + | // This is forbidden |
- | | + | |
| | ||
// This is forbidden (non-static changed to static) | // This is forbidden (non-static changed to static) | ||
private static function neededByTheTrait(): | private static function neededByTheTrait(): | ||
- | |||
- | // This is forbidden (incorrect return type) | ||
- | private function neededByTheTrait(): | ||
} | } | ||
</ | </ | ||
Line 117: | Line 114: | ||
This RFC proposes to always validate the signature of abstract trait methods against the implementing method, independently of its origin. Additionally the incorrect bidirectional cross-trait compatibilty check from the last example is removed. | This RFC proposes to always validate the signature of abstract trait methods against the implementing method, independently of its origin. Additionally the incorrect bidirectional cross-trait compatibilty check from the last example is removed. | ||
- | Verification for abstract trait methods follows the same rules as for other methods and results in a fatal error if the methods are not compatible: | + | A fatal error is generated |
* The signature must be compatible, which includes arity compatibility, | * The signature must be compatible, which includes arity compatibility, | ||
- | | + | * The static-ness of the methods |
- | | + | |
Additionally, | Additionally, | ||
Private abstract methods must be implemented by the using class. Their implementation cannot be postponed by marking the class abstract, as this would once again render the implementation inaccessible. | Private abstract methods must be implemented by the using class. Their implementation cannot be postponed by marking the class abstract, as this would once again render the implementation inaccessible. | ||
+ | |||
+ | Contrary to the usual inheritance rules, the visibility level of the abstract trait method is **not** enforced. This means that an '' | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 133: | Line 131: | ||
===== Vote ===== | ===== Vote ===== | ||
- | Yes/No. | + | Voting opened 2020-03-06 and closes 2020-03-20. |
+ | |||
+ | <doodle title=" | ||
+ | | ||
+ | | ||
+ | </ | ||
rfc/abstract_trait_method_validation.txt · Last modified: 2020/04/23 10:49 by nikic