Skip to content

Remove E_STRICT error level and deprecate E_STRICT constant #13053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
76 changes: 0 additions & 76 deletions Zend/tests/ErrorException_getSeverity.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -953,12 +901,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)
Expand Down Expand Up @@ -1049,12 +991,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)
Expand Down Expand Up @@ -1145,12 +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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions Zend/tests/bug33771.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions Zend/tests/bug81652.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ var_dump(error_reporting());

?>
--EXPECT--
int(32767)
int(32767)
int(30719)
int(30719)
14 changes: 14 additions & 0 deletions Zend/tests/e_strict-deprecated.phpt
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion Zend/tests/error_reporting01.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ var_dump(error_reporting());
echo "Done\n";
?>
--EXPECT--
int(32767)
int(30719)
Done
2 changes: 1 addition & 1 deletion Zend/tests/error_reporting02.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ var_dump(error_reporting());
echo "Done\n";
?>
--EXPECT--
int(32767)
int(30719)
Done
2 changes: 1 addition & 1 deletion Zend/tests/error_reporting03.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ echo "Done\n";
?>
--EXPECTF--
Warning: Undefined variable $undef2 in %s on line %d
int(32767)
int(30719)
Done
2 changes: 1 addition & 1 deletion Zend/tests/error_reporting04.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ echo "Done\n";
?>
--EXPECTF--
Warning: Undefined variable $undef in %s on line %d
int(32767)
int(30719)
Done
2 changes: 1 addition & 1 deletion Zend/tests/error_reporting05.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Zend/tests/error_reporting06.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ var_dump(error_reporting());
echo "Done\n";
?>
--EXPECT--
int(32767)
int(30719)
Done
2 changes: 1 addition & 1 deletion Zend/tests/error_reporting07.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ var_dump(error_reporting());
echo "Done\n";
?>
--EXPECT--
int(32767)
int(30719)
Done
2 changes: 1 addition & 1 deletion Zend/tests/error_reporting08.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ echo "Done\n";
?>
--EXPECTF--
Warning: Undefined variable $undef3 in %s on line %d
int(32767)
int(30719)
Done
2 changes: 1 addition & 1 deletion Zend/tests/error_reporting09.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions Zend/tests/error_reporting10.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ var_dump(error_reporting());
echo "Done\n";
?>
--EXPECT--
int(32767)
int(32759)
int(30719)
int(30711)
Done
2 changes: 1 addition & 1 deletion Zend/tests/throw/leaks.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ new stdClass(exit);
Caught
Caught
Caught
int(32767)
int(30719)
1 change: 0 additions & 1 deletion Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions Zend/zend_constants.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
/**
* @var int
* @cvalue E_STRICT
* @deprecated
* @todo Remove in PHP 9.0
*/
const E_STRICT = UNKNOWN;

Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_constants_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Zend/zend_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/tests/file/parse_ini_file_variation3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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"]=>
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/tests/general_functions/bug70157.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ array(%d) {
["foo"]=>
array(%d) {
[123]=>
int(24575)
int(22527)
[456]=>
int(123)
}
Expand Down
10 changes: 5 additions & 5 deletions ext/standard/tests/general_functions/parse_ini_booleans.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 0 additions & 4 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
10 changes: 3 additions & 7 deletions php.ini-development
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down
Loading
Loading