Skip to content

Commit 8aa01f7

Browse files
committed
fixes
1 parent 7b61dd2 commit 8aa01f7

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

Zend/tests/constants/class_constants_005.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ String interning during constants substitution
44
opcache.enable_cli=0
55
--FILE--
66
<?php
7-
define ("A", "." . ord(26) . ".");
7+
define ("A", "." . ord(2) . ".");
88
eval("class A {const a = A;}");
99
var_dump(A::a);
1010
?>

Zend/tests/nullsafe_operator/013.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Deprecated: chr(): Passing null to parameter #1 ($codepoint) of type int is depr
5353
string(1) "%s"
5454

5555
Deprecated: ord(): Passing null to parameter #1 ($character) of type string is deprecated in %s on line %d
56+
57+
Deprecated: ord(): Providing an empty string is deprecated in %s on line %d
5658
int(0)
5759
string(98) "call_user_func_array(): Argument #1 ($callback) must be a valid callback, no array or string given"
5860
string(77) "call_user_func_array(): Argument #2 ($args) must be of type array, null given"

ext/standard/string.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2652,8 +2652,13 @@ PHP_FUNCTION(ord)
26522652
ZEND_PARSE_PARAMETERS_END();
26532653

26542654
if (UNEXPECTED(ZSTR_LEN(str) != 1)) {
2655-
php_error_docref(NULL, E_DEPRECATED,
2656-
"Providing a string which is not one byte long is deprecated, use ord($str[0]) instead");
2655+
if (ZSTR_LEN(str) == 0) {
2656+
php_error_docref(NULL, E_DEPRECATED,
2657+
"Providing an empty string is deprecated");
2658+
} else {
2659+
php_error_docref(NULL, E_DEPRECATED,
2660+
"Providing a string which is not one byte long is deprecated, use ord($str[0]) instead");
2661+
}
26572662
}
26582663
RETURN_LONG((unsigned char) ZSTR_VAL(str)[0]);
26592664
}

ext/standard/tests/strings/ord_not_1_byte.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var_dump(ord("Hello"));
88

99
?>
1010
--EXPECTF--
11-
Deprecated: ord(): Providing a string which is not one byte long is deprecated, use ord($str[0]) instead in %s on line 3
11+
Deprecated: ord(): Providing an empty string is deprecated in %s on line 3
1212
int(0)
1313

1414
Deprecated: ord(): Providing a string which is not one byte long is deprecated, use ord($str[0]) instead in %s on line 4

0 commit comments

Comments
 (0)