|
11 | 11 |
|
12 | 12 | namespace Symfony\Component\PropertyInfo\Tests\Extractor;
|
13 | 13 |
|
| 14 | +use phpDocumentor\Reflection\DocBlock\StandardTagFactory; |
| 15 | +use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag; |
14 | 16 | use phpDocumentor\Reflection\Types\Collection;
|
15 | 17 | use PHPUnit\Framework\TestCase;
|
16 | 18 | use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
|
@@ -46,6 +48,26 @@ public function testParamTagTypeIsOmitted()
|
46 | 48 | $this->assertNull($this->extractor->getTypes(OmittedParamTagTypeDocBlock::class, 'omittedType'));
|
47 | 49 | }
|
48 | 50 |
|
| 51 | + public function invalidTypesProvider() |
| 52 | + { |
| 53 | + return [ |
| 54 | + 'pub' => ['pub', null, null], |
| 55 | + 'stat' => ['stat', null, null], |
| 56 | + 'foo' => ['foo', $this->isPhpDocumentorV5() ? 'Foo.' : null, null], |
| 57 | + 'bar' => ['bar', $this->isPhpDocumentorV5() ? 'Bar.' : null, null], |
| 58 | + ]; |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * @dataProvider invalidTypesProvider |
| 63 | + */ |
| 64 | + public function testInvalid($property, $shortDescription, $longDescription) |
| 65 | + { |
| 66 | + $this->assertNull($this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\InvalidDummy', $property)); |
| 67 | + $this->assertSame($shortDescription, $this->extractor->getShortDescription('Symfony\Component\PropertyInfo\Tests\Fixtures\InvalidDummy', $property)); |
| 68 | + $this->assertSame($longDescription, $this->extractor->getLongDescription('Symfony\Component\PropertyInfo\Tests\Fixtures\InvalidDummy', $property)); |
| 69 | + } |
| 70 | + |
49 | 71 | /**
|
50 | 72 | * @dataProvider typesWithNoPrefixesProvider
|
51 | 73 | */
|
@@ -94,7 +116,7 @@ public function typesProvider()
|
94 | 116 | ['donotexist', null, null, null],
|
95 | 117 | ['staticGetter', null, null, null],
|
96 | 118 | ['staticSetter', null, null, null],
|
97 |
| - ['emptyVar', null, null, null], |
| 119 | + ['emptyVar', null, $this->isPhpDocumentorV5() ? 'This should not be removed.' : null, null], |
98 | 120 | ];
|
99 | 121 | }
|
100 | 122 |
|
@@ -250,6 +272,16 @@ public function testDocBlockFallback($property, $types)
|
250 | 272 | {
|
251 | 273 | $this->assertEquals($types, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\DockBlockFallback', $property));
|
252 | 274 | }
|
| 275 | + |
| 276 | + protected function isPhpDocumentorV5() |
| 277 | + { |
| 278 | + if (class_exists(InvalidTag::class)) { |
| 279 | + return true; |
| 280 | + } |
| 281 | + |
| 282 | + return (new \ReflectionMethod(StandardTagFactory::class, 'create')) |
| 283 | + ->hasReturnType(); |
| 284 | + } |
253 | 285 | }
|
254 | 286 |
|
255 | 287 | class EmptyDocBlock
|
|
0 commit comments