Parse template tag for generics (#21)

* Parse template tag for generics

* Fixed templatetag docblock

* Fixed PHP 7 issue

* Fixed PHP 7.2 issue

* Fixed another 7.2 issue
This commit is contained in:
Nereo Berardozzi
2024-12-24 12:30:50 +01:00
committed by GitHub
parent fba297a2a7
commit d5d2d76892
8 changed files with 295 additions and 5 deletions
+19 -1
View File
@@ -15,6 +15,7 @@ namespace Barryvdh\Reflection;
use Barryvdh\Reflection\DocBlock\Tag;
use Barryvdh\Reflection\DocBlock\Context;
use Barryvdh\Reflection\DocBlock\Location;
use Barryvdh\Reflection\DocBlock\Tag\TemplateTag;
/**
* Parses the DocBlock for any structure.
@@ -40,6 +41,9 @@ class DocBlock implements \Reflector
*/
protected $tags = array();
/** @var string[] An array containing all the generics in this docblock. */
protected $generics = array();
/** @var Context Information about the context of this DocBlock. */
protected $context = null;
@@ -238,7 +242,11 @@ class DocBlock implements \Reflector
// create proper Tag objects
foreach ($result as $key => $tag_line) {
$result[$key] = Tag::createInstance(trim($tag_line), $this);
$tag = Tag::createInstance(trim($tag_line), $this);
if ($tag instanceof TemplateTag) {
$this->generics[] = $tag->getTemplateName();
}
$result[$key] = $tag;
}
}
@@ -457,6 +465,16 @@ class DocBlock implements \Reflector
return false;
}
/**
* Returns the generics for this DocBlock.
*
* @return string[]
*/
public function getGenerics()
{
return $this->generics;
}
/**
* Builds a string representation of this object.
*