PHP Max Slice Sum
function maxSliceSum(array $a): int
{
    $tmp = $max = PHP_INT_MIN;

    foreach ($a as $v) {
        $tmp = max($tmp + $v, $v);
        $max = max($max, $tmp);
    }

    return $max;
}

This is a Kadane-style scan: keep the best running sum and the best overall sum while moving once through the array.