mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
Remove deprecated code paths
Typed tags are no longer creatable via the create method. The parsing has become to complex to handle per tag. This logic has been moved into factories.
This commit is contained in:
@@ -22,7 +22,6 @@ use phpDocumentor\Reflection\PseudoTypes\IntegerValue;
|
||||
use phpDocumentor\Reflection\PseudoTypes\StringValue;
|
||||
use phpDocumentor\Reflection\Types\Compound;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use phpDocumentor\Reflection\Types\Integer;
|
||||
use phpDocumentor\Reflection\Types\Mixed_;
|
||||
use phpDocumentor\Reflection\Types\Object_;
|
||||
use phpDocumentor\Reflection\Types\String_;
|
||||
@@ -84,16 +83,6 @@ final class ParamFactoryTest extends TagFactoryTestCase
|
||||
false
|
||||
),
|
||||
],
|
||||
[
|
||||
'@param int My Description',
|
||||
new Param(
|
||||
null,
|
||||
new Integer(),
|
||||
false,
|
||||
new Description('My Description'),
|
||||
false
|
||||
),
|
||||
],
|
||||
[
|
||||
'@param \'GET\'|SomeClass $arg My Description',
|
||||
new Param(
|
||||
|
||||
@@ -15,12 +15,6 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||
use phpDocumentor\Reflection\FqsenResolver;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use phpDocumentor\Reflection\Types\Integer;
|
||||
use phpDocumentor\Reflection\Types\String_;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -159,273 +153,4 @@ class ParamTest extends TestCase
|
||||
|
||||
$this->assertSame('string ...$myParameter Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethod(): void
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$context = new Context('');
|
||||
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = Param::create('string $myParameter My Description', $typeResolver, $descriptionFactory, $context);
|
||||
|
||||
$this->assertSame('string $myParameter My Description', (string) $fixture);
|
||||
$this->assertSame('myParameter', $fixture->getVariableName());
|
||||
$this->assertInstanceOf(String_::class, $fixture->getType());
|
||||
$this->assertFalse($fixture->isVariadic());
|
||||
$this->assertFalse($fixture->isReference());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodWithVariadic(): void
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$context = new Context('');
|
||||
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = Param::create('string ...$myParameter My Description', $typeResolver, $descriptionFactory, $context);
|
||||
|
||||
$this->assertSame('string ...$myParameter My Description', (string) $fixture);
|
||||
$this->assertSame('myParameter', $fixture->getVariableName());
|
||||
$this->assertInstanceOf(String_::class, $fixture->getType());
|
||||
$this->assertTrue($fixture->isVariadic());
|
||||
$this->assertFalse($fixture->isReference());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodWithReference(): void
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$context = new Context('');
|
||||
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = Param::create('string &$myParameter My Description', $typeResolver, $descriptionFactory, $context);
|
||||
|
||||
$this->assertSame('string &$myParameter My Description', (string) $fixture);
|
||||
$this->assertSame('myParameter', $fixture->getVariableName());
|
||||
$this->assertInstanceOf(String_::class, $fixture->getType());
|
||||
$this->assertFalse($fixture->isVariadic());
|
||||
$this->assertTrue($fixture->isReference());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodWithVariadicReference(): void
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$context = new Context('');
|
||||
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = Param::create(
|
||||
'string &...$myParameter My Description',
|
||||
$typeResolver,
|
||||
$descriptionFactory,
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame('string &...$myParameter My Description', (string) $fixture);
|
||||
$this->assertSame('myParameter', $fixture->getVariableName());
|
||||
$this->assertInstanceOf(String_::class, $fixture->getType());
|
||||
$this->assertTrue($fixture->isVariadic());
|
||||
$this->assertTrue($fixture->isReference());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodWithReferenceWithoutType(): void
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$fqsenResolver = new FqsenResolver();
|
||||
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||
$context = new Context('');
|
||||
|
||||
$fixture = Param::create(
|
||||
'&$myParameter My Description',
|
||||
$typeResolver,
|
||||
$descriptionFactory,
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame('&$myParameter My Description', (string) $fixture);
|
||||
$this->assertSame('myParameter', $fixture->getVariableName());
|
||||
$this->assertNull($fixture->getType());
|
||||
$this->assertFalse($fixture->isVariadic());
|
||||
$this->assertTrue($fixture->isReference());
|
||||
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodWithVariadicReferenceWithoutType(): void
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$fqsenResolver = new FqsenResolver();
|
||||
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||
$context = new Context('');
|
||||
|
||||
$fixture = Param::create(
|
||||
'&...$myParameter My Description',
|
||||
$typeResolver,
|
||||
$descriptionFactory,
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame('&...$myParameter My Description', (string) $fixture);
|
||||
$this->assertSame('myParameter', $fixture->getVariableName());
|
||||
$this->assertNull($fixture->getType());
|
||||
$this->assertTrue($fixture->isVariadic());
|
||||
$this->assertTrue($fixture->isReference());
|
||||
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodWithoutType(): void
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$fqsenResolver = new FqsenResolver();
|
||||
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||
$context = new Context('');
|
||||
|
||||
$fixture = Param::create(
|
||||
'$myParameter My Description',
|
||||
$typeResolver,
|
||||
$descriptionFactory,
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame('$myParameter My Description', (string) $fixture);
|
||||
$this->assertSame('myParameter', $fixture->getVariableName());
|
||||
$this->assertNull($fixture->getType());
|
||||
$this->assertFalse($fixture->isVariadic());
|
||||
$this->assertFalse($fixture->isReference());
|
||||
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodWithType(): void
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$fqsenResolver = new FqsenResolver();
|
||||
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||
$context = new Context('');
|
||||
|
||||
$fixture = Param::create(
|
||||
'int My Description',
|
||||
$typeResolver,
|
||||
$descriptionFactory,
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame('int My Description', (string) $fixture);
|
||||
$this->assertSame('', $fixture->getVariableName());
|
||||
$this->assertInstanceOf(Integer::class, $fixture->getType());
|
||||
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodFailsIfEmptyBodyIsGiven(): void
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
Param::create('', new TypeResolver(), $descriptionFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodFailsIfResolverIsNull(): void
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
Param::create('body');
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodFailsIfDescriptionFactoryIsNull(): void
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
Param::create('body', new TypeResolver());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,6 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||
use phpDocumentor\Reflection\FqsenResolver;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use phpDocumentor\Reflection\Types\Integer;
|
||||
use phpDocumentor\Reflection\Types\String_;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -141,126 +135,4 @@ class PropertyReadTest extends TestCase
|
||||
|
||||
$this->assertSame('string $myProperty Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyRead::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethod(): void
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$context = new Context('');
|
||||
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = PropertyRead::create(
|
||||
'string $myProperty My Description',
|
||||
$typeResolver,
|
||||
$descriptionFactory,
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame('string $myProperty My Description', (string) $fixture);
|
||||
$this->assertSame('myProperty', $fixture->getVariableName());
|
||||
$this->assertInstanceOf(String_::class, $fixture->getType());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodWithoutType(): void
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$fqsenResolver = new FqsenResolver();
|
||||
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||
$context = new Context('');
|
||||
|
||||
$fixture = PropertyRead::create(
|
||||
'$myParameter My Description',
|
||||
$typeResolver,
|
||||
$descriptionFactory,
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame('$myParameter My Description', (string) $fixture);
|
||||
$this->assertSame('myParameter', $fixture->getVariableName());
|
||||
$this->assertNull($fixture->getType());
|
||||
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodWithType(): void
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$fqsenResolver = new FqsenResolver();
|
||||
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||
$context = new Context('');
|
||||
|
||||
$fixture = PropertyRead::create(
|
||||
'int My Description',
|
||||
$typeResolver,
|
||||
$descriptionFactory,
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame('int My Description', (string) $fixture);
|
||||
$this->assertSame('', $fixture->getVariableName());
|
||||
$this->assertInstanceOf(Integer::class, $fixture->getType());
|
||||
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyRead::<public>
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodFailsIfEmptyBodyIsGiven(): void
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
PropertyRead::create('', new TypeResolver(), $descriptionFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodFailsIfResolverIsNull(): void
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
PropertyRead::create('body');
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodFailsIfDescriptionFactoryIsNull(): void
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
PropertyRead::create('body', new TypeResolver());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,6 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||
use phpDocumentor\Reflection\FqsenResolver;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use phpDocumentor\Reflection\Types\Integer;
|
||||
use phpDocumentor\Reflection\Types\String_;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -141,121 +135,4 @@ class PropertyTest extends TestCase
|
||||
|
||||
$this->assertSame('string $myProperty Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Property::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethod(): void
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$context = new Context('');
|
||||
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = Property::create('string $myProperty My Description', $typeResolver, $descriptionFactory, $context);
|
||||
|
||||
$this->assertSame('string $myProperty My Description', (string) $fixture);
|
||||
$this->assertSame('myProperty', $fixture->getVariableName());
|
||||
$this->assertInstanceOf(String_::class, $fixture->getType());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodWithoutType(): void
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$fqsenResolver = new FqsenResolver();
|
||||
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||
$context = new Context('');
|
||||
|
||||
$fixture = Property::create(
|
||||
'$myParameter My Description',
|
||||
$typeResolver,
|
||||
$descriptionFactory,
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame('$myParameter My Description', (string) $fixture);
|
||||
$this->assertSame('myParameter', $fixture->getVariableName());
|
||||
$this->assertNull($fixture->getType());
|
||||
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodWithType(): void
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$fqsenResolver = new FqsenResolver();
|
||||
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||
$context = new Context('');
|
||||
|
||||
$fixture = Property::create(
|
||||
'int My Description',
|
||||
$typeResolver,
|
||||
$descriptionFactory,
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame('int My Description', (string) $fixture);
|
||||
$this->assertSame('', $fixture->getVariableName());
|
||||
$this->assertInstanceOf(Integer::class, $fixture->getType());
|
||||
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Property::<public>
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodFailsIfEmptyBodyIsGiven(): void
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
Property::create('', new TypeResolver(), $descriptionFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodFailsIfResolverIsNull(): void
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
Property::create('body');
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodFailsIfDescriptionFactoryIsNull(): void
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
Property::create('body', new TypeResolver());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,6 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||
use phpDocumentor\Reflection\FqsenResolver;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use phpDocumentor\Reflection\Types\Integer;
|
||||
use phpDocumentor\Reflection\Types\String_;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -141,126 +135,4 @@ class PropertyWriteTest extends TestCase
|
||||
|
||||
$this->assertSame('string $myProperty Description', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethod(): void
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$context = new Context('');
|
||||
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = PropertyWrite::create(
|
||||
'string $myProperty My Description',
|
||||
$typeResolver,
|
||||
$descriptionFactory,
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame('string $myProperty My Description', (string) $fixture);
|
||||
$this->assertSame('myProperty', $fixture->getVariableName());
|
||||
$this->assertInstanceOf(String_::class, $fixture->getType());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodWithoutType(): void
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$fqsenResolver = new FqsenResolver();
|
||||
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||
$context = new Context('');
|
||||
|
||||
$fixture = PropertyWrite::create(
|
||||
'$myParameter My Description',
|
||||
$typeResolver,
|
||||
$descriptionFactory,
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame('$myParameter My Description', (string) $fixture);
|
||||
$this->assertSame('myParameter', $fixture->getVariableName());
|
||||
$this->assertNull($fixture->getType());
|
||||
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodWithType(): void
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$fqsenResolver = new FqsenResolver();
|
||||
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||
$context = new Context('');
|
||||
|
||||
$fixture = PropertyWrite::create(
|
||||
'int My Description',
|
||||
$typeResolver,
|
||||
$descriptionFactory,
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame('int My Description', (string) $fixture);
|
||||
$this->assertSame('', $fixture->getVariableName());
|
||||
$this->assertInstanceOf(Integer::class, $fixture->getType());
|
||||
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite::<public>
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodFailsIfEmptyBodyIsGiven(): void
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
PropertyWrite::create('', new TypeResolver(), $descriptionFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodFailsIfResolverIsNull(): void
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
PropertyWrite::create('body');
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodFailsIfDescriptionFactoryIsNull(): void
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
PropertyWrite::create('body', new TypeResolver());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use phpDocumentor\Reflection\Types\String_;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -140,152 +136,4 @@ class ReturnTest extends TestCase
|
||||
|
||||
$this->assertSame('string', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Return_::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\String_
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethod(): void
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$resolver = new TypeResolver();
|
||||
$context = new Context('');
|
||||
|
||||
$type = new String_();
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = Return_::create('string My Description', $resolver, $descriptionFactory, $context);
|
||||
|
||||
$this->assertSame('string My Description', (string) $fixture);
|
||||
$this->assertEquals($type, $fixture->getType());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test checks whether a braces in a Type are allowed.
|
||||
*
|
||||
* The advent of generics poses a few issues, one of them is that spaces can now be part of a type. In the past we
|
||||
* could purely rely on spaces to split the individual parts of the body of a tag; but when there is a type in play
|
||||
* we now need to check for braces.
|
||||
*
|
||||
* This test tests whether an error occurs demonstrating that the braces were taken into account; this test is still
|
||||
* expected to produce an exception because the TypeResolver does not support generics.
|
||||
*
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Return_::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\String_
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodWithGenericWithSpace(): void
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$resolver = new TypeResolver();
|
||||
$context = new Context('');
|
||||
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')
|
||||
->with('My Description', $context)
|
||||
->andReturn($description);
|
||||
|
||||
$fixture = Return_::create('array<string, string> My Description', $resolver, $descriptionFactory, $context);
|
||||
|
||||
$this->assertSame('array<string, string> My Description', (string) $fixture);
|
||||
$this->assertEquals('array<string, string>', $fixture->getType());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see self::testFactoryMethodWithGenericWithSpace()
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Return_::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\String_
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodWithGenericWithSpaceAndAddedEmojisToVerifyMultiByteBehaviour(): void
|
||||
{
|
||||
$this->markTestSkipped('A bug in the TypeResolver breaks this test');
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('"\array😁<string,😁 😁string>" is not a valid Fqsen.');
|
||||
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$resolver = new TypeResolver();
|
||||
$context = new Context('');
|
||||
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')
|
||||
->with('My Description', $context)
|
||||
->andReturn($description);
|
||||
|
||||
Return_::create('array😁<string,😁 😁string> My Description', $resolver, $descriptionFactory, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Return_::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\String_
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodWithEmojisToVerifyMultiByteBehaviour(): void
|
||||
{
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$resolver = new TypeResolver();
|
||||
$context = new Context('');
|
||||
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')
|
||||
->with('My Description', $context)
|
||||
->andReturn($description);
|
||||
|
||||
$fixture = Return_::create('\My😁Class My Description', $resolver, $descriptionFactory, $context);
|
||||
|
||||
$this->assertSame('\My😁Class My Description', (string) $fixture);
|
||||
$this->assertEquals('\My😁Class', $fixture->getType());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodFailsIfBodyIsNotEmpty(): void
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->assertNull(Return_::create(''));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodFailsIfResolverIsNull(): void
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
Return_::create('body');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodFailsIfDescriptionFactoryIsNull(): void
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
Return_::create('body', new TypeResolver());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,6 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||
use phpDocumentor\Reflection\FqsenResolver;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use phpDocumentor\Reflection\Types\Integer;
|
||||
use phpDocumentor\Reflection\Types\String_;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -179,150 +173,4 @@ class VarTest extends TestCase
|
||||
|
||||
$this->assertSame('string $myVariable', (string) $fixture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethod(): void
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$context = new Context('');
|
||||
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = Var_::create('string $myVariable My Description', $typeResolver, $descriptionFactory, $context);
|
||||
|
||||
$this->assertSame('string $myVariable My Description', (string) $fixture);
|
||||
$this->assertSame('myVariable', $fixture->getVariableName());
|
||||
$this->assertInstanceOf(String_::class, $fixture->getType());
|
||||
$this->assertSame($description, $fixture->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodWithoutType(): void
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$fqsenResolver = new FqsenResolver();
|
||||
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||
$context = new Context('');
|
||||
|
||||
$fixture = Var_::create(
|
||||
'$myParameter My Description',
|
||||
$typeResolver,
|
||||
$descriptionFactory,
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame('$myParameter My Description', (string) $fixture);
|
||||
$this->assertSame('myParameter', $fixture->getVariableName());
|
||||
$this->assertNull($fixture->getType());
|
||||
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodWithType(): void
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$fqsenResolver = new FqsenResolver();
|
||||
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||
$context = new Context('');
|
||||
|
||||
$fixture = Var_::create(
|
||||
'int My Description',
|
||||
$typeResolver,
|
||||
$descriptionFactory,
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame('int My Description', (string) $fixture);
|
||||
$this->assertSame('', $fixture->getVariableName());
|
||||
$this->assertInstanceOf(Integer::class, $fixture->getType());
|
||||
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||
* @uses \phpDocumentor\Reflection\Types\Context
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodWithTypeWithoutComment(): void
|
||||
{
|
||||
$typeResolver = new TypeResolver();
|
||||
$fqsenResolver = new FqsenResolver();
|
||||
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||
$context = new Context('');
|
||||
|
||||
$fixture = Var_::create(
|
||||
'int',
|
||||
$typeResolver,
|
||||
$descriptionFactory,
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame('int', (string) $fixture);
|
||||
$this->assertSame('', $fixture->getVariableName());
|
||||
$this->assertInstanceOf(Integer::class, $fixture->getType());
|
||||
$this->assertSame('', $fixture->getDescription() . '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::<public>
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodFailsIfEmptyBodyIsGiven(): void
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
Var_::create('', new TypeResolver(), $descriptionFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodFailsIfResolverIsNull(): void
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
Var_::create('body');
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||
*
|
||||
* @covers ::create
|
||||
*/
|
||||
public function testFactoryMethodFailsIfDescriptionFactoryIsNull(): void
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
Var_::create('body', new TypeResolver());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user