Chris@13: hasConstant($member)) { Chris@16: return ReflectionClassConstant::create($value, $member); Chris@13: } elseif ($filter & self::METHOD && $class->hasMethod($member)) { Chris@13: return $class->getMethod($member); Chris@13: } elseif ($filter & self::PROPERTY && $class->hasProperty($member)) { Chris@13: return $class->getProperty($member); Chris@13: } elseif ($filter & self::STATIC_PROPERTY && $class->hasProperty($member) && $class->getProperty($member)->isStatic()) { Chris@13: return $class->getProperty($member); Chris@13: } else { Chris@17: throw new RuntimeException(\sprintf( Chris@13: 'Unknown member %s on class %s', Chris@13: $member, Chris@17: \is_object($value) ? \get_class($value) : $value Chris@13: )); Chris@13: } Chris@13: } Chris@13: Chris@13: /** Chris@13: * Get a ReflectionClass (or ReflectionObject) if possible. Chris@13: * Chris@13: * @throws \InvalidArgumentException if $value is not a class name or instance Chris@13: * Chris@13: * @param mixed $value Chris@13: * Chris@13: * @return \ReflectionClass Chris@13: */ Chris@13: private static function getClass($value) Chris@13: { Chris@17: if (\is_object($value)) { Chris@13: return new \ReflectionObject($value); Chris@13: } Chris@13: Chris@17: if (!\is_string($value)) { Chris@13: throw new \InvalidArgumentException('Mirror expects an object or class'); Chris@17: } elseif (!\class_exists($value) && !\interface_exists($value) && !\trait_exists($value)) { Chris@13: throw new \InvalidArgumentException('Unknown class or function: ' . $value); Chris@13: } Chris@13: Chris@13: return new \ReflectionClass($value); Chris@13: } Chris@13: }