This commit is contained in:
Jaapio
2022-10-28 14:05:33 +02:00
parent 7192e67cfa
commit d6c050a533
16 changed files with 734 additions and 272 deletions
@@ -17,7 +17,11 @@ use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\Param;
use phpDocumentor\Reflection\DocBlock\Tags\See;
use phpDocumentor\Reflection\Types\Array_;
use phpDocumentor\Reflection\Types\Integer;
use phpDocumentor\Reflection\Types\String_;
use PHPUnit\Framework\TestCase;
/**
@@ -83,7 +87,7 @@ DESCRIPTION;
str_replace(
PHP_EOL,
"\n",
$descriptionText
$descriptionText
),
$description->render()
);
@@ -134,7 +138,7 @@ DESCRIPTION;
str_replace(
PHP_EOL,
"\n",
<<<'DESCRIPTION'
<<<'DESCRIPTION'
You can escape the @-sign by surrounding it with braces, for example: @. And escape a closing brace within an
inline tag by adding an opening brace in front of it like this: }.
@@ -149,4 +153,36 @@ DESCRIPTION
$foundDescription
);
}
public function testMultilineTags(): void
{
$docCommment = <<<DOC
/**
* This is an example of a summary.
*
* @param array<
* int,
* string
* > \$store
*/
DOC;
$factory = DocBlockFactory::createInstance();
$docblock = $factory->create($docCommment);
self::assertEquals(
[
new Param(
'store',
new Array_(
new String_(),
new Integer()
),
false,
new Description(''),
),
],
$docblock->getTags()
);
}
}
@@ -1,61 +0,0 @@
<?php
/*
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link http://phpdoc.org
*
*/
declare(strict_types=1);
namespace phpDocumentor\Reflection;
use phpDocumentor\Reflection\DocBlock\Description;
use phpDocumentor\Reflection\DocBlock\Tags\Param;
use phpDocumentor\Reflection\DocBlock\Tags\Return_;
use phpDocumentor\Reflection\PseudoTypes\ArrayShape;
use phpDocumentor\Reflection\PseudoTypes\ArrayShapeItem;
use phpDocumentor\Reflection\Types\Context;
use phpDocumentor\Reflection\Types\String_;
use PHPUnit\Framework\TestCase;
class PhpStanDocblockFactoryTest extends TestCase
{
public function testDocblockIsParsed()
{
$docblock = new DocBlock(
'test summary',
new Description(
"This description contains tags \n And is multiline"
),
[
new Param('firstParam', new String_(), false, new Description('Some description'), false),
new Return_(new ArrayShape(new ArrayShapeItem('foo', new String_(), false)))
]
);
$string = <<<DOC
/**
* test summary
*
* THis description contains tags {@see https://phpdoc.org with a description}
* And is multi line
*
* @param string \$firstParam Some description
* @return array{foo: string}
*/
DOC;
$factory = PhpStanDocblockFactory::createInstance();
$actual = $factory->create(
$string,
new Context('/')
);
self::assertEquals($docblock, $actual);
}
}