This was in library code, but I've done it in my own code as well.
Since we couldn't previously typehint on resources, we'd test (a) to see if we had actually received a resource, and (b) that it was a resource of the correct type (get_resource_type() === '...' or strstr or preg_match operations). The latter doesn't work with the new resource classes.