Can you implement a class onto existing object

Heylo,

Let’s say we have an object $var come to us from a source we cannot edit, is it possible to add an implemented class to that existing stdClass?

I know we could remap the existing $var properties onto a new class we create, but this could lose any methods that exist in the old object.

        $var = (object) ["prop" => "value"]; 
        // somehow implement ArrayAccess on existing stdClass $var
        echo $var["prop"]; // should work
        echo $var->prop; // should also work