Merge branch 'PHP-8.1' into PHP-8.2

* PHP-8.1:
  Fix GH-9905: constant() behaves inconsistent when class is undefined
This commit is contained in:
Christoph M. Becker 2022-11-09 15:22:45 +01:00
commit 4b1feda574
No known key found for this signature in database
GPG Key ID: D66C9593118BCCB6
4 changed files with 18 additions and 3 deletions

4
NEWS
View File

@ -2,6 +2,10 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.2.1
- Core:
. Fixed bug GH-9905 (constant() behaves inconsistent when class is undefined).
(cmb)
27 Nov 2022, PHP 8.2.0
- CLI:

View File

@ -525,7 +525,7 @@ PHP_FUNCTION(constant)
ZEND_PARSE_PARAMETERS_END();
scope = zend_get_executed_scope();
c = zend_get_constant_ex(const_name, scope, 0);
c = zend_get_constant_ex(const_name, scope, ZEND_FETCH_CLASS_EXCEPTION);
if (!c) {
RETURN_THROWS();
}

View File

@ -0,0 +1,12 @@
--TEST--
GH-9905 (constant() behaves inconsistent when class is undefined)
--FILE--
<?php
try {
\constant("\NonExistantClass::non_existant_constant");
} catch (\Throwable|\Error|\Exception $e) {
echo($e->getMessage());
}
?>
--EXPECT--
Class "NonExistantClass" not found

View File

@ -21,5 +21,4 @@ try {
?>
--EXPECTF--
define(): Argument #1 ($constant_name) cannot be a class constant
Fatal error: Class "" not found in %s on line %d
Class "" not found