rfc:class_and_interface_name_types
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:class_and_interface_name_types [2017/04/29 14:55] – delete "(as appropriate)" ajf | rfc:class_and_interface_name_types [2017/05/05 16:15] – note ::class under class/interface arguments ajf | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== PHP RFC: Class name type ====== | + | a few a====== PHP RFC: Class name type ====== |
* Version: 0.1 | * Version: 0.1 | ||
* Date: 2017-04-29 | * Date: 2017-04-29 | ||
Line 18: | Line 18: | ||
- If there is now no currently-loaded class or interface with the name given by the value, reject the value. | - If there is now no currently-loaded class or interface with the name given by the value, reject the value. | ||
- Otherwise, accept the value. | - Otherwise, accept the value. | ||
+ | |||
+ | As a parameter type, it would permit default values of < | ||
A simple example of usage: | A simple example of usage: | ||
Line 24: | Line 26: | ||
<?php | <?php | ||
- | function accepts_class(class $class) { | + | function accepts_class(class $class = stdClass::class) { |
var_dump($class); | var_dump($class); | ||
} | } | ||
- | accepts_class(stdClass:: | + | accepts_class(); |
- | accepts_class(" | + | accepts_class(stdClass:: |
- | accepts_class(ArrayAccess:: | + | accepts_class(" |
+ | accepts_class(ArrayAccess:: | ||
accepts_class(" | accepts_class(" | ||
</ | </ | ||
Line 61: | Line 64: | ||
* It limits the number of new types that are introduced (one versus two or three) | * It limits the number of new types that are introduced (one versus two or three) | ||
* It aligns with the internal '' | * It aligns with the internal '' | ||
+ | * It aligns with how < | ||
* Interfaces are essentially glorified abstract classes | * Interfaces are essentially glorified abstract classes | ||
* PHP internally represents interfaces as a kind of class | * PHP internally represents interfaces as a kind of class | ||
Line 104: | Line 108: | ||
There is a patch here which contains tests: https:// | There is a patch here which contains tests: https:// | ||
- | It does not yet handle inheritance concerns. | + | The commits for versions with multiple new types do not handle inheritance concerns. |
There is not yet a pull request. | There is not yet a pull request. |
rfc/class_and_interface_name_types.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1