Jean-FrancoisHIVERT this is weird.
May I ask to paste the following code somewhere in between the problematic code:
$next = $address->nextAddress();
var_dump( $next );
and please try a mouse tooltip over the $next, if the type is correct.

I'm always open to a quick remote desktop session, if you are willing to, and you have a favorite remote desktop tool.