|
Sara Golemon |
at May 29, 2014 at 10:01 pm
|
⇧ |
| |
On Thu, May 29, 2014 at 1:55 PM, Levi Morrison wrote:I'm hoping to improve the way types are handled in reflection but I've
been waiting until the return types and nullable types RFCs have been
voted on as that will most likely impact my decisions. I'd like to
introduce getType and hasType functions that holds various bits of
information such as isArray(), isCallable() and could also contain the
text representation of the type. What are your thoughts on that?
As in something like this?
$rf = new ReflectionFunction('foo');
list($rp) = $rf->getParameters();
$hint = $rp->getType(); // returns ReflectionTypeHint
if ($hint->isArray()) { ... }
I thought about that (and would like to see it), which is why I
specifically went for the name getTypehintText(), which leaves the
"get me an object version" (i.e. getTypehint()) left available. See
also:
https://wiki.php.net/rfc/reflectionparameter.typehint#on_the_naming If you think it's a bit too busy to have getTypehint(): object, and
getTypehintText(): string, I can hold off on this RFC for awhile.
There's certainly no rush.
Or did you mean something else?
-Sara