public function testInterfaceTester() { $interface = 'SR\\Util\\Test\\Fixture\\FixtureInterface'; static::assertTrue(ClassInfo::assertInterface($interface)); static::assertTrue(ClassInfo::isInterface($interface)); static::assertFalse(ClassInfo::isInterface(__CLASS__)); $this->expectException('\\InvalidArgumentException'); ClassInfo::assertInterface(__CLASS__); }
/** * @param string $class * @param string $constant * @param null|object $bindTo * @param null|ResolverInterface $resolver */ public function __construct($class, $constant, $bindTo = null, ResolverInterface $resolver = null) { try { parent::__construct(new ReflectionConstant($class, $constant), $bindTo, $resolver); if (ClassInfo::isInterface($class)) { $this->declaringClass = new InterfaceInspector($class); } elseif (ClassInfo::isClass($class)) { $this->declaringClass = new ClassInspector($class); } } catch (\Exception $exception) { throw $this->getConstructorException(['class name string', $class], ['constant name string', $constant]); } }
/** * Try to determine the type of passed item and proxies the call to the respective specific this[*] methods. * * @param object|string $what A class name, object instance, interface name, or trait name * @param object|null $bind Alternate $this binding for internal resolver instance * * @throws RuntimeException If passed value is not an instance, class, interface or trait * * @return ClassInspector|ObjectInspector|InterfaceInspector|TraitInspector */ public static function using($what, $bind = null) { if (ClassInfo::isInstance($what)) { return self::useInstance($what, $bind); } if (ClassInfo::isClass($what)) { return self::useClass($what, $bind); } if (ClassInfo::isInterface($what)) { return self::useInterface($what, $bind); } if (ClassInfo::isTrait($what)) { return self::useTrait($what); } throw RuntimeException::create('Invalid inspector argument provided (got %s)', var_export($what, true)); }