function testInvalidAnnotationValue() { $reflection = new RecessReflectionClass('InvalidAnnotationValue'); try { $annotations = $reflection->getAnnotations(); $this->fail('Should throw an InvalidAnnotationValueException.'); } catch (InvalidAnnotationValueException $e) { // Pass } }
/** * Builds a class' metadata structure (Class Descriptor through reflection * and expansion of annotations. Hooks are provided in a Strategy Pattern-like * fashion to allow subclasses to influence various points in the pipeline of * building a class descriptor (initialization, discovery of method, discovery of * property, finalization). * * @param $class Name of class whose descriptor is being built. * @return ClassDescriptor */ protected static function buildClassDescriptor($class) { $descriptor = call_user_func(array($class, 'initClassDescriptor'), $class); try { $reflection = new RecessReflectionClass($class); } catch (ReflectionException $e) { throw new RecessException('Class "' . $class . '" has not been declared.', get_defined_vars()); } foreach ($reflection->getAnnotations() as $annotation) { $annotation->expandAnnotation($class, $reflection, $descriptor); } foreach ($reflection->getMethods(false) as $method) { $annotations = $method->getAnnotations(); $descriptor = call_user_func(array($class, 'shapeDescriptorWithMethod'), $class, $method, $descriptor, $annotations); foreach ($annotations as $annotation) { $annotation->expandAnnotation($class, $method, $descriptor); } } foreach ($reflection->getProperties(false) as $property) { $annotations = $property->getAnnotations(); $descriptor = call_user_func(array($class, 'shapeDescriptorWithProperty'), $class, $property, $descriptor, $annotations); foreach ($annotations as $annotation) { $annotation->expandAnnotation($class, $property, $descriptor); } } $descriptor = call_user_func(array($class, 'finalClassDescriptor'), $class, $descriptor); return $descriptor; }