This if clause probably isn't checking what you think it is.  It's kind of weird, but it's around handling non-scalar types as array keys.  Instead of adding an else clause, I suggest adding a second if clause that checks to see if the object is not a UUID instance, and if it's a string, tries to convert it to a UUID.

(If you want to optimize, make UUID::makeBin() public and use that directly instead of creating a UUID and then extracting just the $bytes.)