-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathPropertyAccessPathItem.php
More file actions
46 lines (37 loc) · 946 Bytes
/
PropertyAccessPathItem.php
File metadata and controls
46 lines (37 loc) · 946 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php declare(strict_types = 1);
namespace PHPStan\PhpDocParser\Ast\Type;
use PHPStan\PhpDocParser\Ast\Node;
use PHPStan\PhpDocParser\Ast\NodeAttributes;
/**
* Represents a single property in a property access path.
*
* Examples:
* - In `$this->config->database`, there are two items: 'config' and 'database'
* - In `self::$cache`, there is one item: 'cache'
*/
class PropertyAccessPathItem implements Node
{
use NodeAttributes;
public string $name;
public function __construct(string $name)
{
$this->name = $name;
}
public function __toString(): string
{
return $this->name;
}
/**
* @param array<string, mixed> $properties
*/
public static function __set_state(array $properties): self
{
$instance = new self($properties['name']);
if (isset($properties['attributes'])) {
foreach ($properties['attributes'] as $key => $value) {
$instance->setAttribute($key, $value);
}
}
return $instance;
}
}