rfc:callable
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
rfc:callable [2011/06/07 13:53] – created bjori | rfc:callable [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Request for Comments: | + | ====== Request for Comments: |
* Version: 1.0 | * Version: 1.0 | ||
* Date: 2011-06-07 | * Date: 2011-06-07 | ||
* Author: Hannes Magnusson < | * Author: Hannes Magnusson < | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
Line 12: | Line 12: | ||
Frameworks have started to adopt Closures for callbacks, utilizing the ' | Frameworks have started to adopt Closures for callbacks, utilizing the ' | ||
That has an unfortunate sideeffect of requiring already-existing-methods to be wrapped into a closure calling that method. | That has an unfortunate sideeffect of requiring already-existing-methods to be wrapped into a closure calling that method. | ||
+ | Additionally, | ||
===== The solution ===== | ===== The solution ===== | ||
Line 18: | Line 19: | ||
The typehint would allow a string with a function name, an array composed of classname/ | The typehint would allow a string with a function name, an array composed of classname/ | ||
+ | |||
+ | ===== Callable vs Callback ===== | ||
+ | |||
+ | callback is callable, the opposite could not be true. A string, or a closure, is callable, but the string is not a callback. | ||
+ | |||
+ | The documentations already use `array` hinting when a function expects an array, even though it does not type hint on it. | ||
+ | The documentations already use `callable` hiting when a function expects a callable instance, even though it does not type hint on it. | ||
+ | |||
+ | Furthermore we already have a function called is_callable(), | ||
+ | |||
+ | Introducing a different name (i..e callback) will therefore only create more inconsistencies and confusion. | ||
+ | |||
+ | The callable typehint reuses the is_callable() logic. | ||
+ | |||
+ | ===== Initialization ===== | ||
+ | |||
+ | Only null initialize is allowed, making it consistent with classname typehinting. | ||
+ | |||
Line 33: | Line 52: | ||
* The only arguments against the idea came from Stas, [[http:// | * The only arguments against the idea came from Stas, [[http:// | ||
- | * ' | + | * ' |
- | * A " | + | * A " |
- | * Everyone else seem to like the idea. | + | * Everyone else seem to like the idea, so far. |
* As for the patch itself, Felipe pointed out that the patch is missing an method in ext/ | * As for the patch itself, Felipe pointed out that the patch is missing an method in ext/ | ||
+ | * Things to finalize: | ||
+ | * Reflection support | ||
+ | * Arginfo support | ||
Line 42: | Line 64: | ||
* June 7th 2011, Initial writeup | * June 7th 2011, Initial writeup | ||
+ | * July 27th 2011, Added " | ||
+ | |||
rfc/callable.1307454825.txt.gz · Last modified: 2017/09/22 13:28 (external edit)