mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
Add typeless parameter support.
This commit is contained in:
@@ -217,6 +217,5 @@ DOC;
|
||||
],
|
||||
$docblock->getTags()
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Param;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use phpDocumentor\Reflection\Types\Integer;
|
||||
use phpDocumentor\Reflection\Types\Mixed_;
|
||||
use phpDocumentor\Reflection\Types\String_;
|
||||
|
||||
final class ParamFactoryTest extends TagFactoryTestCase
|
||||
@@ -24,23 +26,77 @@ final class ParamFactoryTest extends TagFactoryTestCase
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory::create
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory::supports
|
||||
* @dataProvider paramInputProvider
|
||||
*/
|
||||
public function testParamIsCreated(): void
|
||||
public function testParamIsCreated(string $input, Param $expected): void
|
||||
{
|
||||
$ast = $this->parseTag('@param string $var');
|
||||
$ast = $this->parseTag($input);
|
||||
$factory = new ParamFactory($this->giveTypeResolver(), $this->givenDescriptionFactory());
|
||||
$context = new Context('global');
|
||||
|
||||
self::assertTrue($factory->supports($ast, $context));
|
||||
self::assertEquals(
|
||||
new Param(
|
||||
'var',
|
||||
new String_(),
|
||||
false,
|
||||
new Description(''),
|
||||
false
|
||||
),
|
||||
$expected,
|
||||
$factory->create($ast, $context)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<array-key, string|Param>
|
||||
*/
|
||||
public function paramInputProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'@param string $var',
|
||||
new Param(
|
||||
'var',
|
||||
new String_(),
|
||||
false,
|
||||
new Description(''),
|
||||
false
|
||||
),
|
||||
],
|
||||
[
|
||||
'@param $param8 Description 4',
|
||||
new Param(
|
||||
'param8',
|
||||
new Mixed_(),
|
||||
false,
|
||||
new Description('Description 4'),
|
||||
false
|
||||
),
|
||||
],
|
||||
[
|
||||
'@param $param9',
|
||||
new Param(
|
||||
'param9',
|
||||
new Mixed_(),
|
||||
false,
|
||||
new Description(''),
|
||||
false
|
||||
),
|
||||
],
|
||||
[
|
||||
'@param int My Description',
|
||||
new Param(
|
||||
null,
|
||||
new Integer(),
|
||||
false,
|
||||
new Description('My Description'),
|
||||
false
|
||||
),
|
||||
],
|
||||
[
|
||||
'@param foo',
|
||||
new Param(
|
||||
null,
|
||||
new Mixed_(),
|
||||
false,
|
||||
new Description(''),
|
||||
false
|
||||
),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract class TagFactoryTestCase extends TestCase
|
||||
public function givenDescriptionFactory(): DescriptionFactory
|
||||
{
|
||||
$factory = m::mock(DescriptionFactory::class);
|
||||
$factory->shouldReceive('create')->andReturn(new Description(''));
|
||||
$factory->shouldReceive('create')->andReturnUsing(static fn ($args) => new Description($args));
|
||||
|
||||
return $factory;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ final class VarFactoryTest extends TagFactoryTestCase
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\VarFactory::create
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\VarFactory::supports
|
||||
*/
|
||||
public function testParamIsCreated(): void
|
||||
public function testVarIsCreated(): void
|
||||
{
|
||||
$ast = $this->parseTag('@var string $var');
|
||||
$factory = new VarFactory($this->giveTypeResolver(), $this->givenDescriptionFactory());
|
||||
|
||||
Reference in New Issue
Block a user