1<?php 2 3declare(strict_types=1); 4 5namespace JMS\Serializer; 6 7/** 8 * Interface for array transformation. 9 * 10 * @author Daniel Bojdo <daniel@bojdo.eu> 11 */ 12interface ArrayTransformerInterface 13{ 14 /** 15 * Converts objects to an array structure. 16 * 17 * This is useful when the data needs to be passed on to other methods which expect array data. 18 * 19 * @param mixed $data anything that converts to an array, typically an object or an array of objects 20 * 21 * @return array 22 */ 23 public function toArray($data, ?SerializationContext $context = null, ?string $type = null): array; 24 25 /** 26 * Restores objects from an array structure. 27 * 28 * @param array $data 29 * 30 * @return mixed this returns whatever the passed type is, typically an object or an array of objects 31 */ 32 public function fromArray(array $data, string $type, ?DeserializationContext $context = null); 33} 34