diff --git a/src/Transport/Curl.php b/src/Transport/Curl.php index 0b3794808..3995197f4 100644 --- a/src/Transport/Curl.php +++ b/src/Transport/Curl.php @@ -177,6 +177,11 @@ public function request($url, $headers = [], $data = [], $options = []) { $this->stream_handle = @fopen($options['filename'], 'wb'); if ($this->stream_handle === false) { $error = error_get_last(); + if (!is_array($error)) { + // Shouldn't be possible, but can happen in test situations. + $error = ['message' => 'Failed to open stream']; + } + throw new Exception($error['message'], 'fopen'); } } diff --git a/src/Transport/Fsockopen.php b/src/Transport/Fsockopen.php index 97a1f7373..15a5ba9b0 100644 --- a/src/Transport/Fsockopen.php +++ b/src/Transport/Fsockopen.php @@ -282,6 +282,11 @@ public function request($url, $headers = [], $data = [], $options = []) { $download = @fopen($options['filename'], 'wb'); if ($download === false) { $error = error_get_last(); + if (!is_array($error)) { + // Shouldn't be possible, but can happen in test situations. + $error = ['message' => 'Failed to open stream']; + } + throw new Exception($error['message'], 'fopen'); } }