示例#1
0
文件: Header.php 项目: Nycto/phpVocab
 /**
  * Parse a class from token reader
  *
  * @param \vc\Tokens\Access $access The token access
  * @return \vc\Data\Routine\Func
  */
 public function parseClass(\vc\Tokens\Access $access)
 {
     $token = $access->findRequired(array(Token::T_CLASS, Token::T_ABSTRACT));
     $class = new \vc\Data\Type\Cls($token->getLine(), $access->getComment());
     // Extract the abstract flag from the class definition
     if ($token->is(Token::T_ABSTRACT)) {
         $class->setAbstract(TRUE);
         $access->findRequired(array(Token::T_CLASS));
     }
     // Searches for the name of the class
     $token = $access->findRequired(array(Token::T_STRING));
     // Set the name of the class
     $class->setName($token->getContent());
     // Look for parent classes and interfaces
     $token = $access->findRequired(array(Token::T_EXTENDS, Token::T_IMPLEMENTS, Token::T_CURLY_OPEN));
     // Add the parent class
     if ($token->is(Token::T_EXTENDS)) {
         $class->setExtends($this->path->parsePath($access));
         // Look for any interfaces
         $token = $access->findRequired(array(Token::T_IMPLEMENTS, Token::T_CURLY_OPEN));
     }
     // Add any interface implementations
     if ($token->is(Token::T_IMPLEMENTS)) {
         $class->setIFaces($this->pathList->parsePathList($access));
         $access->findRequired(array(Token::T_CURLY_OPEN));
     }
     // Finally, parse out the content of the class
     $this->members->parseMembers($class, $access);
     return $class;
 }
示例#2
0
文件: Cls.php 项目: Nycto/phpVocab
 public function testPropertiesAccess()
 {
     $cls = new \vc\Data\Type\Cls(123);
     $this->assertSame(array(), $cls->getProperties());
     $prop1 = new \vc\Data\Property(1);
     $this->assertSame($cls, $cls->addProperty($prop1));
     $this->assertSame(array($prop1), $cls->getProperties());
     $prop2 = new \vc\Data\Property(1);
     $this->assertSame($cls, $cls->addProperty($prop2));
     $this->assertSame(array($prop1, $prop2), $cls->getProperties());
 }