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