Enhance SplObjectStorage caster + workaround for php bug #65967