DynamicActiveRecord.php
protected static function walk(& $array, $method)
    {
        if (is_scalar($array)) {
            $array = static::$method($array);

            return;
        }

        $replacements = [];
        foreach ($array as $key => & $value) {
            if (is_scalar($value) || $value === null) {
                $value = static::$method($value);
            } else {
                static::walk($value, $method);
            }
            $newKey = static::$method($key);
            if ($newKey !== $key) {
                $replacements[$newKey] = $value;
                unset($array[$key]);
            }
        }
        foreach ($replacements as $key => $value2) {
            $array[$key] = $value2;
        }
    }
protected static function walk(& $array, $method)
    {
        if (is_scalar($array)) {
            $array = static::$method($array);

            return;
        }

        $replacements = [];
        foreach ($array as $key => & $value) {
            if (is_scalar($value) || $value === null) {
                $value = static::$method($value);
            } else {
                static::walk($value, $method);
            }
            $newKey = static::$method($key);
            if ($newKey !== $key) {
                $replacements[$newKey] = $value;
                unset($array[$key]);
            }
        }
        foreach ($replacements as $key => $value2) {
            $array[$key] = $value2;
        }
    }
protected static function walk ( & $ array , $ method ) { if ( is_scalar ( $ array ) ) { $ array = static :: $ method ( $ array ) ; return ; } $ replacements = [ ] ; foreach ( $ array as $ key => & $ value ) { if ( is_scalar ( $ value ) || $ value === null ) { $ value = static :: $ method ( $ value ) ; } else { static :: walk ( $ value , $ method ) ; } $ newKey = static :: $ method ( $ key ) ; if ( $ newKey !== $ key ) { $ replacements [ $ newKey ] = $ value ; unset ( $ array [ $ key ] ) ; } } foreach ( $ replacements as $ key => $ value2 ) { $ array [ $ key ] = $ value2 ; } }
Replacement for PHP's array walk and map builtins.

@param array $array An array to walk, which may be nested
@param callable $method A method to map on the array
Replacement for PHP s array walk and map builtins .