Deprecate E_STRICT constant and remove error level

RFC: https://wiki.php.net/rfc/deprecations_php_8_4#remove_e_strict_error_level_and_deprecate_e_strict_constant

Closes GH-13053
This commit is contained in:
Michael Voříšek 2023-12-30 13:57:05 +01:00 committed by Ilija Tovilo
parent a360b1757e
commit d313ad6098
No known key found for this signature in database
GPG Key ID: 5050C66BFCD1015A
29 changed files with 141 additions and 211 deletions

View File

@ -44,6 +44,9 @@ PHP 8.4 UPGRADE NOTES
As such, passing invalid types to exit/die may now result in a TypeError
being thrown.
RFC: https://wiki.php.net/rfc/exit-as-function
. The E_STRICT constant was deprecated and its corresponding error level was
removed.
RFC: https://wiki.php.net/rfc/deprecations_php_8_4#remove_e_strict_error_level_and_deprecate_e_strict_constant
- DBA:
. dba_open() and dba_popen() will now return a Dba\Connection

View File

@ -192,18 +192,6 @@ try {
var_dump($e->getTraceAsString() === EXCEPTION_TRACE_AS_STRING_MSG);
}
try {
throw new ErrorException(EXCEPTION_PARAM_MSG, EXCEPTION_CODE_ERROR, E_STRICT);
} catch(ErrorException $e) {
echo EXCEPTION_SEVERITY_ERROR_MSG . $e->getSeverity();
var_dump($e->getSeverity() === E_STRICT);
var_dump($e->getMessage() === EXCEPTION_PARAM_MSG);
var_dump($e->getCode() === 0);
var_dump($e->getPrevious() === NULL);
var_dump($e->getFile() === __FILE__);
var_dump($e->getTraceAsString() === EXCEPTION_TRACE_AS_STRING_MSG);
}
try {
throw new ErrorException(EXCEPTION_PARAM_MSG, EXCEPTION_CODE_ERROR, E_RECOVERABLE_ERROR);
} catch(ErrorException $e) {
@ -384,18 +372,6 @@ try {
var_dump($e->getTraceAsString() === EXCEPTION_TRACE_AS_STRING_MSG);
}
try {
throw new ErrorException(EXCEPTION_PARAM_MSG, EXCEPTION_CODE_ERROR, E_STRICT, __FILE__);
} catch(ErrorException $e) {
echo EXCEPTION_SEVERITY_ERROR_MSG . $e->getSeverity();
var_dump($e->getSeverity() === E_STRICT);
var_dump($e->getMessage() === EXCEPTION_PARAM_MSG);
var_dump($e->getCode() === 0);
var_dump($e->getPrevious() === NULL);
var_dump($e->getFile() === __FILE__);
var_dump($e->getTraceAsString() === EXCEPTION_TRACE_AS_STRING_MSG);
}
try {
throw new ErrorException(EXCEPTION_PARAM_MSG, EXCEPTION_CODE_ERROR, E_RECOVERABLE_ERROR, __FILE__);
} catch(ErrorException $e) {
@ -576,18 +552,6 @@ try {
var_dump($e->getTraceAsString() === EXCEPTION_TRACE_AS_STRING_MSG);
}
try {
throw new ErrorException(EXCEPTION_PARAM_MSG, EXCEPTION_CODE_ERROR, E_STRICT, __FILE__, __LINE__);
} catch(ErrorException $e) {
echo EXCEPTION_SEVERITY_ERROR_MSG . $e->getSeverity();
var_dump($e->getSeverity() === E_STRICT);
var_dump($e->getMessage() === EXCEPTION_PARAM_MSG);
var_dump($e->getCode() === 0);
var_dump($e->getPrevious() === NULL);
var_dump($e->getFile() === __FILE__);
var_dump($e->getTraceAsString() === EXCEPTION_TRACE_AS_STRING_MSG);
}
try {
throw new ErrorException(EXCEPTION_PARAM_MSG, EXCEPTION_CODE_ERROR, E_RECOVERABLE_ERROR, __FILE__, __LINE__);
} catch(ErrorException $e) {
@ -813,22 +777,6 @@ try {
}
}
try {
throw new ErrorException(EXCEPTION_PARAM_MSG, EXCEPTION_CODE_ERROR, E_STRICT, __FILE__, __LINE__, NULL);
} catch(Exception $exceptionErr) {
try {
throw new ErrorException(EXCEPTION_PARAM_MSG, EXCEPTION_CODE_ERROR, E_STRICT, __FILE__, __LINE__, $exceptionErr->getPrevious());
} catch(ErrorException $e) {
echo EXCEPTION_SEVERITY_ERROR_MSG . $e->getSeverity();
var_dump($e->getSeverity() === E_STRICT);
var_dump($e->getMessage() === EXCEPTION_PARAM_MSG);
var_dump($e->getCode() === 0);
var_dump($e->getPrevious() === NULL);
var_dump($e->getFile() === __FILE__);
var_dump($e->getTraceAsString() === EXCEPTION_TRACE_AS_STRING_MSG);
}
}
try {
throw new ErrorException(EXCEPTION_PARAM_MSG, EXCEPTION_CODE_ERROR, E_RECOVERABLE_ERROR, __FILE__, __LINE__, NULL);
} catch(Exception $exceptionErr) {
@ -953,7 +901,91 @@ bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 2048bool(true)
This exception severity is: 4096bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 8192bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 16384bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 1bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 2bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 4bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 8bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 16bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 32bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 32bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 64bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 128bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 256bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 512bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 1024bool(true)
bool(true)
bool(true)
bool(true)
@ -1049,108 +1081,6 @@ bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 2048bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 4096bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 8192bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 16384bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 1bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 2bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 4bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 8bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 16bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 32bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 32bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 64bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 128bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 256bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 512bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 1024bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 2048bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 4096bool(true)
bool(true)
bool(true)
@ -1241,12 +1171,6 @@ bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 2048bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
This exception severity is: 4096bool(true)
bool(true)
bool(true)

View File

@ -34,7 +34,7 @@ var_dump(error_reporting());
echo "Done\n";
?>
--EXPECT--
int(32767)
int(32767)
int(32759)
int(30719)
int(30719)
int(30711)
Done

View File

@ -18,5 +18,5 @@ var_dump(error_reporting());
?>
--EXPECT--
int(32767)
int(32767)
int(30719)
int(30719)

View File

@ -0,0 +1,14 @@
--TEST--
The E_STRICT constant is deprecated
--FILE--
<?php
var_dump(E_ALL);
var_dump(E_STRICT);
?>
--EXPECTF--
int(30719)
Deprecated: Constant E_STRICT is deprecated in %s on line %d
int(2048)

View File

@ -22,5 +22,5 @@ var_dump(error_reporting());
echo "Done\n";
?>
--EXPECT--
int(32767)
int(30719)
Done

View File

@ -23,5 +23,5 @@ var_dump(error_reporting());
echo "Done\n";
?>
--EXPECT--
int(32767)
int(30719)
Done

View File

@ -31,5 +31,5 @@ echo "Done\n";
?>
--EXPECTF--
Warning: Undefined variable $undef2 in %s on line %d
int(32767)
int(30719)
Done

View File

@ -19,5 +19,5 @@ echo "Done\n";
?>
--EXPECTF--
Warning: Undefined variable $undef in %s on line %d
int(32767)
int(30719)
Done

View File

@ -30,5 +30,5 @@ echo "Done\n";
Warning: Undefined variable $undef_value in %s on line %d
Warning: Undefined variable $undef_name in %s on line %d
int(32767)
int(30719)
Done

View File

@ -26,5 +26,5 @@ var_dump(error_reporting());
echo "Done\n";
?>
--EXPECT--
int(32767)
int(30719)
Done

View File

@ -26,5 +26,5 @@ var_dump(error_reporting());
echo "Done\n";
?>
--EXPECT--
int(32767)
int(30719)
Done

View File

@ -28,5 +28,5 @@ echo "Done\n";
?>
--EXPECTF--
Warning: Undefined variable $undef3 in %s on line %d
int(32767)
int(30719)
Done

View File

@ -27,5 +27,5 @@ echo "Done\n";
Warning: Undefined variable $blah in %s on line %d
Warning: Undefined variable $undef2 in %s on line %d
int(32767)
int(30719)
Done

View File

@ -29,6 +29,6 @@ var_dump(error_reporting());
echo "Done\n";
?>
--EXPECT--
int(32767)
int(32759)
int(30719)
int(30711)
Done

View File

@ -31,4 +31,4 @@ new stdClass(exit);
Caught
Caught
Caught
int(32767)
int(30719)

View File

@ -1604,7 +1604,6 @@ static ZEND_COLD void get_filename_lineno(int type, zend_string **filename, uint
case E_COMPILE_WARNING:
case E_ERROR:
case E_NOTICE:
case E_STRICT:
case E_DEPRECATED:
case E_WARNING:
case E_USER_ERROR:

View File

@ -71,6 +71,8 @@ const E_USER_NOTICE = UNKNOWN;
/**
* @var int
* @cvalue E_STRICT
* @deprecated
* @todo Remove in PHP 9.0
*/
const E_STRICT = UNKNOWN;

View File

@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 1da352eeafa0d33ddda4171cca4c7bf18313915f */
* Stub hash: 65be08c1bdace83ad1fa1175fc824262e07eac2a */
static void register_zend_constants_symbols(int module_number)
{
@ -14,7 +14,7 @@ static void register_zend_constants_symbols(int module_number)
REGISTER_LONG_CONSTANT("E_USER_ERROR", E_USER_ERROR, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_USER_WARNING", E_USER_WARNING, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_USER_NOTICE", E_USER_NOTICE, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_STRICT", E_STRICT, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_STRICT", E_STRICT, CONST_PERSISTENT | CONST_DEPRECATED);
REGISTER_LONG_CONSTANT("E_RECOVERABLE_ERROR", E_RECOVERABLE_ERROR, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_DEPRECATED", E_DEPRECATED, CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("E_USER_DEPRECATED", E_USER_DEPRECATED, CONST_PERSISTENT);

View File

@ -31,6 +31,7 @@
#define E_USER_ERROR (1<<8L)
#define E_USER_WARNING (1<<9L)
#define E_USER_NOTICE (1<<10L)
// TODO: Remove in PHP 9.0
#define E_STRICT (1<<11L)
#define E_RECOVERABLE_ERROR (1<<12L)
#define E_DEPRECATED (1<<13L)
@ -39,7 +40,7 @@
/* Indicates that this usually fatal error should not result in a bailout */
#define E_DONT_BAIL (1<<15L)
#define E_ALL (E_ERROR | E_WARNING | E_PARSE | E_NOTICE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE | E_RECOVERABLE_ERROR | E_DEPRECATED | E_USER_DEPRECATED | E_STRICT)
#define E_ALL (E_ERROR | E_WARNING | E_PARSE | E_NOTICE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE | E_RECOVERABLE_ERROR | E_DEPRECATED | E_USER_DEPRECATED)
#define E_CORE (E_CORE_ERROR | E_CORE_WARNING)
/* Fatal errors that are ignored by the silence operator */

View File

@ -70,7 +70,7 @@ foreach($newdirs as $newdir) {
New include path is : %sparse_ini_file_variation3.dir1%sparse_ini_file_variation3.dir2%sparse_ini_file_variation3.dir3%S
array(9) {
["error_reporting"]=>
string(5) "32767"
string(5) "30719"
["display_errors"]=>
string(1) "1"
["display_startup_errors"]=>

View File

@ -21,7 +21,7 @@ array(%d) {
["foo"]=>
array(%d) {
[123]=>
int(24575)
int(22527)
[456]=>
int(123)
}

View File

@ -15,17 +15,17 @@ array(3) {
["error_reporting values"]=>
array(6) {
["foo"]=>
string(7) "32767 8"
string(7) "30719 8"
["error_reporting"]=>
string(5) "32767"
string(5) "30719"
["error_reporting1"]=>
string(4) "4177"
["error_reporting2"]=>
string(5) "32759"
string(5) "30711"
["error_reporting3"]=>
string(5) "32759"
string(5) "30711"
["error_reporting4"]=>
string(5) "32759"
string(5) "30711"
}
["true or false"]=>
array(8) {

View File

@ -1369,10 +1369,6 @@ static ZEND_COLD void php_error_cb(int orig_type, zend_string *error_filename, c
error_type_str = "Notice";
syslog_type_int = LOG_NOTICE;
break;
case E_STRICT:
error_type_str = "Strict Standards";
syslog_type_int = LOG_INFO;
break;
case E_DEPRECATED:
case E_USER_DEPRECATED:
error_type_str = "Deprecated";

View File

@ -107,7 +107,7 @@
; error_reporting
; Default Value: E_ALL
; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
; log_errors
; Default Value: Off
@ -442,7 +442,7 @@ memory_limit = 128M
; operators. The error level constants are below here for convenience as well as
; some common settings and their meanings.
; By default, PHP is set to take action on all errors, notices and warnings EXCEPT
; those related to E_NOTICE and E_STRICT, which together cover best practices and
; those related to E_NOTICE, which together cover best practices and
; recommended coding standards in PHP. For performance reasons, this is the
; recommend error reporting setting. Your production server shouldn't be wasting
; resources complaining about best practices and coding standards. That's what
@ -462,9 +462,6 @@ memory_limit = 128M
; intentional (e.g., using an uninitialized variable and
; relying on the fact it is automatically initialized to an
; empty string)
; E_STRICT - run-time notices, enable to have PHP suggest changes
; to your code which will ensure the best interoperability
; and forward compatibility of your code
; E_CORE_ERROR - fatal errors that occur during PHP's initial startup
; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's
; initial startup
@ -480,11 +477,10 @@ memory_limit = 128M
; Common Values:
; E_ALL (Show all errors, warnings and notices including coding standards.)
; E_ALL & ~E_NOTICE (Show all errors, except for notices)
; E_ALL & ~E_NOTICE & ~E_STRICT (Show all errors, except for notices and coding standards warnings.)
; E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors)
; Default Value: E_ALL
; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
; https://php.net/error-reporting
error_reporting = E_ALL

View File

@ -107,7 +107,7 @@
; error_reporting
; Default Value: E_ALL
; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
; log_errors
; Default Value: Off
@ -444,7 +444,7 @@ memory_limit = 128M
; operators. The error level constants are below here for convenience as well as
; some common settings and their meanings.
; By default, PHP is set to take action on all errors, notices and warnings EXCEPT
; those related to E_NOTICE and E_STRICT, which together cover best practices and
; those related to E_NOTICE, which together cover best practices and
; recommended coding standards in PHP. For performance reasons, this is the
; recommend error reporting setting. Your production server shouldn't be wasting
; resources complaining about best practices and coding standards. That's what
@ -464,9 +464,6 @@ memory_limit = 128M
; intentional (e.g., using an uninitialized variable and
; relying on the fact it is automatically initialized to an
; empty string)
; E_STRICT - run-time notices, enable to have PHP suggest changes
; to your code which will ensure the best interoperability
; and forward compatibility of your code
; E_CORE_ERROR - fatal errors that occur during PHP's initial startup
; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's
; initial startup
@ -482,13 +479,12 @@ memory_limit = 128M
; Common Values:
; E_ALL (Show all errors, warnings and notices including coding standards.)
; E_ALL & ~E_NOTICE (Show all errors, except for notices)
; E_ALL & ~E_NOTICE & ~E_STRICT (Show all errors, except for notices and coding standards warnings.)
; E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors)
; Default Value: E_ALL
; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
; https://php.net/error-reporting
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
error_reporting = E_ALL & ~E_DEPRECATED
; This directive controls whether or not and where PHP will output errors,
; notices and warnings too. Error output is very useful during development, but

View File

@ -1616,7 +1616,6 @@ escape:
'E_USER_ERROR',
'E_USER_WARNING',
'E_USER_NOTICE',
'E_STRICT', // TODO Cleanup when removed from Zend Engine.
'E_RECOVERABLE_ERROR',
'E_DEPRECATED',
'E_USER_DEPRECATED'

View File

@ -29,7 +29,7 @@ $tester->start(['-tt']);
$tester->expectLogConfigOptions([
'access.suppress_path[] = /ping',
'access.suppress_path[] = /health_check.php',
'php_value[error_reporting] = 32767',
'php_value[error_reporting] = 30719',
'php_value[date.timezone] = Europe/London',
'php_value[display_errors] = 1',
'php_admin_value[disable_functions] = eval',

View File

@ -7,4 +7,4 @@ error_reporting = E_ALL ^ E_NOTICE ^ E_WARNING ^ E_DEPRECATED
echo ini_get('error_reporting');
?>
--EXPECT--
24565
22517