/** * Constructor. * * @param string $docBlock * @return void * @throws \Tbs\DocBlock\Collection\Exception */ public function __construct($docBlock) { if (!strlen($docBlock)) { $message = 'DocBlock cannot be blank.'; throw new \Tbs\DocBlock\Collection\Exception($message); } $parsed = Parser::getParsed($docBlock); $this->shortDescription = $parsed['shortDescription']; $this->longDescription = $parsed['longDescription']; $this->tags = $parsed['tags']; }
/** * @see \Tbs\DocBlock\Collection::export() */ public function test__toString() { $docBlock = $this->object->__toString(); $rs = \Tbs\DocBlock\Parser::getParsed($docBlock); $this->assertInternalType('array', $rs); $this->assertEquals(3, count($rs)); $this->assertArrayHasKey('shortDescription', $rs); $this->assertArrayHasKey('longDescription', $rs); $this->assertArrayHasKey('tags', $rs); $tags = $rs['tags']; $this->assertInternalType('array', $tags); $this->assertEquals(2, count($tags)); $this->assertArrayHasKey('param', $tags); $this->assertArrayHasKey('return', $tags); foreach ($tags as $tag) { $this->assertInstanceOf('\\Tbs\\DocBlock\\Collection\\Parsed', $tag[0]); } }
/** * @see \Tbs\DocBlock\Parser::getParsed() */ public function testGetParsedCustomTags() { $docBlock = ' /** * This is an short description. * * This is an long description. * * @param string $first description of the param * @param string $seccond * * @return array This is a return of method * @customTag ThisIsACustomTagValue */ '; $rs = P::getParsed($docBlock); $this->validateReturn($rs); $this->validateShortDescrption($rs); $this->validateLongDescrption($rs); $tags = $rs['tags']; $this->assertInternalType('array', $tags); $this->assertEquals(3, count($tags)); $this->assertArrayHasKey('param', $tags); $this->validateParamTag($tags['param']); $this->assertArrayHasKey('return', $tags); $this->validateReturnTag($tags['return']); $this->assertArrayHasKey('customTag', $tags); $this->validateCustomTag($tags['customTag']); }