Could it be just if ( $u ) or if ( $u instance of User )?
Done in r59797.
The problem with that is that it breaks StubUser and any other similar proxy objects. My vote would be for is_object().