/** * All types names should be absolute (include namespace) in the registry. * First '\' will be removed if exists. * Array types (\Some\Type[]) will be converted into simple types (Some\Type). * Simple types names will be converted to it's canonical versions (bool => boolean). * * @param string $type * @return string */ public function normalizeType($type) { $result = $this->_typeProcessor->normalizeType($type); if ($result && $result[0] == '\\') { $result = substr($result, 1); // remove leading slash } if ($this->isArray($result)) { $result = substr($result, 0, -2); // remove '[]' at the end } return $result; }
public function testNormalizeType() { $this->assertEquals('blah', $this->_typeProcessor->normalizeType('blah')); $this->assertEquals('string', $this->_typeProcessor->normalizeType('str')); $this->assertEquals('int', $this->_typeProcessor->normalizeType('integer')); $this->assertEquals('boolean', $this->_typeProcessor->normalizeType('bool')); $this->assertEquals('anyType', $this->_typeProcessor->normalizeType('mixed')); }