Java compiler ensures that each method call includes arguments compatible with parameter types. In the example below, passing something that does not implement LogService interface won't even compile.
public logMessage(LogService logService, String message) {
logService.logMessage(message);
}
Is there a way to achieve the same with PHP? If I pass an object that is not compatible with LogService interface, I'd like to know that immediately in IDE, rather than find out in testing. I'm currently using PHP 5.4 but I have options to go higher.
public function logMessage($logService, $message) {
$logService->logMessage($message);
}