class HotelController extends Controller
{
public function actionBook($id, BookingInterface $bookingService)
{
$result = $bookingService->book($id);
// ...
}
}
First argument is object state, but the second is object dependencies. Should they be mixed in the same method signature, really? Or is this due to historic reasons?
One could make a similar argument related to class properties: That a class should have state or (effectful) dependencies (like a database connection), to keep the intention of the class clear. For example, an ActiveRecord class would have properties corresponding to its database table - including the table name - but the database connection would be an argument to the save-method:
$user = new User();
$user->name = 'Foo';
$user->save($dbConnection);