public function testReflectionAnnotatedClass() { $reflection = new ReflectionAnnotatedClass('Example'); $this->assertTrue($reflection->hasAnnotation('FirstAnnotation')); $this->assertTrue($reflection->hasAnnotation('SecondAnnotation')); $this->assertFalse($reflection->hasAnnotation('NonExistentAnnotation')); $this->assertInstanceOf('FirstAnnotation', $reflection->getAnnotation('FirstAnnotation')); $this->assertInstanceOf('SecondAnnotation', $reflection->getAnnotation('SecondAnnotation')); $annotations = $reflection->getAnnotations(); $this->assertEquals(count($annotations), 2); $this->assertInstanceOf('FirstAnnotation', $annotations[0]); $this->assertInstanceOf('SecondAnnotation', $annotations[1]); $this->assertFalse($reflection->getAnnotation('NonExistentAnnotation')); $this->assertInstanceOf('Addendum\\ReflectionAnnotatedMethod', $reflection->getConstructor()); $this->assertInstanceOf('Addendum\\ReflectionAnnotatedMethod', $reflection->getMethod('exampleMethod')); foreach ($reflection->getMethods() as $method) { $this->assertInstanceOf('Addendum\\ReflectionAnnotatedMethod', $method); } $this->assertInstanceOf('Addendum\\ReflectionAnnotatedProperty', $reflection->getProperty('exampleProperty')); foreach ($reflection->getProperties() as $property) { $this->assertInstanceOf('Addendum\\ReflectionAnnotatedProperty', $property); } foreach ($reflection->getInterfaces() as $interface) { $this->assertInstanceOf('Addendum\\ReflectionAnnotatedClass', $interface); } $this->assertInstanceOf('Addendum\\ReflectionAnnotatedClass', $reflection->getParentClass()); }
public function accept($chain, $controller, $method, $args, $request, $controller_ret = null) { if (isset($this->method)) { return true; } $re = new ReflectionAnnotatedClass(get_class($controller)); $this->method = $re->getMethod($method); if ($this->method->hasAnnotation('Clips\\Rules')) { return true; } return false; }
public function testSuccesfullyNestedAnnotationThrowsNoError() { $reflection = new ReflectionAnnotatedClass('SuccesfullyAnnotatedClass'); $reflection->getMethod('method2')->getAnnotation('MethodRestrictedAnnotation'); }