Skip to content

Commit bb21510

Browse files
committed
fix test
1 parent 99b9b33 commit bb21510

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

ext/standard/basic_functions.stub.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,16 +2310,16 @@ function strcoll(string $string1, string $string2): int {}
23102310
* @frameless-function {"arity": 1}
23112311
* @frameless-function {"arity": 2}
23122312
*/
2313-
function trim(string $string, string $characters = " \f\n\r\t\v\0"): string {}
2313+
function trim(string $string, string $characters = " \n\r\t\v\0"): string {}
23142314

23152315
/** @compile-time-eval */
2316-
function rtrim(string $string, string $characters = " \f\n\r\t\v\0"): string {}
2316+
function rtrim(string $string, string $characters = " \n\r\t\v\0"): string {}
23172317

23182318
/** @alias rtrim */
2319-
function chop(string $string, string $characters = " \f\n\r\t\v\0"): string {}
2319+
function chop(string $string, string $characters = " \n\r\t\v\0"): string {}
23202320

23212321
/** @compile-time-eval */
2322-
function ltrim(string $string, string $characters = " \f\n\r\t\v\0"): string {}
2322+
function ltrim(string $string, string $characters = " \n\r\t\v\0"): string {}
23232323

23242324
/**
23252325
* @compile-time-eval

ext/standard/string.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ static inline zend_result php_charmask(const unsigned char *input, size_t len, c
519519
* mode 1 : trim left
520520
* mode 2 : trim right
521521
* mode 3 : trim left and right
522-
* what indicates which chars are to be trimmed. NULL->default (' \f\t\n\r\v\0')
522+
* what indicates which chars are to be trimmed. NULL->default (' \t\n\r\v\0')
523523
*/
524524
static zend_always_inline zend_string *php_trim_int(zend_string *str, const char *what, size_t what_len, int mode)
525525
{
@@ -576,7 +576,7 @@ static zend_always_inline zend_string *php_trim_int(zend_string *str, const char
576576
unsigned char c = (unsigned char)*start;
577577

578578
if (c <= ' ' &&
579-
(c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == '\0')) {
579+
(c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == '\f' || c == '\0')) {
580580
start++;
581581
} else {
582582
break;
@@ -588,7 +588,7 @@ static zend_always_inline zend_string *php_trim_int(zend_string *str, const char
588588
unsigned char c = (unsigned char)*(end-1);
589589

590590
if (c <= ' ' &&
591-
(c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == '\0')) {
591+
(c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == '\f' || c == '\0')) {
592592
end--;
593593
} else {
594594
break;
@@ -611,7 +611,7 @@ static zend_always_inline zend_string *php_trim_int(zend_string *str, const char
611611
* mode 1 : trim left
612612
* mode 2 : trim right
613613
* mode 3 : trim left and right
614-
* what indicates which chars are to be trimmed. NULL->default (' \f\t\n\r\v\0')
614+
* what indicates which chars are to be trimmed. NULL->default (' \t\n\r\v\0')
615615
*/
616616
PHPAPI zend_string *php_trim(zend_string *str, const char *what, size_t what_len, int mode)
617617
{

tests/classes/tostring_001.phpt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class test2
1212
function __toString()
1313
{
1414
echo __METHOD__ . "()\n";
15-
return "\fConverted\n";
15+
return "Converted\n";
1616
}
1717
}
1818

@@ -24,6 +24,16 @@ class test3
2424
return [];
2525
}
2626
}
27+
28+
class test4
29+
{
30+
function __toString()
31+
{
32+
echo __METHOD__ . "()\n";
33+
return "Converted\f";
34+
}
35+
}
36+
2737
echo "====test1====\n";
2838
$o = new test1;
2939
print_r($o);
@@ -77,7 +87,9 @@ try {
7787
} catch (Error $e) {
7888
echo $e->getMessage(), "\n";
7989
}
80-
90+
echo "====test11====\n";
91+
$o = new test4();
92+
var_dump(trim($o));
8193
?>
8294
====DONE====
8395
--EXPECT--
@@ -132,4 +144,7 @@ object(test3)#2 (0) {
132144
}
133145
test3::__toString()
134146
test3::__toString(): Return value must be of type string, array returned
147+
====test11====
148+
test4::__toString()
149+
string(9) "Converted"
135150
====DONE====

0 commit comments

Comments
 (0)