Re: [RFC] ReflectionParameter::hasTypehint() / getTypehintText()

From: Date: Thu, 29 May 2014 22:01:12 +0000
Subject: Re: [RFC] ReflectionParameter::hasTypehint() / getTypehintText()
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-74646@lists.php.net to get a copy of this message
On Thu, May 29, 2014 at 1:55 PM, Levi Morrison <morrison.levi@gmail.com> wrote: > On Thu, May 29, 2014 at 1:59 PM, Sara Golemon <pollita@php.net> wrote: >> Pretty straight-forward. Makes it easier to recreate a function >> signature from PHP (Mocking) >> https://wiki.php.net/rfc/reflectionparameter.typehint > > 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

« previous php.internals (#74646) next »