Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ext/standard/basic_functions.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2310,16 +2310,16 @@ function strcoll(string $string1, string $string2): int {}
* @frameless-function {"arity": 1}
* @frameless-function {"arity": 2}
*/
function trim(string $string, string $characters = " \n\r\t\v\0"): string {}
function trim(string $string, string $characters = " \f\n\r\t\v\0"): string {}

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

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

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

/**
* @compile-time-eval
Expand Down
8 changes: 4 additions & 4 deletions ext/standard/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ static inline zend_result php_charmask(const unsigned char *input, size_t len, c
* mode 1 : trim left
* mode 2 : trim right
* mode 3 : trim left and right
* what indicates which chars are to be trimmed. NULL->default (' \t\n\r\v\0')
* what indicates which chars are to be trimmed. NULL->default (' \f\t\n\r\v\0')
*/
static zend_always_inline zend_string *php_trim_int(zend_string *str, const char *what, size_t what_len, int mode)
{
Expand Down Expand Up @@ -576,7 +576,7 @@ static zend_always_inline zend_string *php_trim_int(zend_string *str, const char
unsigned char c = (unsigned char)*start;

if (c <= ' ' &&
(c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == '\0')) {
(c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == '\0')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: personal opinion would be nice to share a helper for both cases e.g.

static zend_always_inline bool php_is_whitespace(char c)
{
    ...
}

but no need to bother now until the topic is discussed at least.

start++;
} else {
break;
Expand All @@ -588,7 +588,7 @@ static zend_always_inline zend_string *php_trim_int(zend_string *str, const char
unsigned char c = (unsigned char)*(end-1);

if (c <= ' ' &&
(c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == '\0')) {
(c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == '\0')) {
end--;
} else {
break;
Expand All @@ -611,7 +611,7 @@ static zend_always_inline zend_string *php_trim_int(zend_string *str, const char
* mode 1 : trim left
* mode 2 : trim right
* mode 3 : trim left and right
* what indicates which chars are to be trimmed. NULL->default (' \t\n\r\v\0')
* what indicates which chars are to be trimmed. NULL->default (' \f\t\n\r\v\0')
*/
PHPAPI zend_string *php_trim(zend_string *str, const char *what, size_t what_len, int mode)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/classes/tostring_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class test2
function __toString()
{
echo __METHOD__ . "()\n";
return "Converted\n";
return "\fConverted\n";
}
}

Expand Down
Loading