getArrayCopy(); } public function jsonDeserialize(array|string $data): static { if (is_string($data)) { $data = json_decode($data, true); } $this->exchangeArray([]); if (in_array($this->typeValue, $this->primitiveTypes)) { if ($this->associative) { foreach ($data as $key => $value) { $this[$key] = $value; } } else { foreach ($data as $value) { $this[] = $value; } } } if (!in_array($this->typeValue, $this->primitiveTypes) && class_exists($this->typeValue)) { $reflection = new \ReflectionClass($this->typeValue); if ($reflection->implementsInterface(JsonDeserializable::class)) { if ($this->associative) { foreach ($data as $key => $value) { $instance = $reflection->newInstance(); /** @var JsonDeserializable $instance */ $this[$key] = $instance->jsonDeserialize($value); } } else { foreach ($data as $value) { $instance = $reflection->newInstance(); /** @var JsonDeserializable $instance */ $this[] = $instance->jsonDeserialize($value); } } } } return $this; } }