-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
Add new tags
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of phpDocumentor. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @link http://phpdoc.org | ||
*/ | ||
|
||
namespace phpDocumentor\Reflection\DocBlock\Tags; | ||
|
||
use Doctrine\Deprecations\Deprecation; | ||
use phpDocumentor\Reflection\Type; | ||
use phpDocumentor\Reflection\DocBlock\Description; | ||
use phpDocumentor\Reflection\DocBlock\Tags\TagWithType; | ||
|
||
/** | ||
* Reflection class for a {@}extends tag in a Docblock. | ||
*/ | ||
class Extends_ extends TagWithType | ||
{ | ||
public function __construct(Type $type, ?Description $description = null) | ||
{ | ||
$this->name = 'extends'; | ||
$this->type = $type; | ||
$this->description = $description; | ||
} | ||
|
||
/** | ||
* @deprecated Create using static factory is deprecated, | ||
* this method should not be called directly by library consumers | ||
*/ | ||
public static function create(string $body) | ||
{ | ||
Deprecation::trigger( | ||
'phpdocumentor/reflection-docblock', | ||
'https://github.com/phpDocumentor/ReflectionDocBlock/issues/361', | ||
'Create using static factory is deprecated, this method should not be called directly | ||
by library consumers', | ||
); | ||
return null; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory; | ||
|
||
use phpDocumentor\Reflection\TypeResolver; | ||
use phpDocumentor\Reflection\Types\Context; | ||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode; | ||
use PHPStan\PhpDocParser\Ast\PhpDoc\ExtendsTagValueNode; | ||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory; | ||
|
||
/** | ||
* @internal This class is not part of the BC promise of this library. | ||
*/ | ||
abstract class AbstractExtendsFactory implements PHPStanFactory | ||
{ | ||
private DescriptionFactory $descriptionFactory; | ||
Check failure on line 18 in src/DocBlock/Tags/Factory/AbstractExtendsFactory.php GitHub Actions / Static analysis / Static Code Analysis (8.0)
|
||
private TypeResolver $typeResolver; | ||
Check failure on line 19 in src/DocBlock/Tags/Factory/AbstractExtendsFactory.php GitHub Actions / Static analysis / Static Code Analysis (8.0)
|
||
protected string $tagName; | ||
|
||
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory) | ||
{ | ||
$this->descriptionFactory = $descriptionFactory; | ||
$this->typeResolver = $typeResolver; | ||
} | ||
|
||
public function supports(PhpDocTagNode $node, Context $context): bool | ||
{ | ||
return $node->value instanceof ExtendsTagValueNode && $node->name === $this->tagName; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory; | ||
|
||
use phpDocumentor\Reflection\TypeResolver; | ||
use phpDocumentor\Reflection\Types\Context; | ||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode; | ||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory; | ||
use PHPStan\PhpDocParser\Ast\PhpDoc\ImplementsTagValueNode; | ||
|
||
/** | ||
* @internal This class is not part of the BC promise of this library. | ||
*/ | ||
abstract class AbstractImplementsFactory implements PHPStanFactory | ||
{ | ||
private DescriptionFactory $descriptionFactory; | ||
Check failure on line 18 in src/DocBlock/Tags/Factory/AbstractImplementsFactory.php GitHub Actions / Static analysis / Static Code Analysis (8.0)
|
||
private TypeResolver $typeResolver; | ||
Check failure on line 19 in src/DocBlock/Tags/Factory/AbstractImplementsFactory.php GitHub Actions / Static analysis / Static Code Analysis (8.0)
|
||
protected string $tagName; | ||
|
||
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory) | ||
{ | ||
$this->descriptionFactory = $descriptionFactory; | ||
$this->typeResolver = $typeResolver; | ||
} | ||
|
||
public function supports(PhpDocTagNode $node, Context $context): bool | ||
{ | ||
return $node->value instanceof ImplementsTagValueNode && $node->name === $this->tagName; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory; | ||
|
||
use Webmozart\Assert\Assert; | ||
use phpDocumentor\Reflection\DocBlock\Tag; | ||
use phpDocumentor\Reflection\TypeResolver; | ||
use phpDocumentor\Reflection\Types\Context; | ||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode; | ||
use phpDocumentor\Reflection\DocBlock\Tags\Extends_; | ||
use PHPStan\PhpDocParser\Ast\PhpDoc\ExtendsTagValueNode; | ||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory; | ||
|
||
/** | ||
* @internal This class is not part of the BC promise of this library. | ||
*/ | ||
final class ExtendsFactory extends AbstractExtendsFactory | ||
{ | ||
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory) | ||
{ | ||
parent::__construct($typeResolver, $descriptionFactory); | ||
$this->tagName = '@extends'; | ||
} | ||
|
||
public function create(PhpDocTagNode $node, Context $context): Tag | ||
{ | ||
$tagValue = $node->value; | ||
Assert::isInstanceOf($tagValue, ExtendsTagValueNode::class); | ||
|
||
$description = $tagValue->getAttribute('description'); | ||
if (is_string($description) === false) { | ||
$description = $tagValue->description; | ||
} | ||
|
||
return new Extends_( | ||
$this->typeResolver->createType($tagValue->type, $context), | ||
Check failure on line 38 in src/DocBlock/Tags/Factory/ExtendsFactory.php GitHub Actions / Static analysis / Static Code Analysis (8.0)
|
||
$this->descriptionFactory->create($description, $context) | ||
Check failure on line 39 in src/DocBlock/Tags/Factory/ExtendsFactory.php GitHub Actions / Static analysis / Static Code Analysis (8.0)
|
||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory; | ||
|
||
use Webmozart\Assert\Assert; | ||
use phpDocumentor\Reflection\DocBlock\Tag; | ||
use phpDocumentor\Reflection\TypeResolver; | ||
use phpDocumentor\Reflection\Types\Context; | ||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode; | ||
use phpDocumentor\Reflection\DocBlock\Tags\Implements_; | ||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory; | ||
use PHPStan\PhpDocParser\Ast\PhpDoc\ImplementsTagValueNode; | ||
|
||
/** | ||
* @internal This class is not part of the BC promise of this library. | ||
*/ | ||
final class ImplementsFactory extends AbstractImplementsFactory | ||
{ | ||
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory) | ||
{ | ||
parent::__construct($typeResolver, $descriptionFactory); | ||
$this->tagName = '@implements'; | ||
} | ||
|
||
public function create(PhpDocTagNode $node, Context $context): Tag | ||
{ | ||
$tagValue = $node->value; | ||
Assert::isInstanceOf($tagValue, ImplementsTagValueNode::class); | ||
|
||
$description = $tagValue->getAttribute('description'); | ||
if (is_string($description) === false) { | ||
$description = $tagValue->description; | ||
} | ||
|
||
return new Implements_( | ||
$this->typeResolver->createType($tagValue->type, $context), | ||
Check failure on line 38 in src/DocBlock/Tags/Factory/ImplementsFactory.php GitHub Actions / Static analysis / Static Code Analysis (8.0)
|
||
$this->descriptionFactory->create($description, $context) | ||
Check failure on line 39 in src/DocBlock/Tags/Factory/ImplementsFactory.php GitHub Actions / Static analysis / Static Code Analysis (8.0)
|
||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory; | ||
|
||
use Webmozart\Assert\Assert; | ||
use phpDocumentor\Reflection\DocBlock\Tag; | ||
use phpDocumentor\Reflection\TypeResolver; | ||
use phpDocumentor\Reflection\Types\Context; | ||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode; | ||
use PHPStan\PhpDocParser\Ast\PhpDoc\ExtendsTagValueNode; | ||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory; | ||
use phpDocumentor\Reflection\DocBlock\Tags\TemplateExtends; | ||
|
||
/** | ||
* @internal This class is not part of the BC promise of this library. | ||
*/ | ||
final class TemplateExtendsFactory extends AbstractExtendsFactory | ||
{ | ||
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory) | ||
{ | ||
parent::__construct($typeResolver, $descriptionFactory); | ||
$this->tagName = '@template-extends'; | ||
} | ||
|
||
public function create(PhpDocTagNode $node, Context $context): Tag | ||
{ | ||
$tagValue = $node->value; | ||
Assert::isInstanceOf($tagValue, ExtendsTagValueNode::class); | ||
|
||
$description = $tagValue->getAttribute('description'); | ||
if (is_string($description) === false) { | ||
$description = $tagValue->description; | ||
} | ||
|
||
return new TemplateExtends( | ||
$this->typeResolver->createType($tagValue->type, $context), | ||
Check failure on line 38 in src/DocBlock/Tags/Factory/TemplateExtendsFactory.php GitHub Actions / Static analysis / Static Code Analysis (8.0)
|
||
$this->descriptionFactory->create($description, $context) | ||
Check failure on line 39 in src/DocBlock/Tags/Factory/TemplateExtendsFactory.php GitHub Actions / Static analysis / Static Code Analysis (8.0)
|
||
); | ||
} | ||
} |