1: | <?php declare(strict_types = 1); |
2: | |
3: | namespace PHPStan\Collectors; |
4: | |
5: | use JsonSerializable; |
6: | use PhpParser\Node; |
7: | use ReturnTypeWillChange; |
8: | |
9: | |
10: | |
11: | |
12: | final class CollectedData implements JsonSerializable |
13: | { |
14: | |
15: | |
16: | |
17: | |
18: | |
19: | public function __construct( |
20: | private $data, |
21: | private string $filePath, |
22: | private string $collectorType, |
23: | ) |
24: | { |
25: | } |
26: | |
27: | public function getData(): mixed |
28: | { |
29: | return $this->data; |
30: | } |
31: | |
32: | public function getFilePath(): string |
33: | { |
34: | return $this->filePath; |
35: | } |
36: | |
37: | public function changeFilePath(string $newFilePath): self |
38: | { |
39: | return new self($this->data, $newFilePath, $this->collectorType); |
40: | } |
41: | |
42: | |
43: | |
44: | |
45: | public function getCollectorType(): string |
46: | { |
47: | return $this->collectorType; |
48: | } |
49: | |
50: | |
51: | |
52: | |
53: | #[ReturnTypeWillChange] |
54: | public function jsonSerialize() |
55: | { |
56: | return [ |
57: | 'data' => $this->data, |
58: | 'filePath' => $this->filePath, |
59: | 'collectorType' => $this->collectorType, |
60: | ]; |
61: | } |
62: | |
63: | |
64: | |
65: | |
66: | public static function decode(array $json): self |
67: | { |
68: | return new self( |
69: | $json['data'], |
70: | $json['filePath'], |
71: | $json['collectorType'], |
72: | ); |
73: | } |
74: | |
75: | |
76: | |
77: | |
78: | public static function __set_state(array $properties): self |
79: | { |
80: | return new self( |
81: | $properties['data'], |
82: | $properties['filePath'], |
83: | $properties['collectorType'], |
84: | ); |
85: | } |
86: | |
87: | } |
88: | |