How to get the destination nid from an URL object
Looks like you're using the latest Devel, 4.0.1, which sadly currently doesn't show the available methods tab unless you patch it.
If you had the available methods tab, you would've seen that you can retrieve using the public method getRouteParameters
$nid = $url_object-&gt;getRouteParameters()['node'];