<?php declare(strict_types = 1);
namespace PHPStan\PhpDocParser\Ast;
use function array_key_exists;
trait NodeAttributes
{
/** @var array<string, mixed> */
private array $attributes = [];
/**
* @param mixed $value
*/
public function setAttribute(string $key, $value): void
{
if ($value === null) {
unset($this->attributes[$key]);
return;
}
$this->attributes[$key] = $value;
}
public function hasAttribute(string $key): bool
{
return array_key_exists($key, $this->attributes);
}
/**
* @return mixed
*/
public function getAttribute(string $key)
{
if ($this->hasAttribute($key)) {
return $this->attributes[$key];
}
return null;
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| ConstExpr | Folder | 0755 |
|
|
| NodeVisitor | Folder | 0755 |
|
|
| PhpDoc | Folder | 0755 |
|
|
| Type | Folder | 0755 |
|
|
| AbstractNodeVisitor.php | File | 671 B | 0644 |
|
| Attribute.php | File | 341 B | 0644 |
|
| Comment.php | File | 664 B | 0644 |
|
| Node.php | File | 348 B | 0644 |
|
| NodeAttributes.php | File | 682 B | 0644 |
|
| NodeTraverser.php | File | 8.21 KB | 0644 |
|
| NodeVisitor.php | File | 2.45 KB | 0644 |
|