| 1 |
<?php declare(strict_types = 1); |
| 2 |
|
| 3 |
namespace PHPStan\PhpDocParser\Ast\PhpDoc\Doctrine; |
| 4 |
|
| 5 |
use PHPStan\PhpDocParser\Ast\Node; |
| 6 |
use PHPStan\PhpDocParser\Ast\NodeAttributes; |
| 7 |
use function implode; |
| 8 |
|
| 9 |
class DoctrineAnnotation implements Node |
| 10 |
{ |
| 11 |
|
| 12 |
use NodeAttributes; |
| 13 |
|
| 14 |
public string $name; |
| 15 |
|
| 16 |
/** @var list<DoctrineArgument> */ |
| 17 |
public array $arguments; |
| 18 |
|
| 19 |
/** |
| 20 |
* @param list<DoctrineArgument> $arguments |
| 21 |
*/ |
| 22 |
public function __construct(string $name, array $arguments) |
| 23 |
{ |
| 24 |
$this->name = $name; |
| 25 |
$this->arguments = $arguments; |
| 26 |
} |
| 27 |
|
| 28 |
public function __toString(): string |
| 29 |
{ |
| 30 |
$arguments = implode(', ', $this->arguments); |
| 31 |
return $this->name . '(' . $arguments . ')'; |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* @param array<string, mixed> $properties |
| 36 |
*/ |
| 37 |
public static function __set_state(array $properties): self |
| 38 |
{ |
| 39 |
$instance = new self($properties['name'], $properties['arguments']); |
| 40 |
if (isset($properties['attributes'])) { |
| 41 |
foreach ($properties['attributes'] as $key => $value) { |
| 42 |
$instance->setAttribute($key, $value); |
| 43 |
} |
| 44 |
} |
| 45 |
return $instance; |
| 46 |
} |
| 47 |
|
| 48 |
} |