1<?php 2namespace DeepCopy\TypeFilter\Spl; 3 4use DeepCopy\DeepCopy; 5use DeepCopy\TypeFilter\TypeFilter; 6 7/** 8 * In PHP 7.4 the storage of an ArrayObject isn't returned as 9 * ReflectionProperty. So we deep copy its array copy. 10 */ 11final class ArrayObjectFilter implements TypeFilter 12{ 13 /** 14 * @var DeepCopy 15 */ 16 private $copier; 17 18 public function __construct(DeepCopy $copier) 19 { 20 $this->copier = $copier; 21 } 22 23 /** 24 * {@inheritdoc} 25 */ 26 public function apply($arrayObject) 27 { 28 $clone = clone $arrayObject; 29 foreach ($arrayObject->getArrayCopy() as $k => $v) { 30 $clone->offsetSet($k, $this->copier->copy($v)); 31 } 32 33 return $clone; 34 } 35} 36 37