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/15 23:18] – Grammar carusogabriel | rfc:magic-methods-signature [2020/04/28 15:08] – carusogabriel | ||
---|---|---|---|
Line 15: | Line 15: | ||
Nowadays, PHP already checks the signature for the following methods: | Nowadays, PHP already checks the signature for the following methods: | ||
- | * clone return type: https:// | + | * //%%__%%clone// return type: https:// |
- | * construct return type: https:// | + | * //%%__%%construct// return type: https:// |
- | * destruct return type: https:// | + | * //%%__%%destruct// return type: https:// |
+ | * // | ||
===== Motivation ===== | ===== Motivation ===== | ||
- | Since the introduction of types in PHP 7.0, only the 3 checks listed above were introduced to make sure that developers | + | 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 |
- | For PHP 8, this RFC aims to expand these checks, making their usage standard across different projects and applications. | + | 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. | ||
===== Proposal ===== | ===== Proposal ===== | ||
Line 41: | Line 44: | ||
Foo:: | Foo:: | ||
+ | |||
+ | Foo:: | ||
/** @return mixed */ | /** @return mixed */ | ||
Line 46: | Line 51: | ||
Foo:: | Foo:: | ||
+ | |||
+ | Foo:: | ||
/** @param mixed $value */ | /** @param mixed $value */ | ||
Foo:: | Foo:: | ||
+ | |||
+ | /** @return mixed */ | ||
+ | Foo:: | ||
+ | |||
+ | Foo:: | ||
+ | |||
+ | Foo:: | ||
Foo:: | Foo:: | ||
+ | |||
+ | Foo:: | ||
</ | </ | ||
- | **Note:** The // | + | **Note:** The // |
| | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
- | |||
- | An important note here is that if one of the listed magic methods is directly called, and it has the wrong signatures, the error will be thrown regardless. | ||
- | |||
- | For example https:// | ||
==== To Magic Methods without types declared ==== | ==== To Magic Methods without types declared ==== | ||
Line 71: | Line 83: | ||
===== RFC Impact ===== | ===== RFC Impact ===== | ||
- | Scraping the top 1000 Composer packages (using Nikita' | + | Scraping the top 1000 Composer packages (using Nikita' |
Luckily, none of them is a problem as // | Luckily, none of them is a problem as // | ||
Line 79: | Line 91: | ||
===== Future Scope ===== | ===== Future Scope ===== | ||
- | This RFC only aims to add checks for the methods' | + | This RFC only aims to add checks for the methods' |
+ | |||
+ | * // | ||
+ | * // | ||
+ | * // | ||
+ | * // | ||
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
Yes/No. | Yes/No. | ||
+ | |||
+ | ===== External resources ===== | ||
+ | |||
+ | - Discussion thread: https:// | ||
+ |
rfc/magic-methods-signature.txt · Last modified: 2020/08/01 23:34 by carusogabriel