For anyone wondering, the copy-on-write behaviour just does the Right Thing™ when an array is passed to a function not by-ref which then passes it through to another function by-ref without writing to it. For example:
<?php
function do_sort(array $array) : array {
usort($array, function ($a, $b) {
return strnatcasecmp($a['name'], $b['name']);
});
return $array;
}
$data = [
[
'name' => 'one',
], [
'name' => 'two',
], [
'name' => 'three',
], [
'name' => 'four',
],
];
var_dump($data);
do_sort($data); var_dump($data);
$data = do_sort($data);
var_dump($data);