rfc:magic-methods-signature
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:magic-methods-signature [2020/04/26 23:59] – debugInfo can also return null carusogabriel | rfc:magic-methods-signature [2020/04/28 16:29] – carusogabriel | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== PHP RFC: Ensure correct magic methods' signatures when typed ====== | + | ====== PHP RFC: Ensure correct |
* Version: 1.0 | * Version: 1.0 | ||
* Date: 2020-04-05 | * Date: 2020-04-05 | ||
Line 9: | Line 9: | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | This RFC is inspired by [[https:// | + | It is currently possible to write magic methods that have signatures that don't match the signature |
- | However, this implementation is not as simple as just check for the methods' | + | This behavior of allowing incorrect |
- | Nowadays, PHP already checks | + | As ensuring magic methods have correct signatures is a backward compatible break for code that currently has incorrect signatures, this change would only be appropriate in a major PHP release. |
+ | |||
+ | ===== Motivation ===== | ||
+ | |||
+ | PHP's Magic Methods is something that PHP provides allowing developers to track and act on specific changes of behavior of a certain class. Given that fact, the same should ensure that the end-users are using these methods consistently across different codebases. | ||
+ | |||
+ | Since the introduction of types in PHP 7.0, only the checks list below were introduced to make sure that developers are using PHP's magic methods | ||
* // | * // | ||
Line 19: | Line 25: | ||
* // | * // | ||
* // | * // | ||
- | |||
- | ===== Motivation ===== | ||
- | |||
- | PHP's Magic Methods is something that PHP provides allowing developers to track and act on specific changes of behavior of a certain class. Given that fact, the same should ensure that the end-users are using these methods consistently across different codebases. | ||
- | |||
- | Since the introduction of types in PHP 7.0, only the checks listed above (under " | ||
For PHP 8, this RFC aims to expand these checks. | For PHP 8, this RFC aims to expand these checks. | ||
Line 30: | Line 30: | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | This RFC proposes to introduce | + | This RFC proposes to add parameter and return types checks per the following |
- | + | ||
- | **Important: | + | |
The proposal follows the [[https:// | The proposal follows the [[https:// | ||
Line 57: | Line 55: | ||
Foo:: | Foo:: | ||
- | /** @return mixed */ | + | Foo:: |
- | Foo:: | + | |
Foo:: | Foo:: | ||
Line 69: | Line 66: | ||
</ | </ | ||
- | **Note:** The // | + | **Note:** The // |
| | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 96: | Line 93: | ||
* // | * // | ||
* // | * // | ||
+ | * // | ||
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== |
rfc/magic-methods-signature.txt · Last modified: 2020/08/01 23:34 by carusogabriel