$object should probably not be a reference. Could provide it with the type hint?