Exemplo n.º 1
0
 /**
  * Use the internal PHP namespace resolution order to
  * resolve the FQN for the given name.
  *
  * @param string $name The name to resolve.
  * @return string The fully qualified name.
  */
 private function getFullyQualifiedName($name)
 {
     $name = rtrim($name, self::NS_SEPARATOR);
     $pos = strpos($name, self::NS_SEPARATOR);
     $nsAlias = substr($name, 0, $pos);
     $useStatements = $this->context->getUseStatements();
     // Try to find the FQN for the annotation
     if ($pos === 0) {
         // Given name is an FQN
         $fqn = $name;
     } else {
         if ($nsAlias && isset($useStatements[$nsAlias])) {
             // It must be an aliased namespace
             $lastPart = substr($name, $pos);
             $fqn = $useStatements[$nsAlias] . $lastPart;
             $fqn = trim($fqn, self::NS_SEPARATOR);
         } else {
             if (!$nsAlias && isset($useStatements[$name])) {
                 // It must be an aliased class name
                 $fqn = $useStatements[$name];
             } else {
                 // Use the namespace of the class
                 $namespace = trim($this->context->getNamespace(), self::NS_SEPARATOR);
                 $fqn = $namespace . self::NS_SEPARATOR . $name;
             }
         }
     }
     return $fqn;
 }
Exemplo n.º 2
0
 /**
  * Test all getters for the values set with the constructor.
  */
 public function testConstructorAccessors()
 {
     $namespace = sha1(microtime(true));
     $useStatements = array(sha1(microtime(true)));
     $class = sha1(microtime(true));
     $location = sha1(microtime(true));
     $context = new AnnotationContext($namespace, $useStatements, $class, $location);
     $this->assertSame($namespace, $context->getNamespace());
     $this->assertSame($useStatements, $context->getUseStatements());
     $this->assertSame($class, $context->getClass());
     $this->assertSame($location, $context->getLocation());
 }