foreach ($availability->getFreeBusyResponseArray()->FreeBusyResponse as $responseMessage) {
if ($responseMessage->getResponseMessage()->getResponseClass() === 'Error') {
throw new ExchangeException($responseMessage);
}
}
$availability->getFreeBusyResponseArray()->FreeBusyResponse is array
https://github.com/Garethp/php-ews/blob/7920fefb0bb431cb2df0b2ba58d09330535ced6c/src/CalendarAPI.php#L307
replace ->
$availability->getFreeBusyResponseArray()->FreeBusyResponse is array