mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
Merge pull request #260 from voku/get_tags_with_type_by_name
Get tags with type by name
This commit is contained in:
@@ -14,6 +14,7 @@ declare(strict_types=1);
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\TagWithType;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
final class DocBlock
|
||||
@@ -161,6 +162,29 @@ final class DocBlock
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of tags with type matching the given name. If no tags are found
|
||||
* an empty array is returned.
|
||||
*
|
||||
* @param string $name String to search by.
|
||||
*
|
||||
* @return TagWithType[]
|
||||
*/
|
||||
public function getTagsWithTypeByName(string $name) : array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($this->getTagsByName($name) as $tag) {
|
||||
if (!$tag instanceof TagWithType) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result[] = $tag;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a tag of a certain type is present in this DocBlock.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user