rfc:callable-interfaces
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
rfc:callable-interfaces [2016/04/06 11:58] – Adding question about instanceof usage ocramius | rfc:callable-interfaces [2016/04/12 10:11] – Retiring RFC due to incompatible object -> function semantics mixup ocramius | ||
---|---|---|---|
Line 4: | Line 4: | ||
* Author: Ben Scholzen, mail@dasprids.de | * Author: Ben Scholzen, mail@dasprids.de | ||
* Author: Marco Pivetta, ocramius@gmail.com | * Author: Marco Pivetta, ocramius@gmail.com | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
Line 112: | Line 112: | ||
===== Still Open for Discussion ===== | ===== Still Open for Discussion ===== | ||
- | * how will **instanceof** behave, when asked for a type-check against **callable**? | + | How will **instanceof** behave, when asked for a type-check against **callable**? |
+ | |||
+ | <code php> | ||
+ | interface RegisterUser { | ||
+ | public function __invoke(Username $username) : UserRegistration; | ||
+ | } | ||
+ | |||
+ | interface DeleteUserRegistration { | ||
+ | public function __invoke(Username $username) : UserRegistration; | ||
+ | } | ||
+ | |||
+ | $register = function (Username $username) : UserRegistration { | ||
+ | return new UserRegistration(...); | ||
+ | }; | ||
+ | |||
+ | var_dump($register instanceof DeleteUserRegistration); | ||
+ | </ | ||
+ | |||
+ | ===== Retired ===== | ||
+ | |||
+ | This RFC has been retired. Reason for that is that PHP currently (Version 7.0~7.1) allows applying function semantics to objects via the **_****_invoke** magic methods. Allowing the opposite would mix the domain of functions and objects in ways that are very hard to disentangle, | ||
+ | |||
+ | While it is unfortunate that migration to type-safe callables (https:// | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== |
rfc/callable-interfaces.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1