| 1 |
<?php |
| 2 |
|
| 3 |
namespace FL\Assistant\System\Container; |
| 4 |
|
| 5 |
class StandardReflector implements Reflector { |
| 6 |
|
| 7 |
public function getClass( $class ) { |
| 8 |
return new \ReflectionClass( $class ); |
| 9 |
} |
| 10 |
|
| 11 |
public function getCtor( $class ) { |
| 12 |
$reflectionClass = new \ReflectionClass( $class ); |
| 13 |
|
| 14 |
return $reflectionClass->getConstructor(); |
| 15 |
} |
| 16 |
|
| 17 |
public function getCtorParams( $class ) { |
| 18 |
return ( $reflectedCtor = $this->getCtor( $class ) ) |
| 19 |
? $reflectedCtor->getParameters() |
| 20 |
: null; |
| 21 |
} |
| 22 |
|
| 23 |
public function getParamTypeHint( \ReflectionFunctionAbstract $function, \ReflectionParameter $param ) { |
| 24 |
return ( $reflectionClass = $param->getClass() ) |
| 25 |
? $reflectionClass->getName() |
| 26 |
: null; |
| 27 |
} |
| 28 |
|
| 29 |
public function getFunction( $functionName ) { |
| 30 |
return new \ReflectionFunction( $functionName ); |
| 31 |
} |
| 32 |
|
| 33 |
public function getMethod( $classNameOrInstance, $methodName ) { |
| 34 |
$className = is_string( $classNameOrInstance ) |
| 35 |
? $classNameOrInstance |
| 36 |
: get_class( $classNameOrInstance ); |
| 37 |
|
| 38 |
return new \ReflectionMethod( $className, $methodName ); |
| 39 |
} |
| 40 |
} |
| 41 |
|