/** * @param ClassInfo $classInfo * @return Expr[] */ public function generateCode(ClassInfo $classInfo) { $nodes = array(); $nodes[] = $this->prepareControllersNode(); foreach ($classInfo->getMethodInfos() as $methodInfo) { $route = $methodInfo->getFirstAnnotationInstanceof('Saxulum\\RouteController\\Annotation\\Route'); if (!is_null($route)) { $nodes[] = $this->prepareControllerNode($classInfo, $methodInfo, $route); $nodes = array_merge($nodes, $this->prepareControllerSimple($route, 'bind')); $nodes = array_merge($nodes, $this->prepareControllerComplex($route, 'asserts', 'assert')); $nodes = array_merge($nodes, $this->prepareControllerComplex($route, 'values', 'value')); $nodes = array_merge($nodes, $this->prepareControllerConverters($classInfo, $route)); $nodes = array_merge($nodes, $this->prepareControllerSimple($route, 'method')); $nodes = array_merge($nodes, $this->prepareControllerBoolean($route, 'requireHttp')); $nodes = array_merge($nodes, $this->prepareControllerBoolean($route, 'requireHttps')); $nodes = array_merge($nodes, $this->prepareControllerBefore($classInfo, $route)); $nodes = array_merge($nodes, $this->prepareControllerAfter($classInfo, $route)); } } $nodes[] = $this->prepareControllersMountNode($classInfo); return $nodes; }
/** * @param ClassInfo $classInfo */ protected function checkTestClass1(ClassInfo $classInfo) { $this->assertEquals('Saxulum\\Tests\\AnnotationManager\\Classes1\\TestClass1', $classInfo->getName()); $propertyInfos = $classInfo->getPropertyInfos(); $this->assertCount(1, $propertyInfos); $propertyAnnotations = $propertyInfos[0]->getAnnotations(); $this->assertCount(1, $propertyAnnotations); $this->assertInstanceOf('Saxulum\\Tests\\AnnotationManager\\Annotation\\TestAnnotationB', $propertyAnnotations[0]); $this->assertFalse($propertyAnnotations[0]->value); $methodInfos = $classInfo->getMethodInfos(); $this->assertCount(3, $methodInfos); $methodAnnotations = $methodInfos[0]->getAnnotations(); $this->assertEquals('test1', $methodInfos[0]->getName()); $this->assertCount(2, $methodAnnotations); $this->assertInstanceOf('Saxulum\\Tests\\AnnotationManager\\Annotation\\TestAnnotationA', $methodAnnotations[0]); $this->assertEquals('test1', $methodAnnotations[0]->value); $this->assertInstanceOf('Saxulum\\Tests\\AnnotationManager\\Annotation\\TestAnnotationB', $methodAnnotations[1]); $this->assertTrue($methodAnnotations[1]->value); $methodAnnotations = $methodInfos[1]->getAnnotations(); $this->assertEquals('test2', $methodInfos[1]->getName()); $this->assertCount(1, $methodAnnotations); $this->assertInstanceOf('Saxulum\\Tests\\AnnotationManager\\Annotation\\TestAnnotationB', $methodAnnotations[0]); $this->assertTrue($methodAnnotations[0]->value); $this->assertCount(0, $methodInfos[2]->getAnnotations()); $this->assertEquals('test3', $methodInfos[2]->getName()); }