Skip to content

Commit b3c7ab6

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fixed bug #79434
2 parents 87375fa + cf68bc4 commit b3c7ab6

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

Zend/tests/case_insensitive_constant_deprecation.phpt

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace {
99

1010
var_dump(FOO); // Ok
1111
var_dump(foo); // Deprecated
12+
var_dump(\foo); // Deprecated
1213

1314
var_dump(NS\FOO); // Ok
1415
var_dump(ns\FOO); // Ok
@@ -72,10 +73,13 @@ int(42)
7273

7374
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 8
7475
int(42)
76+
77+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 9
78+
int(42)
7579
int(24)
7680
int(24)
7781

78-
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 12
82+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 13
7983
int(24)
8084
bool(true)
8185
bool(true)
@@ -84,24 +88,24 @@ bool(true)
8488
bool(true)
8589
int(42)
8690

87-
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 21
91+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 22
8892
int(42)
8993
int(24)
9094
int(24)
9195

92-
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 24
96+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 25
9397
int(24)
9498
int(24)
9599

96-
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 29
100+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 30
97101
int(24)
98102
int(24)
99103

100-
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 34
104+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 35
101105
int(24)
102106
int(42)
103107

104-
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 39
108+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 40
105109
int(42)
106110
bool(true)
107111
bool(true)
@@ -110,18 +114,18 @@ bool(true)
110114
bool(true)
111115
int(42)
112116

113-
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 48
117+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 49
114118
int(42)
115119
int(24)
116120
int(24)
117121

118-
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 51
122+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 52
119123
int(24)
120124
int(42)
121125

122-
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 55
126+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 56
123127
int(42)
124128
int(43)
125129

126-
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 59
130+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 60
127131
int(43)

Zend/zend_execute.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4416,11 +4416,15 @@ static zend_always_inline int _zend_quick_get_constant(
44164416
is_deprecated = !zend_string_equals(c->name, Z_STR_P(access_key));
44174417
} else {
44184418
check_short_name:
4419-
ns_sep = zend_memrchr(ZSTR_VAL(c->name), '\\', ZSTR_LEN(c->name));
4420-
ZEND_ASSERT(ns_sep);
44214419
/* Namespaces are always case-insensitive. Only compare shortname. */
4422-
shortname_offset = ns_sep - ZSTR_VAL(c->name) + 1;
4423-
shortname_len = ZSTR_LEN(c->name) - shortname_offset;
4420+
ns_sep = zend_memrchr(ZSTR_VAL(c->name), '\\', ZSTR_LEN(c->name));
4421+
if (ns_sep) {
4422+
shortname_offset = ns_sep - ZSTR_VAL(c->name) + 1;
4423+
shortname_len = ZSTR_LEN(c->name) - shortname_offset;
4424+
} else {
4425+
shortname_offset = 0;
4426+
shortname_len = ZSTR_LEN(c->name);
4427+
}
44244428

44254429
is_deprecated = memcmp(ZSTR_VAL(c->name) + shortname_offset, Z_STRVAL_P(orig_key - 1) + shortname_offset, shortname_len) != 0;
44264430
}

0 commit comments

Comments
 (0)