The primary issue was already resolved in 7c3e487289, but the particular example used in this bug report ran into an additional issue on PHP 8, because I forgot to drop a number of zend_bailout calls when switch require failure to throw.
7c3e487289