/**
  * @dataProvider getTypeNames()
  * 
  * @param string $typeName
  * @param string $category
  * @return void
  */
 public function testTypeCategorization($typeName, $category)
 {
     switch ($category) {
         case 'scalar':
             self::assertTrue($this->fixture->isScalarType($typeName));
             self::assertFalse($this->fixture->isArray($typeName));
             self::assertFalse($this->fixture->isMixed($typeName));
             break;
         case 'class':
             self::assertfalse($this->fixture->isScalarType($typeName));
             self::assertFalse($this->fixture->isArray($typeName));
             self::assertFalse($this->fixture->isMixed($typeName));
             break;
         case 'array':
             self::assertFalse($this->fixture->isScalarType($typeName));
             self::assertTrue($this->fixture->isArray($typeName));
             self::assertFalse($this->fixture->isMixed($typeName));
             break;
         case 'mixed':
             self::assertFalse($this->fixture->isScalarType($typeName));
             self::assertFalse($this->fixture->isArray($typeName));
             self::assertTrue($this->fixture->isMixed($typeName));
             break;
     }
 }
示例#2
0
 /**
  * @return ezcReflectionTypeMapper
  */
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new ezcReflectionTypeMapper();
     }
     return self::$instance;
 }
 /**
  * Creates a type object for given type name
  * @param string|ReflectionClass $typeName
  * @return ezcReflectionType
  * @todo ArrayAccess stuff, how to handle? has to be implemented
  */
 public function getType($typeName)
 {
     if ($typeName instanceof ReflectionClass) {
         return new ezcReflectionObjectType($typeName);
     }
     $typeName = trim($typeName);
     if (empty($typeName)) {
         return null;
     } elseif ($this->mapper->isScalarType($typeName) or $this->mapper->isSpecialType($typeName)) {
         return new ezcReflectionPrimitiveType($typeName);
     } elseif ($this->mapper->isArray($typeName)) {
         return new ezcReflectionArrayType($typeName);
     } elseif ($this->mapper->isMixed($typeName)) {
         return new ezcReflectionMixedType($typeName);
     } else {
         // otherwhise it has to be a class name
         return new ezcReflectionObjectType($typeName);
     }
 }
示例#4
0
 /**
  * @param string[] $line Array of words
  */
 public function __construct($line)
 {
     $this->annotationName = $line[0];
     if (isset($line[1])) {
         $this->params[0] = ezcReflectionTypeMapper::getInstance()->getTypeName($line[1]);
     }
     if (isset($line[2])) {
         $this->desc = $line[2];
     }
     if (isset($line[3])) {
         $this->desc .= ' ' . $line[3];
     }
 }
示例#5
0
 /**
  * @param string[] $line Array of words
  */
 public function __construct($line)
 {
     $this->annotationName = $line[0];
     if (isset($line[1])) {
         $this->params[0] = ezcReflectionTypeMapper::getInstance()->getTypeName($line[1]);
     }
     if (isset($line[2]) and strlen($line[2]) > 0) {
         if ($line[2][0] == '$') {
             $line[2] = substr($line[2], 1);
         }
         $this->params[1] = $line[2];
     }
     if (isset($line[3])) {
         $this->desc = $line[3];
     }
 }
 /**
  * Returns name of the correspondent XML Schema datatype
  *
  * The prefix `xsd' is comonly used to refer to the
  * XML Schema namespace.
  *
  * @param boolean $usePrefix augments common prefix `xsd:' to the name
  * @return string
  */
 function getXmlName($usePrefix = true)
 {
     if ($usePrefix) {
         $prefix = 'xsd:';
     } else {
         $prefix = '';
     }
     return $prefix . ezcReflectionTypeMapper::getInstance()->getXmlType($this->getTypeName());
 }