1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\PhpDocParser\Ast;
4:
5: use function array_key_exists;
6:
7: trait NodeAttributes
8: {
9:
10: /** @var array<string, mixed> */
11: private $attributes = [];
12:
13: /**
14: * @param mixed $value
15: */
16: public function setAttribute(string $key, $value): void
17: {
18: $this->attributes[$key] = $value;
19: }
20:
21: public function hasAttribute(string $key): bool
22: {
23: return array_key_exists($key, $this->attributes);
24: }
25:
26: /**
27: * @return mixed
28: */
29: public function getAttribute(string $key)
30: {
31: if ($this->hasAttribute($key)) {
32: return $this->attributes[$key];
33: }
34:
35: return null;
36: }
37:
38: }
39: