Reflection-API (was: Re: [PHP-DEV] RFC: Return Types Update)

From: Date: Sun, 19 Oct 2014 19:31:00 +0000
Subject: Reflection-API (was: Re: [PHP-DEV] RFC: Return Types Update)
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-78153@lists.php.net to get a copy of this message
On 16.10.14 06:39, Levi Morrison wrote: > - The design and accompanying section of reflection[3] has been > rewritten entirely. > > [3]: https://wiki.php.net/rfc/returntypehinting#reflection I've some comments about the Reflection API addition/changes: 1. > "Note that getReturnType will always return a ReflectionType object, even if there is no return type declared." That feels weird, TBH. Other parts of the Reflection-API don't do that, they simply return false if I would call e.g. getParentClass() when there's none. 2. > "This API was designed so you could use ReflectionType::getKind() in a switch statement to cover all cases, rather than be forced to use an if/else structure that calls isArray(), isCallable, etc like the ReflectionParameter API does." I don't like the deviation from the existing Reflection API. I'm not saying it's perfect, but I fear a "haystack,needle vs. needle,haystack" thing here and would prefer the existing convention for is*() methods. I wouldn't see a conflict it providing both as I see the usefulness. 3. The new class is called "ReflectionType", shouldn't it be "ReflectionReturnType" ? 4. Other reflection classes, e.g. ReflectionParameter provides "missing link" methods, specifically I'm missing: public ReflectionClass getDeclaringClass ( void ); public ReflectionFunctionAbstract getDeclaringFunction ( void ); 5. I think, also like in ReflectionParameter, there should a direct shortcut to the class, if provided (and not just the string name): public ReflectionClass getClass ( void ); thanks, - Markus

« previous php.internals (#78153) next »