<?php
function inner(): void
{
    throw new \UnexpectedValueException("inner-boom", 23);
}

function outer(): void
{
    try {
        inner();
    } catch (\Error $wrong) {
        echo "wrong-error\n";
    } catch (\UnexpectedValueException $e) {
        echo "caught:" . $e->getMessage() . ":" . $e->getCode() . "\n";

        $copy = $e;
        echo "copy:" . $copy->getMessage() . ":" . $copy->getCode() . "\n";

        throw $e;
    }
}

try {
    outer();
} catch (\UnexpectedValueException $e) {
    echo "rethrown:" . $e->getMessage() . ":" . $e->getCode() . "\n";
} catch (\Throwable $e) {
    echo "wrong-throwable\n";
}
