Skip to content

Commit

Permalink
Never reference E_STRICT on PHP 8.4+
Browse files Browse the repository at this point in the history
  • Loading branch information
mlocati committed Sep 30, 2024
1 parent 6f4c3a0 commit 3b225ef
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
6 changes: 5 additions & 1 deletion PEAR/RunTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ function __construct($logger = null, $options = array())
if (!defined('E_STRICT')) {
define('E_STRICT', 0);
}
$this->ini_overwrites[] = 'error_reporting=' . (E_ALL & ~(E_DEPRECATED | E_STRICT));
$excluded_error_reporting = E_DEPRECATED;
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 80400) {
$excluded_error_reporting |= E_STRICT;
}
$this->ini_overwrites[] = 'error_reporting=' . (E_ALL & ~$excluded_error_reporting);
if (is_null($logger)) {
require_once 'PEAR/Common.php';
$logger = new PEAR_Common;
Expand Down
7 changes: 6 additions & 1 deletion make-gopear-phar.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
* @copyright 2005-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
*/
error_reporting(error_reporting() & ~E_STRICT & ~E_DEPRECATED);
$new_error_reporting = error_reporting() & ~E_DEPRECATED;
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 80400) {
$new_error_reporting &= ~E_STRICT;
}
error_reporting($new_error_reporting);
unset($new_error_reporting);

function replaceVersion($contents, $path)
{
Expand Down
7 changes: 6 additions & 1 deletion make-installpear-nozlib-phar.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
* @copyright 2005-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
*/
error_reporting(error_reporting() & ~E_STRICT & ~E_DEPRECATED);
$new_error_reporting = error_reporting() & ~E_DEPRECATED;
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 80400) {
$new_error_reporting &= ~E_STRICT;
}
error_reporting($new_error_reporting);
unset($new_error_reporting);

function replaceVersion($contents, $path)
{
Expand Down
6 changes: 4 additions & 2 deletions scripts/pearcmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ function cmdHelp($command)
*/
function error_handler($errno, $errmsg, $file, $line)
{
if ($errno & E_STRICT) {
if ((!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 80400) && ($errno & E_STRICT)) {
return; // E_STRICT
}
if ($errno & E_DEPRECATED) {
Expand All @@ -455,7 +455,6 @@ function error_handler($errno, $errmsg, $file, $line)
E_ERROR => "Error",
E_WARNING => "Warning",
E_PARSE => "Parsing Error",
E_STRICT => 'Strict Warning',
E_NOTICE => "Notice",
E_CORE_ERROR => "Core Error",
E_CORE_WARNING => "Core Warning",
Expand All @@ -465,6 +464,9 @@ function error_handler($errno, $errmsg, $file, $line)
E_USER_WARNING => "User Warning",
E_USER_NOTICE => "User Notice"
);
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 80400) {
$errortype[E_STRICT] = 'Strict Warning';
}
$prefix = $errortype[$errno];
global $_PEAR_PHPDIR;
if (stristr($file, $_PEAR_PHPDIR)) {
Expand Down
4 changes: 2 additions & 2 deletions tests/PEAR_Error/pear_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ if (!getenv('PHP_PEAR_RUNTESTS')) {

include_once "PEAR.php";

if (!defined('E_STRICT')) {
if ((!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 80400) && !defined('E_STRICT')) {
define('E_STRICT', -1);
}
if (!defined('E_DEPRECATED')) {
define('E_DEPRECATED', -1);
}

function test_error_handler($errno, $errmsg, $file, $line) {
if ($errno == E_STRICT) {
if ((!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 80400) && $errno == E_STRICT) {
return;
}
if ($errno == E_DEPRECATED) {
Expand Down

0 comments on commit 3b225ef

Please sign in to comment.