Kahlan\Analysis\Inspector::inspect PHP Method

inspect() public static method

Gets the ReflectionClass instance of a class.
public static inspect ( string $class ) : object
$class string The class name to inspect.
return object The ReflectionClass instance.
    public static function inspect($class)
    {
        if (!isset(static::$_cache[$class])) {
            static::$_cache[$class] = new ReflectionClass($class);
        }
        return static::$_cache[$class];
    }

Usage Example

Example #1
0
 /**
  * The Constructor.
  *
  * @param mixed $reference An instance or a fully-namespaced class name.
  */
 public function __construct($reference)
 {
     $reference = $this->_reference($reference);
     $isString = is_string($reference);
     if ($isString) {
         if (!class_exists($reference)) {
             throw new InvalidArgumentException("Can't Stub the unexisting class `{$reference}`.");
         }
         $reference = ltrim($reference, '\\');
         $reflection = Inspector::inspect($reference);
     } else {
         $reflection = Inspector::inspect(get_class($reference));
     }
     if (!$reflection->isInternal()) {
         $this->_reference = $reference;
         return;
     }
     if (!$isString) {
         throw new InvalidArgumentException("Can't Stub built-in PHP instances, create a test double using `Double::instance()`.");
     }
     $this->_needToBePatched = true;
     return $this->_reference = $reference;
 }
All Usage Examples Of Kahlan\Analysis\Inspector::inspect