PECL not working in PHP 7.4.1; "Trying to access array offset on value of type bool in PEAR/REST.php on line 181"

.

Since upgrading to PHP 7.4.1, an error related to PEAR has been encountered even though the issue was listed as fixed. When attempting to install a package using pecl, a warning error is displayed with the following message:

Notice: Trying to access array offset on value of type bool in PEAR/REST.php on line 187
    PHP Notice:  Trying to access array offset on value of type bool in /usr/share/php/PEAR/REST.php on line 187

The repositories have been updated, but the problem remains unresolved.

The error you are encountering is a known issue with PEAR in PHP 7.4.1. It occurs when trying to access an array offset on a boolean value in the PEAR/REST.php file.

To resolve this issue, you can apply the following fix:

  1. Open the PEAR/REST.php file in a text editor.

  2. Go to line 187.

  3. Replace the line:

    $this->response = $http->request($url, $http_options);
    

    with:

    $this->response = $http->request($url, $http_options) ?? '';
    

    This change ensures that $this->response is always assigned a value, even if the request fails and returns a boolean false.

Save the file and try installing the package using pecl again. The warning error should no longer be displayed.