mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
@@ -59,7 +59,7 @@ final class See extends BaseTag implements Factory\StaticMethod
|
|||||||
$description = isset($parts[1]) ? $descriptionFactory->create($parts[1], $context) : null;
|
$description = isset($parts[1]) ? $descriptionFactory->create($parts[1], $context) : null;
|
||||||
|
|
||||||
// https://tools.ietf.org/html/rfc2396#section-3
|
// https://tools.ietf.org/html/rfc2396#section-3
|
||||||
if (preg_match('/\w:\/\/\w/i', $parts[0])) {
|
if (preg_match('#\w://\w#', $parts[0])) {
|
||||||
return new static(new Url($parts[0]), $description);
|
return new static(new Url($parts[0]), $description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,30 @@ class StandardTagFactoryTest extends TestCase
|
|||||||
$this->assertSame($expectedDescription, $tag->getDescription());
|
$this->assertSame($expectedDescription, $tag->getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
*
|
||||||
|
* @covers ::__construct
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testCreatingAGenericTagWithDescriptionText() : void
|
||||||
|
{
|
||||||
|
$expectedTagName = 'unknown-tag';
|
||||||
|
$expectedDescriptionText = ' foo Bar 123 ';
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$tagFactory = new StandardTagFactory(new FqsenResolver());
|
||||||
|
$tagFactory->addService(new DescriptionFactory($tagFactory), DescriptionFactory::class);
|
||||||
|
|
||||||
|
$tag = $tagFactory->create('@' . $expectedTagName . $expectedDescriptionText, $context);
|
||||||
|
|
||||||
|
$this->assertInstanceOf(Generic::class, $tag);
|
||||||
|
$this->assertSame('foo Bar 123', $tag . '');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author
|
||||||
@@ -146,6 +170,90 @@ class StandardTagFactoryTest extends TestCase
|
|||||||
$this->assertSame('author', $tag->getName());
|
$this->assertSame('author', $tag->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||||
|
*
|
||||||
|
* @covers ::__construct
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testPassingYourOwnSetOfTagHandlersWithGermanChars() : void
|
||||||
|
{
|
||||||
|
$typeResolver = new TypeResolver();
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$tagFactory = new StandardTagFactory(
|
||||||
|
$fqsenResolver,
|
||||||
|
['my-täg' => Author::class]
|
||||||
|
);
|
||||||
|
|
||||||
|
$tag = $tagFactory->create('@my-täg foo bar ', $context);
|
||||||
|
|
||||||
|
$this->assertInstanceOf(Author::class, $tag);
|
||||||
|
$this->assertSame('author', $tag->getName());
|
||||||
|
$this->assertSame('foo bar', $tag . '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||||
|
*
|
||||||
|
* @covers ::__construct
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testPassingYourOwnSetOfTagHandlersWithoutComment() : void
|
||||||
|
{
|
||||||
|
$typeResolver = new TypeResolver();
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$tagFactory = new StandardTagFactory(
|
||||||
|
$fqsenResolver,
|
||||||
|
['my-täg' => Author::class]
|
||||||
|
);
|
||||||
|
|
||||||
|
$tag = $tagFactory->create('@my-täg', $context);
|
||||||
|
|
||||||
|
$this->assertInstanceOf(Author::class, $tag);
|
||||||
|
$this->assertSame('author', $tag->getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||||
|
*
|
||||||
|
* @covers ::__construct
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testPassingYourOwnSetOfTagHandlersWithEmptyComment() : void
|
||||||
|
{
|
||||||
|
$this->expectException('InvalidArgumentException');
|
||||||
|
$this->expectExceptionMessage(
|
||||||
|
'The tag "@my-täg " does not seem to be wellformed, please check it for errors'
|
||||||
|
);
|
||||||
|
|
||||||
|
$typeResolver = new TypeResolver();
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$tagFactory = new StandardTagFactory(
|
||||||
|
$fqsenResolver,
|
||||||
|
['my-täg' => Author::class]
|
||||||
|
);
|
||||||
|
|
||||||
|
$tag = $tagFactory->create('@my-täg ', $context);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
|
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
|
|||||||
use Mockery as m;
|
use Mockery as m;
|
||||||
use phpDocumentor\Reflection\DocBlock\Description;
|
use phpDocumentor\Reflection\DocBlock\Description;
|
||||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||||
use phpDocumentor\Reflection\Fqsen;
|
use phpDocumentor\Reflection\Fqsen;
|
||||||
use phpDocumentor\Reflection\FqsenResolver;
|
use phpDocumentor\Reflection\FqsenResolver;
|
||||||
use phpDocumentor\Reflection\Types\Context;
|
use phpDocumentor\Reflection\Types\Context;
|
||||||
@@ -174,6 +175,35 @@ class CoversTest extends TestCase
|
|||||||
$this->assertSame('\DateTime', (string) $fixture);
|
$this->assertSame('\DateTime', (string) $fixture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
* @uses \phpDocumentor\Reflection\FqsenResolver
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Url
|
||||||
|
* @uses \phpDocumentor\Reflection\Types\Context
|
||||||
|
*
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testFactoryMethodWithSpaceBeforeClass() : void
|
||||||
|
{
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$fixture = Covers::create(
|
||||||
|
'Foo My Description ',
|
||||||
|
$descriptionFactory,
|
||||||
|
$fqsenResolver,
|
||||||
|
$context
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame('\Foo My Description ', (string) $fixture);
|
||||||
|
$this->assertSame('\Foo', (string) $fixture->getReference());
|
||||||
|
$this->assertSame('My Description ', $fixture->getDescription() . '');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::__construct
|
* @covers ::__construct
|
||||||
* @covers ::__toString
|
* @covers ::__toString
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
|
|||||||
use Mockery as m;
|
use Mockery as m;
|
||||||
use phpDocumentor\Reflection\DocBlock\Description;
|
use phpDocumentor\Reflection\DocBlock\Description;
|
||||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||||
|
use phpDocumentor\Reflection\FqsenResolver;
|
||||||
use phpDocumentor\Reflection\Types\Context;
|
use phpDocumentor\Reflection\Types\Context;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
@@ -163,6 +165,60 @@ class LinkTest extends TestCase
|
|||||||
$this->assertSame($description, $fixture->getDescription());
|
$this->assertSame($description, $fixture->getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
* @uses \phpDocumentor\Reflection\FqsenResolver
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Url
|
||||||
|
* @uses \phpDocumentor\Reflection\Types\Context
|
||||||
|
*
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testFactoryMethodWithoutSpaceBeforeUrl() : void
|
||||||
|
{
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$fixture = Link::create(
|
||||||
|
'http://this.is.my/link My Description ',
|
||||||
|
$descriptionFactory,
|
||||||
|
$context
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame('http://this.is.my/link My Description ', (string) $fixture);
|
||||||
|
$this->assertSame('My Description ', $fixture->getDescription() . '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
* @uses \phpDocumentor\Reflection\FqsenResolver
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Url
|
||||||
|
* @uses \phpDocumentor\Reflection\Types\Context
|
||||||
|
*
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testFactoryMethodWithSpaceBeforeUrl() : void
|
||||||
|
{
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$fixture = Link::create(
|
||||||
|
' http://this.is.my/link My Description ',
|
||||||
|
$descriptionFactory,
|
||||||
|
$context
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame('http://this.is.my/link My Description ', (string) $fixture);
|
||||||
|
$this->assertSame('http://this.is.my/link My Description ', $fixture->getDescription() . '');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Link::<public>
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Link::<public>
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
|
|||||||
use Mockery as m;
|
use Mockery as m;
|
||||||
use phpDocumentor\Reflection\DocBlock\Description;
|
use phpDocumentor\Reflection\DocBlock\Description;
|
||||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen as FqsenRef;
|
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen as FqsenRef;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen as TagsFqsen;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Url as UrlRef;
|
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Url as UrlRef;
|
||||||
use phpDocumentor\Reflection\Fqsen;
|
use phpDocumentor\Reflection\Fqsen;
|
||||||
use phpDocumentor\Reflection\FqsenResolver;
|
use phpDocumentor\Reflection\FqsenResolver;
|
||||||
@@ -251,6 +253,36 @@ class SeeTest extends TestCase
|
|||||||
$this->assertSame($description, $fixture->getDescription());
|
$this->assertSame($description, $fixture->getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
* @uses \phpDocumentor\Reflection\FqsenResolver
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Url
|
||||||
|
* @uses \phpDocumentor\Reflection\Types\Context
|
||||||
|
*
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testFactoryMethodWithoutUrl() : void
|
||||||
|
{
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$fixture = See::create(
|
||||||
|
'Foo My Description ',
|
||||||
|
$fqsenResolver,
|
||||||
|
$descriptionFactory,
|
||||||
|
$context
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame('\Foo My Description ', (string) $fixture);
|
||||||
|
$this->assertInstanceOf(TagsFqsen::class, $fixture->getReference());
|
||||||
|
$this->assertSame('\Foo', (string) $fixture->getReference());
|
||||||
|
$this->assertSame('My Description ', $fixture->getDescription() . '');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::create
|
* @covers ::create
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
|
|||||||
use Mockery as m;
|
use Mockery as m;
|
||||||
use phpDocumentor\Reflection\DocBlock\Description;
|
use phpDocumentor\Reflection\DocBlock\Description;
|
||||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||||
use phpDocumentor\Reflection\Fqsen;
|
use phpDocumentor\Reflection\Fqsen;
|
||||||
use phpDocumentor\Reflection\FqsenResolver;
|
use phpDocumentor\Reflection\FqsenResolver;
|
||||||
use phpDocumentor\Reflection\Types\Context;
|
use phpDocumentor\Reflection\Types\Context;
|
||||||
@@ -129,6 +130,12 @@ class UsesTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||||
{
|
{
|
||||||
|
$fixture = new Uses(new Fqsen('\\'));
|
||||||
|
|
||||||
|
$this->assertSame('\\', (string) $fixture);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
$fixture = new Uses(new Fqsen('\DateTime'));
|
$fixture = new Uses(new Fqsen('\DateTime'));
|
||||||
|
|
||||||
$this->assertSame('\DateTime', (string) $fixture);
|
$this->assertSame('\DateTime', (string) $fixture);
|
||||||
@@ -170,6 +177,66 @@ class UsesTest extends TestCase
|
|||||||
$this->assertSame($description, $fixture->getDescription());
|
$this->assertSame($description, $fixture->getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
* @uses \phpDocumentor\Reflection\FqsenResolver
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Url
|
||||||
|
* @uses \phpDocumentor\Reflection\Types\Context
|
||||||
|
*
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testFactoryMethodWithoutSpaceBeforeClass() : void
|
||||||
|
{
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$fixture = Uses::create(
|
||||||
|
'Foo My Description ',
|
||||||
|
$fqsenResolver,
|
||||||
|
$descriptionFactory,
|
||||||
|
$context
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame('\Foo My Description ', (string) $fixture);
|
||||||
|
$this->assertInstanceOf(Fqsen::class, $fixture->getReference());
|
||||||
|
$this->assertSame('\\Foo', (string) $fixture->getReference());
|
||||||
|
$this->assertSame('My Description ', $fixture->getDescription() . '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
* @uses \phpDocumentor\Reflection\FqsenResolver
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Url
|
||||||
|
* @uses \phpDocumentor\Reflection\Types\Context
|
||||||
|
*
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testFactoryMethodWithSpaceBeforeClass() : void
|
||||||
|
{
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$fixture = Uses::create(
|
||||||
|
' Foo My Description ',
|
||||||
|
$fqsenResolver,
|
||||||
|
$descriptionFactory,
|
||||||
|
$context
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame('\ Foo My Description ', (string) $fixture);
|
||||||
|
$this->assertInstanceOf(Fqsen::class, $fixture->getReference());
|
||||||
|
$this->assertSame('\\', (string) $fixture->getReference());
|
||||||
|
$this->assertSame('Foo My Description ', $fixture->getDescription() . '');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::create
|
* @covers ::create
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user