The 7.2 object type hint, and what it is not

November’s release adds object as a type, which sounds like it should let a function accept “any class” and be checked. It does exactly that and nothing more.

function describe(object $thing): string
{
    return get_class($thing);
}

describe(new Order());   // fine
describe([]);            // TypeError
describe('Order');       // TypeError

It is a genuine improvement over no hint at all for a serialiser or a container, and it is not a substitute for an interface — a parameter typed object tells the reader nothing about what may be called on it. Reach for it where the function genuinely does not care, such as something that only ever inspects the class, and for an interface everywhere else.