public function testSetReflectionTypeFactory() { $factory = new ezcReflectionTypeFactoryImpl(); ezcReflection::setReflectionTypeFactory($factory); self::assertEquals($factory, ezcReflection::getReflectionTypeFactory()); }
public function testGetVarAnnotations() { $comment = <<<EOF /** * @var string */ EOF; $parser = ezcReflection::getDocCommentParser(); $parser->parse($comment); $annotations = $parser->getVarAnnotations(); self::assertEquals(1, count($annotations)); self::assertType('ezcReflectionAnnotationVar', $annotations[0]); self::assertEquals('string', $annotations[0]->getTypeName()); self::assertEquals('', $annotations[0]->getDescription()); $comment = <<<EOF /** * @var bool[] An array of * boolean values. */ EOF; $parser = ezcReflection::getDocCommentParser(); $parser->parse($comment); $annotations = $parser->getVarAnnotations(); self::assertEquals(1, count($annotations)); self::assertType('ezcReflectionAnnotationVar', $annotations[0]); self::assertEquals("An array of\nboolean values.", $annotations[0]->getDescription()); self::assertEquals('bool[]', $annotations[0]->getTypeName()); $type = ezcReflection::getReflectionTypeFactory()->getType($annotations[0]->getTypeName()); self::assertType('ezcReflectionArrayType', $type); self::assertTrue($type->isArray()); $arrayType = $type->getValueType(); self::assertType('ezcReflectionPrimitiveType', $arrayType); self::assertTrue($arrayType->isPrimitive()); self::assertTrue($arrayType->isScalarType()); self::assertEquals('boolean', $arrayType->getTypeName()); }