Always treat needles as strings

This is part of https://wiki.php.net/rfc/deprecations_php_7_3.
This commit is contained in:
Nikita Popov 2019-01-29 10:02:03 +01:00
parent c7d7af8069
commit c97b9aa226
31 changed files with 209 additions and 1074 deletions

View File

@ -76,6 +76,11 @@ PHP 8.0 UPGRADE NOTES
. parse_str() can no longer be used without specifying a result array.
. fgetss() has been removed.
. The string.strip_tags filter has been removed.
. The needle argument of strpos(), strrpos(), stripos(), strripos(), strstr(),
strchr(), strrchr(), and stristr() will now always be interpreted as a
string. Previously non-string needles were interpreted as an ASCII code
point. An explicit call to chr() can be used to restore the previous
behavior.
- Zlib:
. gzgetss() has been removed.

View File

@ -1813,79 +1813,34 @@ PHPAPI size_t php_strcspn(char *s1, char *s2, char *s1_end, char *s2_end)
}
/* }}} */
/* {{{ php_needle_char
*/
static int php_needle_char(zval *needle, char *target)
{
switch (Z_TYPE_P(needle)) {
case IS_LONG:
*target = (char)Z_LVAL_P(needle);
return SUCCESS;
case IS_NULL:
case IS_FALSE:
*target = '\0';
return SUCCESS;
case IS_TRUE:
*target = '\1';
return SUCCESS;
case IS_DOUBLE:
*target = (char)(int)Z_DVAL_P(needle);
return SUCCESS;
case IS_OBJECT:
*target = (char) zval_get_long(needle);
return SUCCESS;
default:
php_error_docref(NULL, E_WARNING, "needle is not a string or an integer");
return FAILURE;
}
}
/* }}} */
/* {{{ proto string stristr(string haystack, string needle[, bool part])
Finds first occurrence of a string within another, case insensitive */
PHP_FUNCTION(stristr)
{
zval *needle;
zend_string *haystack;
zend_string *haystack, *needle;
const char *found = NULL;
size_t found_offset;
char *haystack_dup;
char needle_char[2];
char *orig_needle;
zend_bool part = 0;
ZEND_PARSE_PARAMETERS_START(2, 3)
Z_PARAM_STR(haystack)
Z_PARAM_ZVAL(needle)
Z_PARAM_STR(needle)
Z_PARAM_OPTIONAL
Z_PARAM_BOOL(part)
ZEND_PARSE_PARAMETERS_END();
haystack_dup = estrndup(ZSTR_VAL(haystack), ZSTR_LEN(haystack));
if (Z_TYPE_P(needle) == IS_STRING) {
char *orig_needle;
if (!Z_STRLEN_P(needle)) {
php_error_docref(NULL, E_WARNING, "Empty needle");
efree(haystack_dup);
RETURN_FALSE;
}
orig_needle = estrndup(Z_STRVAL_P(needle), Z_STRLEN_P(needle));
found = php_stristr(haystack_dup, orig_needle, ZSTR_LEN(haystack), Z_STRLEN_P(needle));
efree(orig_needle);
} else {
if (php_needle_char(needle, needle_char) != SUCCESS) {
efree(haystack_dup);
RETURN_FALSE;
}
needle_char[1] = 0;
php_error_docref(NULL, E_DEPRECATED,
"Non-string needles will be interpreted as strings in the future. " \
"Use an explicit chr() call to preserve the current behavior");
found = php_stristr(haystack_dup, needle_char, ZSTR_LEN(haystack), 1);
if (!ZSTR_LEN(needle)) {
php_error_docref(NULL, E_WARNING, "Empty needle");
RETURN_FALSE;
}
haystack_dup = estrndup(ZSTR_VAL(haystack), ZSTR_LEN(haystack));
orig_needle = estrndup(ZSTR_VAL(needle), ZSTR_LEN(needle));
found = php_stristr(haystack_dup, orig_needle, ZSTR_LEN(haystack), ZSTR_LEN(needle));
efree(orig_needle);
if (found) {
found_offset = found - haystack_dup;
if (part) {
@ -1905,40 +1860,25 @@ PHP_FUNCTION(stristr)
Finds first occurrence of a string within another */
PHP_FUNCTION(strstr)
{
zval *needle;
zend_string *haystack;
zend_string *haystack, *needle;
const char *found = NULL;
char needle_char[2];
zend_long found_offset;
zend_bool part = 0;
ZEND_PARSE_PARAMETERS_START(2, 3)
Z_PARAM_STR(haystack)
Z_PARAM_ZVAL(needle)
Z_PARAM_STR(needle)
Z_PARAM_OPTIONAL
Z_PARAM_BOOL(part)
ZEND_PARSE_PARAMETERS_END();
if (Z_TYPE_P(needle) == IS_STRING) {
if (!Z_STRLEN_P(needle)) {
php_error_docref(NULL, E_WARNING, "Empty needle");
RETURN_FALSE;
}
found = php_memnstr(ZSTR_VAL(haystack), Z_STRVAL_P(needle), Z_STRLEN_P(needle), ZSTR_VAL(haystack) + ZSTR_LEN(haystack));
} else {
if (php_needle_char(needle, needle_char) != SUCCESS) {
RETURN_FALSE;
}
needle_char[1] = 0;
php_error_docref(NULL, E_DEPRECATED,
"Non-string needles will be interpreted as strings in the future. " \
"Use an explicit chr() call to preserve the current behavior");
found = php_memnstr(ZSTR_VAL(haystack), needle_char, 1, ZSTR_VAL(haystack) + ZSTR_LEN(haystack));
if (!ZSTR_LEN(needle)) {
php_error_docref(NULL, E_WARNING, "Empty needle");
RETURN_FALSE;
}
found = php_memnstr(ZSTR_VAL(haystack), ZSTR_VAL(needle), ZSTR_LEN(needle), ZSTR_VAL(haystack) + ZSTR_LEN(haystack));
if (found) {
found_offset = found - ZSTR_VAL(haystack);
if (part) {
@ -1959,15 +1899,13 @@ PHP_FUNCTION(strstr)
Finds position of first occurrence of a string within another */
PHP_FUNCTION(strpos)
{
zval *needle;
zend_string *haystack;
zend_string *haystack, *needle;
const char *found = NULL;
char needle_char[2];
zend_long offset = 0;
zend_long offset = 0;
ZEND_PARSE_PARAMETERS_START(2, 3)
Z_PARAM_STR(haystack)
Z_PARAM_ZVAL(needle)
Z_PARAM_STR(needle)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(offset)
ZEND_PARSE_PARAMETERS_END();
@ -1980,32 +1918,15 @@ PHP_FUNCTION(strpos)
RETURN_FALSE;
}
if (Z_TYPE_P(needle) == IS_STRING) {
if (!Z_STRLEN_P(needle)) {
php_error_docref(NULL, E_WARNING, "Empty needle");
RETURN_FALSE;
}
found = (char*)php_memnstr(ZSTR_VAL(haystack) + offset,
Z_STRVAL_P(needle),
Z_STRLEN_P(needle),
ZSTR_VAL(haystack) + ZSTR_LEN(haystack));
} else {
if (php_needle_char(needle, needle_char) != SUCCESS) {
RETURN_FALSE;
}
needle_char[1] = 0;
php_error_docref(NULL, E_DEPRECATED,
"Non-string needles will be interpreted as strings in the future. " \
"Use an explicit chr() call to preserve the current behavior");
found = (char*)php_memnstr(ZSTR_VAL(haystack) + offset,
needle_char,
1,
ZSTR_VAL(haystack) + ZSTR_LEN(haystack));
if (!ZSTR_LEN(needle)) {
php_error_docref(NULL, E_WARNING, "Empty needle");
RETURN_FALSE;
}
found = (char*)php_memnstr(ZSTR_VAL(haystack) + offset,
ZSTR_VAL(needle), ZSTR_LEN(needle),
ZSTR_VAL(haystack) + ZSTR_LEN(haystack));
if (found) {
RETURN_LONG(found - ZSTR_VAL(haystack));
} else {
@ -2019,15 +1940,13 @@ PHP_FUNCTION(strpos)
PHP_FUNCTION(stripos)
{
const char *found = NULL;
zend_string *haystack;
zend_string *haystack, *needle;
zend_long offset = 0;
char needle_char[2];
zval *needle;
zend_string *needle_dup = NULL, *haystack_dup;
ZEND_PARSE_PARAMETERS_START(2, 3)
Z_PARAM_STR(haystack)
Z_PARAM_ZVAL(needle)
Z_PARAM_STR(needle)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(offset)
ZEND_PARSE_PARAMETERS_END();
@ -2044,33 +1963,14 @@ PHP_FUNCTION(stripos)
RETURN_FALSE;
}
if (Z_TYPE_P(needle) == IS_STRING) {
if (Z_STRLEN_P(needle) == 0 || Z_STRLEN_P(needle) > ZSTR_LEN(haystack)) {
RETURN_FALSE;
}
haystack_dup = php_string_tolower(haystack);
needle_dup = php_string_tolower(Z_STR_P(needle));
found = (char*)php_memnstr(ZSTR_VAL(haystack_dup) + offset,
ZSTR_VAL(needle_dup), ZSTR_LEN(needle_dup), ZSTR_VAL(haystack_dup) + ZSTR_LEN(haystack));
} else {
if (php_needle_char(needle, needle_char) != SUCCESS) {
RETURN_FALSE;
}
php_error_docref(NULL, E_DEPRECATED,
"Non-string needles will be interpreted as strings in the future. " \
"Use an explicit chr() call to preserve the current behavior");
haystack_dup = php_string_tolower(haystack);
needle_char[0] = tolower(needle_char[0]);
needle_char[1] = '\0';
found = (char*)php_memnstr(ZSTR_VAL(haystack_dup) + offset,
needle_char,
sizeof(needle_char) - 1,
ZSTR_VAL(haystack_dup) + ZSTR_LEN(haystack));
if (ZSTR_LEN(needle) == 0 || ZSTR_LEN(needle) > ZSTR_LEN(haystack)) {
RETURN_FALSE;
}
haystack_dup = php_string_tolower(haystack);
needle_dup = php_string_tolower(needle);
found = (char*)php_memnstr(ZSTR_VAL(haystack_dup) + offset,
ZSTR_VAL(needle_dup), ZSTR_LEN(needle_dup), ZSTR_VAL(haystack_dup) + ZSTR_LEN(haystack));
if (found) {
RETVAL_LONG(found - ZSTR_VAL(haystack_dup));
@ -2089,38 +1989,20 @@ PHP_FUNCTION(stripos)
Finds position of last occurrence of a string within another string */
PHP_FUNCTION(strrpos)
{
zval *zneedle;
zend_string *haystack;
char *needle;
size_t needle_len;
zend_long offset = 0;
char ord_needle[2];
const char *p, *e, *found, *needle;
const char *p, *e, *found;
ZEND_PARSE_PARAMETERS_START(2, 3)
Z_PARAM_STR(haystack)
Z_PARAM_ZVAL(zneedle)
Z_PARAM_STRING(needle, needle_len)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(offset)
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
if (Z_TYPE_P(zneedle) == IS_STRING) {
needle = Z_STRVAL_P(zneedle);
needle_len = Z_STRLEN_P(zneedle);
} else {
if (php_needle_char(zneedle, ord_needle) != SUCCESS) {
RETURN_FALSE;
}
php_error_docref(NULL, E_DEPRECATED,
"Non-string needles will be interpreted as strings in the future. " \
"Use an explicit chr() call to preserve the current behavior");
ord_needle[1] = '\0';
needle = ord_needle;
needle_len = 1;
}
if ((ZSTR_LEN(haystack) == 0) || (needle_len == 0)) {
if (ZSTR_LEN(haystack) == 0 || needle_len == 0) {
RETURN_FALSE;
}
@ -2156,49 +2038,29 @@ PHP_FUNCTION(strrpos)
Finds position of last occurrence of a string within another string */
PHP_FUNCTION(strripos)
{
zval *zneedle;
zend_string *needle;
zend_string *haystack;
zend_long offset = 0;
const char *p, *e, *found;
zend_string *needle_dup, *haystack_dup, *ord_needle = NULL;
ALLOCA_FLAG(use_heap);
zend_string *needle_dup, *haystack_dup;
ZEND_PARSE_PARAMETERS_START(2, 3)
Z_PARAM_STR(haystack)
Z_PARAM_ZVAL(zneedle)
Z_PARAM_STR(needle)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(offset)
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
ZSTR_ALLOCA_ALLOC(ord_needle, 1, use_heap);
if (Z_TYPE_P(zneedle) == IS_STRING) {
needle = Z_STR_P(zneedle);
} else {
if (php_needle_char(zneedle, ZSTR_VAL(ord_needle)) != SUCCESS) {
ZSTR_ALLOCA_FREE(ord_needle, use_heap);
RETURN_FALSE;
}
php_error_docref(NULL, E_DEPRECATED,
"Non-string needles will be interpreted as strings in the future. " \
"Use an explicit chr() call to preserve the current behavior");
ZSTR_VAL(ord_needle)[1] = '\0';
needle = ord_needle;
}
if ((ZSTR_LEN(haystack) == 0) || (ZSTR_LEN(needle) == 0)) {
ZSTR_ALLOCA_FREE(ord_needle, use_heap);
if (ZSTR_LEN(haystack) == 0 || ZSTR_LEN(needle) == 0) {
RETURN_FALSE;
}
if (ZSTR_LEN(needle) == 1) {
/* Single character search can shortcut memcmps
Can also avoid tolower emallocs */
char lowered;
if (offset >= 0) {
if ((size_t)offset > ZSTR_LEN(haystack)) {
ZSTR_ALLOCA_FREE(ord_needle, use_heap);
php_error_docref(NULL, E_WARNING, "Offset is greater than the length of haystack string");
RETURN_FALSE;
}
@ -2207,22 +2069,19 @@ PHP_FUNCTION(strripos)
} else {
p = ZSTR_VAL(haystack);
if (offset < -INT_MAX || (size_t)(-offset) > ZSTR_LEN(haystack)) {
ZSTR_ALLOCA_FREE(ord_needle, use_heap);
php_error_docref(NULL, E_WARNING, "Offset is greater than the length of haystack string");
RETURN_FALSE;
}
e = ZSTR_VAL(haystack) + ZSTR_LEN(haystack) + (size_t)offset;
}
/* Borrow that ord_needle buffer to avoid repeatedly tolower()ing needle */
*ZSTR_VAL(ord_needle) = tolower(*ZSTR_VAL(needle));
lowered = tolower(*ZSTR_VAL(needle));
while (e >= p) {
if (tolower(*e) == *ZSTR_VAL(ord_needle)) {
ZSTR_ALLOCA_FREE(ord_needle, use_heap);
if (tolower(*e) == lowered) {
RETURN_LONG(e - p + (offset > 0 ? offset : 0));
}
e--;
}
ZSTR_ALLOCA_FREE(ord_needle, use_heap);
RETURN_FALSE;
}
@ -2230,7 +2089,6 @@ PHP_FUNCTION(strripos)
if (offset >= 0) {
if ((size_t)offset > ZSTR_LEN(haystack)) {
zend_string_release_ex(haystack_dup, 0);
ZSTR_ALLOCA_FREE(ord_needle, use_heap);
php_error_docref(NULL, E_WARNING, "Offset is greater than the length of haystack string");
RETURN_FALSE;
}
@ -2239,7 +2097,6 @@ PHP_FUNCTION(strripos)
} else {
if (offset < -INT_MAX || (size_t)(-offset) > ZSTR_LEN(haystack)) {
zend_string_release_ex(haystack_dup, 0);
ZSTR_ALLOCA_FREE(ord_needle, use_heap);
php_error_docref(NULL, E_WARNING, "Offset is greater than the length of haystack string");
RETURN_FALSE;
}
@ -2256,11 +2113,9 @@ PHP_FUNCTION(strripos)
RETVAL_LONG(found - ZSTR_VAL(haystack_dup));
zend_string_release_ex(needle_dup, 0);
zend_string_release_ex(haystack_dup, 0);
ZSTR_ALLOCA_FREE(ord_needle, use_heap);
} else {
zend_string_release_ex(needle_dup, 0);
zend_string_release_ex(haystack_dup, 0);
ZSTR_ALLOCA_FREE(ord_needle, use_heap);
RETURN_FALSE;
}
}
@ -2270,31 +2125,16 @@ PHP_FUNCTION(strripos)
Finds the last occurrence of a character in a string within another */
PHP_FUNCTION(strrchr)
{
zval *needle;
zend_string *haystack;
zend_string *haystack, *needle;
const char *found = NULL;
zend_long found_offset;
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_STR(haystack)
Z_PARAM_ZVAL(needle)
Z_PARAM_STR(needle)
ZEND_PARSE_PARAMETERS_END();
if (Z_TYPE_P(needle) == IS_STRING) {
found = zend_memrchr(ZSTR_VAL(haystack), *Z_STRVAL_P(needle), ZSTR_LEN(haystack));
} else {
char needle_chr;
if (php_needle_char(needle, &needle_chr) != SUCCESS) {
RETURN_FALSE;
}
php_error_docref(NULL, E_DEPRECATED,
"Non-string needles will be interpreted as strings in the future. " \
"Use an explicit chr() call to preserve the current behavior");
found = zend_memrchr(ZSTR_VAL(haystack), needle_chr, ZSTR_LEN(haystack));
}
found = zend_memrchr(ZSTR_VAL(haystack), *ZSTR_VAL(needle), ZSTR_LEN(haystack));
if (found) {
found_offset = found - ZSTR_VAL(haystack);
RETURN_STRINGL(found, ZSTR_LEN(haystack) - found_offset);

View File

@ -28,7 +28,7 @@ stripos() function test
echo "Done\n";
?>
--EXPECTF--
--EXPECT--
int(0)
int(5)
int(5)
@ -45,23 +45,11 @@ int(0)
bool(false)
bool(false)
bool(false)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
int(0)
bool(false)
int(0)
int(1)
Done

View File

@ -81,7 +81,7 @@ for($index=0; $index<count($needle); $index++) {
}
echo "*** Done ***";
?>
--EXPECTF--
--EXPECT--
*** Testing stripos() function: with double quoted strings ***
-- Iteration 1 --
int(2)
@ -117,32 +117,16 @@ int(9)
int(8)
bool(false)
-- Iteration 12 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
int(8)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
bool(false)
-- Iteration 13 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
int(8)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
bool(false)
-- Iteration 14 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
int(8)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
bool(false)
-- Iteration 15 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
int(8)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
bool(false)
-- Iteration 16 --
bool(false)

View File

@ -95,101 +95,71 @@ echo "*** Done ***";
*** Testing stripos() function with unexpected values for needle ***
-- Iteration 1 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
int(7)
-- Iteration 2 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
int(9)
-- Iteration 3 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 4 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 5 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
int(16)
-- Iteration 6 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
int(21)
-- Iteration 7 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 8 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 9 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
int(17)
-- Iteration 10 --
Warning: stripos(): needle is not a string or an integer in %s on line %d
bool(false)
Warning: stripos() expects parameter 2 to be string, array given in %s on line %d
NULL
-- Iteration 11 --
Warning: stripos(): needle is not a string or an integer in %s on line %d
bool(false)
Warning: stripos() expects parameter 2 to be string, array given in %s on line %d
NULL
-- Iteration 12 --
Warning: stripos(): needle is not a string or an integer in %s on line %d
bool(false)
Warning: stripos() expects parameter 2 to be string, array given in %s on line %d
NULL
-- Iteration 13 --
Warning: stripos(): needle is not a string or an integer in %s on line %d
bool(false)
Warning: stripos() expects parameter 2 to be string, array given in %s on line %d
NULL
-- Iteration 14 --
Warning: stripos(): needle is not a string or an integer in %s on line %d
bool(false)
Warning: stripos() expects parameter 2 to be string, array given in %s on line %d
NULL
-- Iteration 15 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
int(9)
-- Iteration 16 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 17 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
int(9)
-- Iteration 18 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 19 --
Notice: Object of class sample could not be converted to int in %s on line %d
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
int(64)
-- Iteration 20 --
bool(false)
@ -198,27 +168,19 @@ bool(false)
bool(false)
-- Iteration 22 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 23 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 24 --
Warning: stripos(): needle is not a string or an integer in %s on line %d
%s
Warning: stripos() expects parameter 2 to be string, resource given in %s on line %d
NULL
-- Iteration 25 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 26 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
*** Done ***

View File

@ -91,67 +91,31 @@ echo "*** Done ***";
--EXPECTF--
*** Testing stripos() function with unexpected values for haystack and needle ***
-- Iteration 1 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
int(0)
bool(false)
-- Iteration 2 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
int(0)
bool(false)
-- Iteration 3 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
int(0)
bool(false)
-- Iteration 4 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
int(0)
bool(false)
-- Iteration 5 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
int(0)
bool(false)
-- Iteration 6 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
int(0)
bool(false)
-- Iteration 7 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
int(0)
bool(false)
-- Iteration 8 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
int(0)
bool(false)
-- Iteration 9 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
int(0)
bool(false)
-- Iteration 10 --
@ -189,11 +153,7 @@ NULL
Warning: stripos() expects parameter 1 to be string, array given in %s on line %d
NULL
-- Iteration 15 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
int(0)
bool(false)
-- Iteration 16 --
bool(false)
@ -201,11 +161,7 @@ bool(false)
Warning: stripos(): Offset not contained in string in %s on line %d
bool(false)
-- Iteration 17 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
int(0)
bool(false)
-- Iteration 18 --
bool(false)
@ -213,15 +169,7 @@ bool(false)
Warning: stripos(): Offset not contained in string in %s on line %d
bool(false)
-- Iteration 19 --
Notice: Object of class sample could not be converted to int in %s on line %d
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Notice: Object of class sample could not be converted to int in %s on line %d
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
int(0)
bool(false)
-- Iteration 20 --
bool(false)

View File

@ -91,12 +91,8 @@ echo "*** Done ***";
--EXPECTF--
*** Testing stripos() function with unexpected values for haystack, needle & offset ***
-- Iteration 1 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
int(0)
-- Iteration 2 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 3 --
@ -119,13 +115,9 @@ bool(false)
Warning: stripos(): Offset not contained in string in %s on line %d
bool(false)
-- Iteration 8 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
int(0)
-- Iteration 9 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
int(0)
-- Iteration 10 --
Warning: stripos() expects parameter 1 to be string, array given in %s on line %d
@ -147,14 +139,10 @@ NULL
Warning: stripos() expects parameter 1 to be string, array given in %s on line %d
NULL
-- Iteration 15 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 16 --
bool(false)
-- Iteration 17 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 18 --
bool(false)

View File

@ -83,7 +83,7 @@ for($index=0; $index<count($needle); $index++) {
}
echo "*** Done ***";
?>
--EXPECTF--
--EXPECT--
*** Testing stripos() function: with single quoted strings ***
-- Iteration 1 --
int(2)
@ -119,32 +119,16 @@ bool(false)
int(10)
int(10)
-- Iteration 12 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 13 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 14 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 15 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 16 --
bool(false)
@ -234,11 +218,7 @@ bool(false)
bool(false)
bool(false)
-- Iteration 45 --
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
int(26)
Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
bool(false)
-- Iteration 46 --
int(0)

View File

@ -25,8 +25,8 @@ NULL
Warning: stristr() expects parameter 1 to be string, array given in %s on line %d
NULL
Warning: stristr(): needle is not a string or an integer in %s on line %d
bool(false)
Warning: stristr() expects parameter 2 to be string, array given in %s on line %d
NULL
Warning: stristr() expects parameter 1 to be string, array given in %s on line %d
NULL

View File

@ -16,14 +16,10 @@ var_dump(stristr($email, 97));
var_dump(stristr($email, 97, 1));
?>
--EXPECTF--
--EXPECT--
string(7) "cCdEfGh"
string(2) "Ab"
string(5) "eEfGh"
string(4) "AbCd"
Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
string(11) "azAbCdeEfGh"
Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
string(1) "w"
bool(false)
bool(false)

View File

@ -83,85 +83,63 @@ fclose($file_handle); //closing the file handle
--EXPECTF--
*** Testing stristr() function: with unexpected inputs for 'needle' argument ***
-- Iteration 1 --
Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 2 --
Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 3 --
Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 4 --
Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 5 --
Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 6 --
Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 7 --
Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 8 --
Warning: stristr(): needle is not a string or an integer in %s on line %d
bool(false)
Warning: stristr() expects parameter 2 to be string, array given in %s on line %d
NULL
-- Iteration 9 --
Warning: stristr(): needle is not a string or an integer in %s on line %d
bool(false)
Warning: stristr() expects parameter 2 to be string, array given in %s on line %d
NULL
-- Iteration 10 --
Warning: stristr(): needle is not a string or an integer in %s on line %d
bool(false)
Warning: stristr() expects parameter 2 to be string, array given in %s on line %d
NULL
-- Iteration 11 --
Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 12 --
Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
Warning: stristr(): Empty needle in %s on line %d
bool(false)
-- Iteration 13 --
Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 14 --
Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
Warning: stristr(): Empty needle in %s on line %d
bool(false)
-- Iteration 15 --
Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
Warning: stristr(): Empty needle in %s on line %d
bool(false)
-- Iteration 16 --
Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
Warning: stristr(): Empty needle in %s on line %d
bool(false)
-- Iteration 17 --
Notice: Object of class sample could not be converted to int in %s on line %d
Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 18 --
Warning: stristr(): needle is not a string or an integer in %s on line %d
bool(false)
Warning: stristr() expects parameter 2 to be string, resource given in %s on line %d
NULL
-- Iteration 19 --
Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
Warning: stristr(): Empty needle in %s on line %d
bool(false)
-- Iteration 20 --
Deprecated: stristr(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
Warning: stristr(): Empty needle in %s on line %d
bool(false)
===DONE===

View File

@ -9,10 +9,7 @@ var_dump(strpos("foo bar", 111));
// string("11") is contained
var_dump(strpos("foo 11", "11"));
?>
--EXPECTF--
Deprecated: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
Deprecated: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
int(1)
--EXPECT--
int(4)
bool(false)
int(4)

View File

@ -132,105 +132,67 @@ echo "*** Done ***";
--EXPECTF--
*** Testing strrchr() function with unexpected inputs for needle ***
-- Iteration 1 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
string(1) "0"
-- Iteration 2 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
string(1) "1"
-- Iteration 3 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 4 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
string(2) "-2"
-- Iteration 5 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
string(4) "10.5"
-- Iteration 6 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
string(5) "-10.5"
-- Iteration 7 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
string(2) "10"
-- Iteration 8 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
string(2) "10"
-- Iteration 9 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 10 --
Warning: strrchr(): needle is not a string or an integer in %s on line %d
bool(false)
Warning: strrchr() expects parameter 2 to be string, array given in %s on line %d
NULL
-- Iteration 11 --
Warning: strrchr(): needle is not a string or an integer in %s on line %d
bool(false)
Warning: strrchr() expects parameter 2 to be string, array given in %s on line %d
NULL
-- Iteration 12 --
Warning: strrchr(): needle is not a string or an integer in %s on line %d
bool(false)
Warning: strrchr() expects parameter 2 to be string, array given in %s on line %d
NULL
-- Iteration 13 --
Warning: strrchr(): needle is not a string or an integer in %s on line %d
bool(false)
Warning: strrchr() expects parameter 2 to be string, array given in %s on line %d
NULL
-- Iteration 14 --
Warning: strrchr(): needle is not a string or an integer in %s on line %d
bool(false)
Warning: strrchr() expects parameter 2 to be string, array given in %s on line %d
NULL
-- Iteration 15 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 16 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 17 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 18 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 19 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 20 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 21 --
Notice: Object of class sample could not be converted to int in %s on line %d
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
string(6) "object"
-- Iteration 22 --
bool(false)
-- Iteration 23 --
bool(false)
-- Iteration 24 --
Warning: strrchr(): needle is not a string or an integer in %s on line %d
bool(false)
Warning: strrchr() expects parameter 2 to be string, resource given in %s on line %d
NULL
-- Iteration 25 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 26 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
*** Done ***

View File

@ -91,41 +91,23 @@ echo "*** Done ***";
--EXPECTF--
*** Testing strrchr() function: with unexpected inputs for haystack and needle ***
-- Iteration 1 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
string(1) "0"
-- Iteration 2 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
string(1) "1"
-- Iteration 3 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
string(5) "12345"
-- Iteration 4 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
string(5) "-2345"
-- Iteration 5 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
string(4) "10.5"
-- Iteration 6 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
string(5) "-10.5"
-- Iteration 7 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
string(10) "1234567000"
-- Iteration 8 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
string(4) "1E-9"
-- Iteration 9 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
string(3) "0.5"
-- Iteration 10 --
Warning: strrchr() expects parameter 1 to be string, array given in %s on line %d
@ -147,49 +129,29 @@ NULL
Warning: strrchr() expects parameter 1 to be string, array given in %s on line %d
NULL
-- Iteration 15 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
string(1) "1"
-- Iteration 16 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 17 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
string(1) "1"
-- Iteration 18 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 19 --
Notice: Object of class sample could not be converted to int in %s on line %d
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
string(6) "object"
-- Iteration 20 --
bool(false)
-- Iteration 21 --
bool(false)
-- Iteration 22 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 23 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 24 --
Warning: strrchr() expects parameter 1 to be string, resource given in %s on line %d
NULL
-- Iteration 25 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 26 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
*** Done ***

View File

@ -117,23 +117,15 @@ bool(false)
string(5) "\101 "
-- Iteration 12 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 13 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 14 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 15 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 16 --
@ -221,9 +213,7 @@ bool(false)
string(7) "4 \101 "
-- Iteration 44 --
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
string(37) "*+-./:;<=>?@hello123456he \x234 \101 "
string(7) "4 \101 "
-- Iteration 45 --
string(63) "Hello,\t\n\0\n $&!#%\o,()*+-./:;<=>?@hello123456he \x234 \101 "

View File

@ -30,15 +30,11 @@ foreach($needles as $needle) {
}
echo "*** Done ***";
?>
--EXPECTF--
--EXPECT--
*** Testing strrchr() function: with heredoc strings ***
bool(false)
bool(false)
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrchr(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
bool(false)
bool(false)

View File

@ -31,16 +31,12 @@ bool(false)
Warning: strripos() expects parameter 1 to be string, array given in %s on line %d
bool(false)
Deprecated: strripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
Warning: strripos(): Offset is greater than the length of haystack string in %s on line %d
bool(false)
Warning: strripos(): Offset is greater than the length of haystack string in %s on line %d
bool(false)
Deprecated: strripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
Warning: strripos(): Offset is greater than the length of haystack string in %s on line %d
bool(false)

View File

@ -74,7 +74,7 @@ foreach ($needles as $needle) {
}
?>
===DONE===
--EXPECTF--
--EXPECT--
*** Testing strripos() function: with double quoted strings ***
-- Iteration 1 --
int(28)
@ -132,57 +132,25 @@ int(8)
bool(false)
int(8)
-- Iteration 12 --
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
int(8)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
int(8)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
int(8)
bool(false)
bool(false)
bool(false)
-- Iteration 13 --
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
int(8)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
int(8)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
int(8)
bool(false)
bool(false)
bool(false)
-- Iteration 14 --
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
int(8)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
int(8)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
int(8)
bool(false)
bool(false)
bool(false)
-- Iteration 15 --
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
int(8)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
int(8)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
int(8)
bool(false)
bool(false)
bool(false)
-- Iteration 16 --
bool(false)
bool(false)

View File

@ -75,7 +75,7 @@ foreach ($needles as $needle) {
}
?>
===DONE===
--EXPECTF--
--EXPECT--
*** Testing strripos() function: with single quoted strings ***
-- Iteration 1 --
int(32)
@ -133,56 +133,24 @@ int(10)
bool(false)
int(10)
-- Iteration 12 --
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 13 --
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 14 --
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 15 --
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 16 --
bool(false)
@ -280,18 +248,10 @@ bool(false)
bool(false)
bool(false)
-- Iteration 35 --
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
int(23)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
int(23)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
int(23)
Deprecated: strripos(): Non-string needles will be interpreted as strings in %s on line %d
int(23)
bool(false)
bool(false)
bool(false)
bool(false)
-- Iteration 36 --
int(0)
bool(false)

View File

@ -27,16 +27,12 @@ bool(false)
Warning: strrpos() expects parameter 3 to be int, float given in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
Warning: strrpos(): Offset is greater than the length of haystack string in %s on line %d
bool(false)
Warning: strrpos(): Offset is greater than the length of haystack string in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
Warning: strrpos(): Offset is greater than the length of haystack string in %s on line %d
bool(false)

View File

@ -72,7 +72,7 @@ for($index=0; $index<count($needle); $index++) {
}
echo "*** Done ***";
?>
--EXPECTF--
--EXPECT--
*** Testing strrpos() function: with double quoted strings ***
-- Iteration 1 --
int(28)
@ -108,32 +108,16 @@ int(9)
int(8)
bool(false)
-- Iteration 12 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
int(8)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
bool(false)
-- Iteration 13 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
int(8)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
bool(false)
-- Iteration 14 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
int(8)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
bool(false)
-- Iteration 15 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
int(8)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
bool(false)
-- Iteration 16 --
bool(false)

View File

@ -94,105 +94,67 @@ echo "*** Done ***";
--EXPECTF--
*** Testing strrpos() function with unexpected values for needle ***
-- Iteration 1 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
int(42)
-- Iteration 2 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
int(41)
-- Iteration 3 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 4 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 5 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
int(27)
-- Iteration 6 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
int(21)
-- Iteration 7 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 8 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 9 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
int(28)
-- Iteration 10 --
Warning: strrpos(): needle is not a string or an integer in %s on line %d
Warning: strrpos() expects parameter 2 to be string, array given in %s on line %d
bool(false)
-- Iteration 11 --
Warning: strrpos(): needle is not a string or an integer in %s on line %d
Warning: strrpos() expects parameter 2 to be string, array given in %s on line %d
bool(false)
-- Iteration 12 --
Warning: strrpos(): needle is not a string or an integer in %s on line %d
Warning: strrpos() expects parameter 2 to be string, array given in %s on line %d
bool(false)
-- Iteration 13 --
Warning: strrpos(): needle is not a string or an integer in %s on line %d
Warning: strrpos() expects parameter 2 to be string, array given in %s on line %d
bool(false)
-- Iteration 14 --
Warning: strrpos(): needle is not a string or an integer in %s on line %d
Warning: strrpos() expects parameter 2 to be string, array given in %s on line %d
bool(false)
-- Iteration 15 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
int(41)
-- Iteration 16 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 17 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
int(41)
-- Iteration 18 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 19 --
Notice: Object of class sample could not be converted to int in %s on line %d
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
int(64)
-- Iteration 20 --
bool(false)
-- Iteration 21 --
bool(false)
-- Iteration 22 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 23 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 24 --
Warning: strrpos(): needle is not a string or an integer in %s on line %d
Warning: strrpos() expects parameter 2 to be string, resource given in %s on line %d
bool(false)
-- Iteration 25 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 26 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
*** Done ***

View File

@ -91,67 +91,31 @@ echo "*** Done ***";
--EXPECTF--
*** Testing strrpos() function with unexpected values for haystack and needle ***
-- Iteration 1 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
int(0)
bool(false)
-- Iteration 2 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
int(0)
bool(false)
-- Iteration 3 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
int(0)
bool(false)
-- Iteration 4 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
int(0)
bool(false)
-- Iteration 5 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
int(0)
bool(false)
-- Iteration 6 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
int(0)
bool(false)
-- Iteration 7 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
int(0)
bool(false)
-- Iteration 8 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
int(0)
bool(false)
-- Iteration 9 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
int(0)
bool(false)
-- Iteration 10 --
@ -189,43 +153,19 @@ bool(false)
Warning: strrpos() expects parameter 1 to be string, array given in %s on line %d
bool(false)
-- Iteration 15 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
int(0)
bool(false)
-- Iteration 16 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 17 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
int(0)
bool(false)
-- Iteration 18 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 19 --
Notice: Object of class sample could not be converted to int in %s on line %d
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Notice: Object of class sample could not be converted to int in %s on line %d
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
int(0)
bool(false)
-- Iteration 20 --
bool(false)
@ -234,18 +174,10 @@ bool(false)
bool(false)
bool(false)
-- Iteration 22 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 23 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 24 --
@ -255,17 +187,9 @@ bool(false)
Warning: strrpos() expects parameter 1 to be string, resource given in %s on line %d
bool(false)
-- Iteration 25 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 26 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
*** Done ***

View File

@ -1,205 +0,0 @@
--TEST--
Test strrpos() function : usage variations - unexpected inputs for 'haystack', 'needle' & 'offset' arguments
--SKIPIF--
<?php if (PHP_INT_SIZE !== 4) die("skip this test is for 32-bit only");
--FILE--
<?php
/* Prototype : int strrpos ( string $haystack, string $needle [, int $offset] );
* Description: Find position of last occurrence of 'needle' in 'haystack'.
* Source code: ext/standard/string.c
*/
/* Test strrpos() function with unexpected inputs for 'haystack', 'needle' & 'offset' arguments */
echo "*** Testing strrpos() function: with unexpected values for haystack, needle & offset ***\n";
// get an unset variable
$unset_var = 'string_val';
unset($unset_var);
// defining a class
class sample {
public function __toString() {
return "object";
}
}
//getting the resource
$file_handle = fopen(__FILE__, "r");
// array with different values
$values = array (
// integer values
0,
1,
12345,
-2345,
// float values
10.5,
-10.5,
10.5e10,
10.6E-10,
.5,
// array values
array(),
array(0),
array(1),
array(1, 2),
array('color' => 'red', 'item' => 'pen'),
// boolean values
true,
false,
TRUE,
FALSE,
// objects
new sample(),
// empty string
"",
'',
// null values
NULL,
null,
//resource
$file_handle,
// undefined variable
@$undefined_var,
// unset variable
@$unset_var
);
// loop through each element of the array and check the working of strrpos()
$counter = 1;
for($index = 0; $index < count($values); $index ++) {
echo "-- Iteration $counter --\n";
var_dump( strrpos($values[$index], $values[$index], $values[$index]) );
$counter ++;
}
echo "*** Done ***";
?>
--EXPECTF--
*** Testing strrpos() function: with unexpected values for haystack, needle & offset ***
-- Iteration 1 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 2 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 3 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
Warning: strrpos(): Offset is greater than the length of haystack string in %s on line %d
bool(false)
-- Iteration 4 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
Warning: strrpos(): Offset is greater than the length of haystack string in %s on line %d
bool(false)
-- Iteration 5 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
Warning: strrpos(): Offset is greater than the length of haystack string in %s on line %d
bool(false)
-- Iteration 6 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
Warning: strrpos(): Offset is greater than the length of haystack string in %s on line %d
bool(false)
-- Iteration 7 --
Warning: strrpos() expects parameter 3 to be int, float given in %s on line %d
bool(false)
-- Iteration 8 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 9 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 10 --
Warning: strrpos() expects parameter 1 to be string, array given in %s on line %d
bool(false)
-- Iteration 11 --
Warning: strrpos() expects parameter 1 to be string, array given in %s on line %d
bool(false)
-- Iteration 12 --
Warning: strrpos() expects parameter 1 to be string, array given in %s on line %d
bool(false)
-- Iteration 13 --
Warning: strrpos() expects parameter 1 to be string, array given in %s on line %d
bool(false)
-- Iteration 14 --
Warning: strrpos() expects parameter 1 to be string, array given in %s on line %d
bool(false)
-- Iteration 15 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 16 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 17 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 18 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 19 --
Warning: strrpos() expects parameter 3 to be int, object given in %s on line %d
bool(false)
-- Iteration 20 --
Warning: strrpos() expects parameter 3 to be int, string given in %s on line %d
bool(false)
-- Iteration 21 --
Warning: strrpos() expects parameter 3 to be int, string given in %s on line %d
bool(false)
-- Iteration 22 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 23 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 24 --
Warning: strrpos() expects parameter 1 to be string, resource given in %s on line %d
bool(false)
-- Iteration 25 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
-- Iteration 26 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in %s on line %d
bool(false)
*** Done ***

View File

@ -73,7 +73,7 @@ for($index=0; $index<count($needle); $index++) {
}
echo "*** Done ***";
?>
--EXPECTF--
--EXPECT--
*** Testing strrpos() function: with single quoted strings ***
-- Iteration 1 --
int(32)
@ -109,32 +109,16 @@ bool(false)
int(10)
int(10)
-- Iteration 12 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 13 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 14 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 15 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
-- Iteration 16 --
bool(false)
@ -194,11 +178,7 @@ bool(false)
bool(false)
bool(false)
-- Iteration 35 --
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
int(23)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
bool(false)
-- Iteration 36 --
int(0)

View File

@ -22,15 +22,11 @@ var_dump( strrpos($empty_string, NULL) );
echo "*** Done ***";
?>
--EXPECTF--
--EXPECT--
*** Testing strrpos() function: with heredoc strings ***
-- With empty heredoc string --
bool(false)
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
Deprecated: strrpos(): Non-string needles will be interpreted as strings in %s on line %d
bool(false)
*** Done ***

View File

@ -3,8 +3,6 @@ String functions
--FILE--
<?php
error_reporting(0);
echo "Testing strtok: ";
$str = "testing 1/2\\3";
@ -26,7 +24,7 @@ if ($tok1 != "testing") {
echo "Testing strstr: ";
$test = "This is a test";
$found1 = strstr($test, 32);
$found1 = strstr($test, chr(32));
$found2 = strstr($test, "a ");
if ($found1 != " is a test") {
echo("failed 1\n");
@ -39,7 +37,7 @@ if ($found1 != " is a test") {
echo "Testing strrchr: ";
$test = "fola fola blakken";
$found1 = strrchr($test, "b");
$found2 = strrchr($test, 102);
$found2 = strrchr($test, chr(102));
if ($found1 != "blakken") {
echo("failed 1\n");
} elseif ($found2 != "fola blakken") {