====== PHP RFC: ReflectionParameter::getClassName() ====== * Version: 0.2 * Date: 2015-01-30 * Author: Phil Sturgeon, me@philsturgeon.uk * Status: Withdrawn * First Published at: http://wiki.php.net/rfc/reflectionparameter-getclassname ===== Introduction ===== Adds a new method to ReflectionParameter to allow easy access to a class name in a type hint, avoiding the need to actually load the class and use `getClass()->name`. ===== Proposal ===== This method lets you access the class name of a type hint as a string: getMethod("bar"); $params = $method->getParameters(); var_dump($params[0]->getClassName()); // string(3) "Qux" var_dump($params[1]->getClassName()); // NULL var_dump($params[2]->getClassName()); // string(7) "Bar\Baz" var_dump($params[3]->getClassName()); // string(7) "Bar\Quz" $method = $class->getMethod("waldo"); $params = $method->getParameters(); var_dump($params[0]->getClassName()); // NULL var_dump($params[1]->getClassName()); // NULL This is only targeted at classes, not any other typehint. If scalar type hints come then I'm sure they'll have some new reflection methods. This is just getClass()->name but without the need to load the class. ===== Backward Incompatible Changes ===== None, unless somebody has made their own reflection extension and already have a getClassName() method. ===== Proposed PHP Version(s) ===== PHP 7 ===== Open Issues ===== None so far ===== Patches and Tests ===== https://github.com/php/php-src/pull/1039