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