add alias

This commit is contained in:
crazywhalecc
2022-08-21 20:15:55 +08:00
parent 8f761c31e3
commit ac69640253
8 changed files with 59 additions and 112 deletions

View File

@@ -11,10 +11,15 @@ use Traversable;
abstract class AnnotationBase implements IteratorAggregate
{
public $method = '';
public string $method = '';
/**
* @var Closure|string
*/
public $class = '';
public array $group = [];
public function __toString()
{
$str = __CLASS__ . ': ';
@@ -44,7 +49,7 @@ abstract class AnnotationBase implements IteratorAggregate
*
* @param Closure|string $method
*/
public function withMethod($method): AnnotationBase
public function on($method): AnnotationBase
{
$this->method = $method;
return $this;
@@ -54,4 +59,19 @@ abstract class AnnotationBase implements IteratorAggregate
{
return new ArrayIterator($this);
}
public function isInGroup(string $name): bool
{
return in_array($name, $this->group);
}
public function addGroup(string $name)
{
$this->group[] = $name;
}
public function getGroups(): array
{
return $this->group;
}
}