/** * Checks if the addAnnotationAlias() method works as expected. * * @return void */ public function testAddAnnotationAlias() { // add the annotation alias $this->reflectionProperty->addAnnotationAlias($name = 'test', $className = __CLASS__); // load the annotation aliases $annotationAliases = $this->reflectionProperty->getAnnotationAliases(); // check the annotation alias $this->assertCount(1, $annotationAliases); $this->assertTrue(array_key_exists($name, $annotationAliases)); $this->assertContains($className, $annotationAliases); }
/** * Returns the class properties. * * @param integer $filter Filter the results to include only properties with certain attributes * * @return array The class properties * @see \AppserverIo\Lang\Reflection\ClassInterface::getProperties() * @link http://php.net/manual/en/reflectionclass.getproperties.php */ public function getProperties($filter = ReflectionProperty::ALL_MODIFIERS) { // check if the properties for the requested filter has been loaded if (isset($this->properties[$filter]) === false) { $this->properties[$filter] = ReflectionProperty::fromReflectionClass($this, $filter, $this->getAnnotationsToIgnore(), $this->getAnnotationAliases()); } // return the requested properties return $this->properties[$filter]; }
/** * Creates a new reflection property instance from the passed PHP reflection property. * * @param \ReflectionProperty $reflectionProperty The reflection property to load the data from * @param array $annotationsToIgnore An array with annotations names we want to ignore when loaded * @param array $annotationAliases An array with annotation aliases used when create annotation instances * * @return \AppserverIo\Lang\Reflection\ReflectionProperty The instance */ public static function fromPhpReflectionProperty(\ReflectionProperty $reflectionProperty, array $annotationsToIgnore = array(), array $annotationAliases = array()) { // load class and method name from the reflection class $className = $reflectionProperty->getDeclaringClass()->getName(); $propertyName = $reflectionProperty->getName(); // initialize and return the timeout method instance return new ReflectionProperty($className, $propertyName, $annotationsToIgnore, $annotationAliases); }