public function testMethodAnnotations() { $rel = new IPReflectionClass('extendedAnnotationTestClass'); $methods = $rel->getMethods(); $method = $methods['methodB']; $ann = $method->getAnnotation('Controller', 'testExtendedAnnotationContainer'); $this->assertInternalType('object', $ann); $this->assertInstanceOf('testExtendedAnnotationContainer', $ann); $this->assertEquals(testExtendedAnnotationContainer::TYPE_HTML, $ann->type); $this->assertEquals(215, $ann->length); }
/** * Load the class or service definition for doc purpose * @param string $classname Name of the class for witch we want the doc, default doc is the service one (controller) */ public function doc($className = "") { if ($className != "") { if (!class_exists($className, false)) { throw new jException('jelix~errors.ad.controller.class.unknown', array('WSDL generation', $className, $this->_ctrlpath)); } $classObject = new IPReflectionClass($className); } else { $classObject = new IPReflectionClass($this->controllerClassName); } $documentation = array(); $documentation['menu'] = array(); if ($classObject) { $classObject->properties = $classObject->getProperties(false, false, false); $classObject->methods = $classObject->getMethods(false, false, false); foreach ((array) $classObject->methods as $method) { $method->params = $method->getParameters(); } $documentation['class'] = $classObject; $documentation['service'] = $this->module . '~' . $this->controller; } return $documentation; }
} /** * @ann1('me'=>'you'); */ class something { /** * @var string * @Controller(type => DefaultController::TYPE_PLAIN, length => 100) */ public $propertyA; /** * @var string * @Controller(type => DefaultController::TYPE_HTML, length => 100) */ public function methodB() { return "aap"; } } /* Annotation example */ $rel = new IPReflectionClass("something"); $properties = $rel->getProperties(); $methods = $rel->getMethods(); var_dump($rel->getAnnotation("ann1", "stdClass")); $property = $properties["propertyA"]; $ann = $property->getAnnotation("Controller", "DefaultController"); var_dump($ann); $method = $methods["methodB"]; $ann = $method->getAnnotation("Controller", "DefaultController"); var_dump($ann);