Skip to content

Commit 70745c7

Browse files
committed
Bump dependencies
1 parent da1c4e7 commit 70745c7

File tree

9 files changed

+165
-39
lines changed

9 files changed

+165
-39
lines changed

composer.lock

Lines changed: 28 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpcs.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<file>src</file>
66
<file>tests/unit</file>
77
<exclude-pattern>*/tests/unit/Types/ContextFactoryTest.php</exclude-pattern>
8+
<exclude-pattern>*/tests/unit/Assets/*</exclude-pattern>
89
<arg value="p"/>
910

1011
<rule ref="phpDocumentor">

src/DocBlock/StandardTagFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use phpDocumentor\Reflection\DocBlock\Tags\Author;
1818
use phpDocumentor\Reflection\DocBlock\Tags\Covers;
1919
use phpDocumentor\Reflection\DocBlock\Tags\Deprecated;
20-
use phpDocumentor\Reflection\DocBlock\Tags\Factory\StaticMethod;
2120
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
2221
use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag;
2322
use phpDocumentor\Reflection\DocBlock\Tags\Link as LinkTag;
@@ -165,7 +164,7 @@ public function registerTagHandler(string $tagName, string $handler) : void
165164
{
166165
Assert::stringNotEmpty($tagName);
167166
Assert::classExists($handler);
168-
Assert::implementsInterface($handler, StaticMethod::class);
167+
Assert::implementsInterface($handler, Tag::class);
169168

170169
if (strpos($tagName, '\\') && $tagName[0] !== '\\') {
171170
throw new InvalidArgumentException(

src/DocBlock/Tags/Deprecated.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ final class Deprecated extends BaseTag implements Factory\StaticMethod
4848

4949
public function __construct(?string $version = null, ?Description $description = null)
5050
{
51-
Assert::nullOrStringNotEmpty($version);
51+
Assert::nullOrNotEmpty($version);
5252

5353
$this->version = $version;
5454
$this->description = $description;

src/DocBlock/Tags/Since.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ final class Since extends BaseTag implements Factory\StaticMethod
4848

4949
public function __construct(?string $version = null, ?Description $description = null)
5050
{
51-
Assert::nullOrStringNotEmpty($version);
51+
Assert::nullOrNotEmpty($version);
5252

5353
$this->version = $version;
5454
$this->description = $description;

tests/unit/Assets/CustomParam.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace phpDocumentor\Reflection\Assets;
6+
7+
use phpDocumentor\Reflection\DocBlock\Tag;
8+
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
9+
use phpDocumentor\Reflection\FqsenResolver;
10+
use phpDocumentor\Reflection\DocBlock\Tags\Factory\StaticMethod;
11+
12+
final class CustomParam implements Tag, StaticMethod
13+
{
14+
public $myParam;
15+
public $fqsenResolver;
16+
17+
public function getName() : string
18+
{
19+
return 'spy';
20+
}
21+
22+
public static function create($body, FqsenResolver $fqsenResolver = null, ?string $myParam = null)
23+
{
24+
$tag = new self();
25+
$tag->fqsenResolver = $fqsenResolver;
26+
$tag->myParam = $myParam;
27+
28+
return $tag;
29+
}
30+
31+
public function render(?Formatter $formatter = null) : string
32+
{
33+
return $this->getName();
34+
}
35+
36+
public function __toString() : string
37+
{
38+
return $this->getName();
39+
}
40+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace phpDocumentor\Reflection\Assets;
6+
7+
use phpDocumentor\Reflection\DocBlock\Tag;
8+
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
9+
use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter;
10+
use phpDocumentor\Reflection\FqsenResolver;
11+
use phpDocumentor\Reflection\DocBlock\Tags\Factory\StaticMethod;
12+
13+
final class CustomServiceClass implements Tag, StaticMethod
14+
{
15+
public $formatter;
16+
17+
public function getName() : string
18+
{
19+
return 'spy';
20+
}
21+
22+
public static function create($body, PassthroughFormatter $formatter = null)
23+
{
24+
$tag = new self();
25+
$tag->formatter = $formatter;
26+
27+
return $tag;
28+
}
29+
30+
public function render(?Formatter $formatter = null) : string
31+
{
32+
return $this->getName();
33+
}
34+
35+
public function __toString() : string
36+
{
37+
return $this->getName();
38+
}
39+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace phpDocumentor\Reflection\Assets;
6+
7+
use phpDocumentor\Reflection\DocBlock\Tag;
8+
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
9+
use phpDocumentor\Reflection\FqsenResolver;
10+
use phpDocumentor\Reflection\DocBlock\Tags\Factory\StaticMethod;
11+
12+
final class CustomServiceInterface implements Tag, StaticMethod
13+
{
14+
public $formatter;
15+
16+
public function getName() : string
17+
{
18+
return 'spy';
19+
}
20+
21+
public static function create($body, Formatter $formatter = null)
22+
{
23+
$tag = new self();
24+
$tag->formatter = $formatter;
25+
26+
return $tag;
27+
}
28+
29+
public function render(?Formatter $formatter = null) : string
30+
{
31+
return $this->getName();
32+
}
33+
34+
public function __toString() : string
35+
{
36+
return $this->getName();
37+
}
38+
}

tests/unit/DocBlock/StandardTagFactoryTest.php

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515

1616
use InvalidArgumentException;
1717
use Mockery as m;
18+
use phpDocumentor\Reflection\Assets\CustomParam;
19+
use phpDocumentor\Reflection\Assets\CustomServiceClass;
20+
use phpDocumentor\Reflection\Assets\CustomServiceInterface;
1821
use phpDocumentor\Reflection\DocBlock\Tags\Author;
1922
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
2023
use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter;
@@ -169,13 +172,13 @@ public function testAddParameterToServiceLocator() : void
169172
{
170173
$resolver = m::mock(FqsenResolver::class);
171174
$tagFactory = new StandardTagFactory($resolver);
175+
$tagFactory->registerTagHandler('spy', CustomParam::class);
176+
172177
$tagFactory->addParameter('myParam', 'myValue');
178+
$spy = $tagFactory->create('@spy');
173179

174-
$this->assertAttributeSame(
175-
[FqsenResolver::class => $resolver, 'myParam' => 'myValue'],
176-
'serviceLocator',
177-
$tagFactory
178-
);
180+
$this->assertSame($resolver, $spy->fqsenResolver);
181+
$this->assertSame('myValue', $spy->myParam);
179182
}
180183

181184
/**
@@ -190,12 +193,11 @@ public function testAddServiceToServiceLocator() : void
190193
$resolver = m::mock(FqsenResolver::class);
191194
$tagFactory = new StandardTagFactory($resolver);
192195
$tagFactory->addService($service);
196+
$tagFactory->registerTagHandler('spy', CustomServiceClass::class);
193197

194-
$this->assertAttributeSame(
195-
[FqsenResolver::class => $resolver, PassthroughFormatter::class => $service],
196-
'serviceLocator',
197-
$tagFactory
198-
);
198+
$spy = $tagFactory->create('@spy');
199+
200+
$this->assertSame($service, $spy->formatter);
199201
}
200202

201203
/**
@@ -211,12 +213,11 @@ public function testInjectConcreteServiceForInterfaceToServiceLocator() : void
211213
$resolver = m::mock(FqsenResolver::class);
212214
$tagFactory = new StandardTagFactory($resolver);
213215
$tagFactory->addService($service, $interfaceName);
216+
$tagFactory->registerTagHandler('spy', CustomServiceInterface::class);
214217

215-
$this->assertAttributeSame(
216-
[FqsenResolver::class => $resolver, $interfaceName => $service],
217-
'serviceLocator',
218-
$tagFactory
219-
);
218+
$spy = $tagFactory->create('@spy');
219+
220+
$this->assertSame($service, $spy->formatter);
220221
}
221222

222223
/**

0 commit comments

Comments
 (0)