Fluent interfaces and method chaining: A potential hidden landmine

Of late, I have been doing some maintenance work on a legacy website which uses Laravel and PHP 7 (work on the upgrade is in progress). In testing, we found a situation where we were trying to call a method on a NULL value. The line of code read as follows:

      $fleet = Chapter::find($this->getAssignedShip())->getAssignedFleet(true);

The code would then go on to properly use the $fleet value, checking for whether or not it was NULL before using it.