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