rfc:null-false-standalone-types
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:null-false-standalone-types [2022/03/10 16:45] – Clear up Reflection caveat girgias | rfc:null-false-standalone-types [2022/04/08 16:26] (current) – Change status to implemented girgias | ||
---|---|---|---|
Line 4: | Line 4: | ||
* Date: 2022-02-20 | * Date: 2022-02-20 | ||
* Author: George Peter Banyard, < | * Author: George Peter Banyard, < | ||
- | * Status: | + | * Status: |
* Target Version: PHP 8.2 | * Target Version: PHP 8.2 | ||
- | * Implementation: | + | * Implementation: |
* First Published at: [[http:// | * First Published at: [[http:// | ||
Line 132: | Line 132: | ||
Allows Null: true | Allows Null: true | ||
</ | </ | ||
+ | |||
+ | ==== Example ==== | ||
+ | |||
+ | We take an example from unit testing but it can be applied to other more general cases, | ||
+ | where a class which implements an interface always returns '' | ||
+ | |||
+ | <PHP> | ||
+ | class User {} | ||
+ | |||
+ | interface UserFinder | ||
+ | { | ||
+ | function findUserByEmail(): | ||
+ | } | ||
+ | |||
+ | class AlwaysNullUserFinder implements UserFinder | ||
+ | { | ||
+ | function findUserByEmail(): | ||
+ | { | ||
+ | return null; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Currently it is not possible to write this code in PHP as it gives the error: | ||
+ | < | ||
+ | |||
+ | This means that an incorrect '' | ||
+ | That leads to further confusion as a static analyzer analysing that class will give a ' | ||
+ | |||
+ | The same problem exists for interfaces that have a return type that is a union of false with another type. | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 144: | Line 174: | ||
As per the voting RFC a yes/no vote with a 2/3 majority is needed for this proposal to be accepted. | As per the voting RFC a yes/no vote with a 2/3 majority is needed for this proposal to be accepted. | ||
+ | |||
+ | Voting started on 2022-03-12 and will end on 2022-03-26. | ||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
===== Implementation ===== | ===== Implementation ===== | ||
Line 151: | Line 187: | ||
After the project is implemented, | After the project is implemented, | ||
- | * the version(s) it was merged into | + | * Version 8.2.0 |
- | * a link to the git commit(s) | + | * Commit: https:// |
* a link to the PHP manual entry for the feature | * a link to the PHP manual entry for the feature | ||
===== References ===== | ===== References ===== | ||
rfc/null-false-standalone-types.1646930752.txt.gz · Last modified: 2022/03/10 16:45 by girgias