com php-src: Remove ability to declare userland case-insensitive constants: UPGRADING Zend/tests/bug46304.phpt Zend/tests/case_insensitiv
e_constant_deprecation.phpt Zend/zend_builtin_funct ions.c

From: Date: Wed, 30 Jan 2019 08:19:02 +0000
Subject: com php-src: Remove ability to declare userland case-insensitive constants: UPGRADING Zend/tests/bug46304.phpt Zend/tests/case_insensitiv
e_constant_deprecation.phpt Zend/zend_builtin_funct ions.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-104394@lists.php.net to get a copy of this message
Commit: 23a5be3696f4d92e1b18fd59f3ac63c6a15ea12a Author: Nikita Popov <nikita.ppv@gmail.com> Tue, 29 Jan 2019 13:36:26 +0100 Parents: 90bb326100e04f56deb27764e5da07074e01888d Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=23a5be3696f4d92e1b18fd59f3ac63c6a15ea12a Log: Remove ability to declare userland case-insensitive constants This is part of https://wiki.php.net/rfc/case_insensitive_constant_deprecation. This commit only removes the ability to declare such constants from userland. Before the functionality can be removed entirely, it's necessary to figure out the handling of true/false/null first. Changed paths: M UPGRADING M Zend/tests/bug46304.phpt D Zend/tests/case_insensitive_constant_deprecation.phpt M Zend/zend_builtin_functions.c Diff: diff --git a/UPGRADING b/UPGRADING index 1dfd9da..0f2b9a5 100644 --- a/UPGRADING +++ b/UPGRADING @@ -26,6 +26,8 @@ PHP 8.0 UPGRADE NOTES . Removed (unset) cast. . Removed track_errors ini directive. This means that $php_errormsg is no longer available. The error_get_last() function may be used instead. + . Removed the ability to define case-insensitive constants. The third + argument to define() may no longer be true. . Removed create_function(). Anonymous functions may be used instead. . Removed each(). foreach or ArrayIterator should be used instead. diff --git a/Zend/tests/bug46304.phpt b/Zend/tests/bug46304.phpt index 9898838..f8b9a0b 100644 --- a/Zend/tests/bug46304.phpt +++ b/Zend/tests/bug46304.phpt @@ -6,9 +6,6 @@ Bug #46304 (defining namespaced constant using define()) define('NS1\ns2\const1','value1'); define('ns1\ns2\const2','value2'); define('ns1\NS2\coNSt3','value3'); -define('NS1\ns2\const4','value4', true); -define('ns1\ns2\const5','value5', true); -define('ns1\NS2\coNSt6','value6', true); print NS1\ns2\const1 . "\n"; print ns1\ns2\const1 . "\n"; @@ -22,29 +19,9 @@ print NS1\ns2\coNSt3 . "\n"; print ns1\ns2\coNSt3 . "\n"; print ns1\ns2\coNSt3 . "\n"; -print NS1\ns2\const4 . "\n"; -print ns1\ns2\const4 . "\n"; -print ns1\NS2\const4 . "\n"; -print ns1\ns2\coNSt4 . "\n"; - -print NS1\ns2\const5 . "\n"; -print ns1\ns2\const5 . "\n"; -print ns1\NS2\const5 . "\n"; -print ns1\ns2\coNSt5 . "\n"; - -print NS1\ns2\const6 . "\n"; -print ns1\ns2\const6 . "\n"; -print ns1\NS2\const6 . "\n"; -print ns1\ns2\coNSt6 . "\n"; - print NS1\ns2\coNSt1 . "\n"; ?> --EXPECTF-- -Deprecated: define(): Declaration of case-insensitive constants is deprecated in %s on line 6 - -Deprecated: define(): Declaration of case-insensitive constants is deprecated in %s on line 7 - -Deprecated: define(): Declaration of case-insensitive constants is deprecated in %s on line 8 value1 value1 value1 @@ -54,28 +31,6 @@ value2 value3 value3 value3 -value4 -value4 -value4 - -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS1\ns2\const4" in %s on line 25 -value4 -value5 -value5 -value5 - -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "ns1\ns2\const5" in %s on line 30 -value5 - -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "ns1\NS2\coNSt6" in %s on line 32 -value6 - -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "ns1\NS2\coNSt6" in %s on line 33 -value6 - -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "ns1\NS2\coNSt6" in %s on line 34 -value6 -value6 Fatal error: Uncaught Error: Undefined constant 'NS1\ns2\coNSt1' in %sbug46304.php:%d Stack trace: diff --git a/Zend/tests/case_insensitive_constant_deprecation.phpt b/Zend/tests/case_insensitive_constant_deprecation.phpt deleted file mode 100644 index e7a92c8..0000000 --- a/Zend/tests/case_insensitive_constant_deprecation.phpt +++ /dev/null @@ -1,127 +0,0 @@ ---TEST-- -Case-insensitive constants are deprecated ---FILE-- -<?php - -namespace { - define('FOO', 42, true); // Deprecated - define('NS\FOO', 24, true); // Deprecated - - var_dump(FOO); // Ok - var_dump(foo); // Deprecated - - var_dump(NS\FOO); // Ok - var_dump(ns\FOO); // Ok - var_dump(ns\foo); // Deprecated - - var_dump(defined('FOO')); // Ok - var_dump(defined('foo')); // Ok - var_dump(defined('NS\FOO')); // Ok - var_dump(defined('ns\FOO')); // Ok - var_dump(defined('ns\foo')); // Ok - - var_dump(constant('FOO')); // Ok - var_dump(constant('foo')); // Deprecated - var_dump(constant('NS\FOO')); // Ok - var_dump(constant('ns\FOO')); // Ok - var_dump(constant('ns\foo')); // Deprecated -} - -namespace NS { - var_dump(FOO); // Ok - var_dump(foo); // Deprecated -} - -namespace ns { - var_dump(FOO); // Ok - var_dump(foo); // Deprecated -} - -namespace Other { - var_dump(FOO); // Ok - var_dump(foo); // Deprecated - - var_dump(defined('FOO')); // Ok - var_dump(defined('foo')); // Ok - var_dump(defined('NS\FOO')); // Ok - var_dump(defined('ns\FOO')); // Ok - var_dump(defined('ns\foo')); // Ok - - var_dump(constant('FOO')); // Ok - var_dump(constant('foo')); // Deprecated - var_dump(constant('NS\FOO')); // Ok - var_dump(constant('ns\FOO')); // Ok - var_dump(constant('ns\foo')); // Deprecated - - const C1 = FOO; // Ok - var_dump(C1); - const C2 = foo; // Deprecated - var_dump(C2); - const C3 = 1 + FOO; // Ok - var_dump(C3); - const C4 = 1 + foo; // Deprecated - var_dump(C4); -} - -?> ---EXPECTF-- -Deprecated: define(): Declaration of case-insensitive constants is deprecated in %s on line 4 - -Deprecated: define(): Declaration of case-insensitive constants is deprecated in %s on line 5 -int(42) - -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 8 -int(42) -int(24) -int(24) - -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 12 -int(24) -bool(true) -bool(true) -bool(true) -bool(true) -bool(true) -int(42) - -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 21 -int(42) -int(24) -int(24) - -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 24 -int(24) -int(24) - -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 29 -int(24) -int(24) - -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 34 -int(24) -int(42) - -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 39 -int(42) -bool(true) -bool(true) -bool(true) -bool(true) -bool(true) -int(42) - -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 48 -int(42) -int(24) -int(24) - -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 51 -int(24) -int(42) - -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 55 -int(42) -int(43) - -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 59 -int(43) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 14c8fd3..87f54ed 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -765,7 +765,6 @@ ZEND_FUNCTION(define) zend_string *name; zval *val, val_free; zend_bool non_cs = 0; - int case_sensitive = CONST_CS; zend_constant c; ZEND_PARSE_PARAMETERS_START(2, 3) @@ -775,15 +774,17 @@ ZEND_FUNCTION(define) Z_PARAM_BOOL(non_cs) ZEND_PARSE_PARAMETERS_END(); - if (non_cs) { - case_sensitive = 0; - } - if (zend_memnstr(ZSTR_VAL(name), "::", sizeof("::") - 1, ZSTR_VAL(name) + ZSTR_LEN(name))) { zend_error(E_WARNING, "Class constants cannot be defined or redefined"); RETURN_FALSE; } + if (non_cs) { + zend_error(E_WARNING, + "define(): Declaration of case-insensitive constants is no longer supported"); + RETURN_FALSE; + } + ZVAL_UNDEF(&val_free); repeat: @@ -831,13 +832,8 @@ repeat: zval_ptr_dtor(&val_free); register_constant: - if (non_cs) { - zend_error(E_DEPRECATED, - "define(): Declaration of case-insensitive constants is deprecated"); - } - /* non persistent */ - ZEND_CONSTANT_SET_FLAGS(&c, case_sensitive, PHP_USER_CONSTANT); + ZEND_CONSTANT_SET_FLAGS(&c, CONST_CS, PHP_USER_CONSTANT); c.name = zend_string_copy(name); if (zend_register_constant(&c) == SUCCESS) { RETURN_TRUE;

« previous php.cvs (#104394) next »