3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = [ 'counters' => [ 'success' => 1, 'failed' => 3 ], 'aa' => [1,2,3], 'column_errors' => false ]; $update = array( ); class Job { private $data; public function __construct(array $data) { $this->data = $data; } public function getData() { return $this->data; } public function updateDataWith(array $update) { $result = array_replace_recursive($this->data, $update); if (is_null($result)) { throw new \RuntimeException; } $this->data = $result; } } $job = new Job($a); $job->updateDataWith($update); var_dump($job->getData());
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.5 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
array(3) { ["counters"]=> array(2) { ["success"]=> int(1) ["failed"]=> int(3) } ["aa"]=> array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } ["column_errors"]=> bool(false) }

preferences:
155.16 ms | 404 KiB | 168 Q