should be `set_error_handler(function () use (&$hasError) {`