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