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