Skip to content
Merged
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
15 changes: 15 additions & 0 deletions Zend/tests/bug71300.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,22 @@ function test2() {
var_dump(test2());
?>
--EXPECTF--
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(4) "test"

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d

Warning: Array to string conversion in %s on line %d
string(9) "Arraytest"
4 changes: 3 additions & 1 deletion Zend/tests/dynamic_call/variable_variables_curly_syntax.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ $strtoupper = 'strtolower';
var_dump(${${++$a}}('FOO') == 'foo');

?>
--EXPECT--
--EXPECTF--
bool(true)

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
bool(true)
3 changes: 2 additions & 1 deletion Zend/tests/enum/backed-from-unknown-hash.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ $s++;
var_dump(Foo::from($s));

?>
--EXPECT--
--EXPECTF--
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
enum(Foo::Bar)
3 changes: 2 additions & 1 deletion Zend/tests/enum/backed-tryFrom-unknown-hash.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ $s++;
var_dump(Foo::tryFrom($s));

?>
--EXPECT--
--EXPECTF--
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
enum(Foo::Bar)
16 changes: 12 additions & 4 deletions Zend/tests/in-de-crement/incdec_strings.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ foreach ($values as $value) {
Using increment:
Initial value:string(0) ""

Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
Result value:string(1) "1"
Initial value:string(1) " "

Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
Result value:string(1) " "
Initial value:string(1) "0"
Result value:int(1)
Expand All @@ -70,20 +70,28 @@ Result value:float(16.5)
Initial value:string(4) "1e10"
Result value:float(10000000001)
Initial value:string(4) "199A"

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
Result value:string(4) "199B"
Initial value:string(4) "A199"

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
Result value:string(4) "A200"
Initial value:string(4) "199Z"

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
Result value:string(4) "200A"
Initial value:string(4) "Z199"

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
Result value:string(4) "Z200"
Initial value:string(11) "Hello world"

Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
Result value:string(11) "Hello worle"
Initial value:string(4) "🐘"

Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
Result value:string(4) "🐘"
Using decrement:
Initial value:string(0) ""
Expand Down
28 changes: 16 additions & 12 deletions Zend/tests/in-de-crement/incdec_strings_exception.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,35 @@ foreach ($values as $value) {
}
?>
--EXPECT--
Deprecated: Increment on non-alphanumeric string is deprecated
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead
string(0) ""
Deprecated: Decrement on empty string is deprecated as non-numeric
string(0) ""
Deprecated: Increment on non-alphanumeric string is deprecated
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead
string(1) " "
Deprecated: Decrement on non-numeric string has no effect and is deprecated
string(1) " "
string(4) "199B"
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead
string(4) "199A"
Deprecated: Decrement on non-numeric string has no effect and is deprecated
string(4) "199B"
string(4) "A200"
string(4) "199A"
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead
string(4) "A199"
Deprecated: Decrement on non-numeric string has no effect and is deprecated
string(4) "A200"
string(4) "200A"
string(4) "A199"
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead
string(4) "199Z"
Deprecated: Decrement on non-numeric string has no effect and is deprecated
string(4) "200A"
string(4) "Z200"
string(4) "199Z"
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead
string(4) "Z199"
Deprecated: Decrement on non-numeric string has no effect and is deprecated
string(4) "Z200"
Deprecated: Increment on non-alphanumeric string is deprecated
string(4) "Z199"
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead
string(11) "Hello world"
Deprecated: Decrement on non-numeric string has no effect and is deprecated
string(11) "Hello world"
Deprecated: Increment on non-alphanumeric string is deprecated
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead
string(4) "🐘"
Deprecated: Decrement on non-numeric string has no effect and is deprecated
string(4) "🐘"
4 changes: 2 additions & 2 deletions Zend/tests/in-de-crement/incdec_types.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ Initial value:float(0)
Result value:float(1)
Initial value:string(0) ""

Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
Result value:string(1) "1"
Initial value:string(1) " "

Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
Result value:string(1) " "
Initial value:string(1) "0"
Result value:int(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ var_dump($x);
DONE
--EXPECT--
string(1) "1"
string(50) "Increment on non-alphanumeric string is deprecated"
string(74) "Increment on non-numeric string is deprecated, use str_increment() instead"
string(4) "foo!"
string(50) "Increment on non-alphanumeric string is deprecated"
string(74) "Increment on non-numeric string is deprecated, use str_increment() instead"
string(1) "!"
DONE
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ var_dump($x);
?>
DONE
--EXPECT--
string(50) "Increment on non-alphanumeric string is deprecated"
string(74) "Increment on non-numeric string is deprecated, use str_increment() instead"
string(4) "foo!"
string(50) "Increment on non-alphanumeric string is deprecated"
string(74) "Increment on non-numeric string is deprecated, use str_increment() instead"
string(1) "!"
DONE
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ PRE DEC
Decrement on non-numeric string has no effect and is deprecated
string(1) " "
POST INC
Increment on non-alphanumeric string is deprecated
Increment on non-numeric string is deprecated, use str_increment() instead
string(1) " "
PRE INC
Increment on non-alphanumeric string is deprecated
Increment on non-numeric string is deprecated, use str_increment() instead
string(1) " "
45 changes: 31 additions & 14 deletions Zend/tests/in-de-crement/string_increment_various.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -53,55 +53,72 @@ var_dump(++$s); // string(3) "5e0"
var_dump(++$s); // float(6)
?>
--EXPECTF--
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(2) "Ba"

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(2) "bA"

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(2) "B0"

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(2) "b0"

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(3) "AAa"

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(3) "aaA"

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(3) "10a"

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(3) "10A"

Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(1) "1"

Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(3) "-cd"

Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(2) "Z "

Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(2) " A"

Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(2) "é"

Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(15) "あいうえお"

Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(2) "α"

Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(2) "ω"

Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(2) "Α"

Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(2) "Ω"

Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(8) "foo1.txu"

Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(4) "1f.6"

Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(9) "foo.1.txu"

Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d
Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(5) "1.f.6"

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
string(3) "5e0"
float(6)
8 changes: 4 additions & 4 deletions Zend/tests/in-de-crement/unset_globals_in_error_handler.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,23 @@ Decrement on type null has no effect, this will change in the next major version
NULL
Empty string
POST INC
Increment on non-alphanumeric string is deprecated
Increment on non-numeric string is deprecated, use str_increment() instead
string(0) ""
POST DEC
Decrement on empty string is deprecated as non-numeric
string(0) ""
PRE INC
Increment on non-alphanumeric string is deprecated
Increment on non-numeric string is deprecated, use str_increment() instead
string(1) "1"
PRE DEC
Decrement on empty string is deprecated as non-numeric
int(-1)
Non fill ASCII (only ++)
POST INC
Increment on non-alphanumeric string is deprecated
Increment on non-numeric string is deprecated, use str_increment() instead
string(4) " ad "
PRE INC
Increment on non-alphanumeric string is deprecated
Increment on non-numeric string is deprecated, use str_increment() instead
string(4) " ad "
Bool
POST INC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,23 @@ string(87) "Decrement on type null has no effect, this will change in the next m
NULL
Empty string
POST INC
string(50) "Increment on non-alphanumeric string is deprecated"
string(74) "Increment on non-numeric string is deprecated, use str_increment() instead"
string(0) ""
POST DEC
string(54) "Decrement on empty string is deprecated as non-numeric"
string(0) ""
PRE INC
string(50) "Increment on non-alphanumeric string is deprecated"
string(74) "Increment on non-numeric string is deprecated, use str_increment() instead"
string(1) "1"
PRE DEC
string(54) "Decrement on empty string is deprecated as non-numeric"
int(-1)
Non fill ASCII (only ++)
POST INC
string(50) "Increment on non-alphanumeric string is deprecated"
string(74) "Increment on non-numeric string is deprecated, use str_increment() instead"
string(4) " ad "
PRE INC
string(50) "Increment on non-alphanumeric string is deprecated"
string(74) "Increment on non-numeric string is deprecated, use str_increment() instead"
string(4) " ad "
Bool
POST INC
Expand Down
1 change: 1 addition & 0 deletions Zend/tests/operator_unsupported_types.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2104,6 +2104,7 @@ Cannot increment stdClass
Cannot decrement stdClass
Cannot increment resource
Cannot decrement resource
Warning: Increment on non-numeric string is deprecated, use str_increment() instead
No error for fop++
Warning: Decrement on non-numeric string has no effect and is deprecated
No error for foo--
2 changes: 2 additions & 0 deletions Zend/tests/temporary_cleaning/temporary_cleaning_013.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -320,5 +320,7 @@ caught Exception 27
caught Exception 28
caught Exception 29
caught Exception 30

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
caught Exception 31
caught Exception 32
28 changes: 11 additions & 17 deletions Zend/zend_operators.c
Original file line number Diff line number Diff line change
Expand Up @@ -2558,29 +2558,23 @@ static bool ZEND_FASTCALL increment_string(zval *str) /* {{{ */
int last=0; /* Shut up the compiler warning */
int ch;

zend_string *zstr = Z_STR_P(str);
zend_string_addref(zstr);
zend_error(E_DEPRECATED, "Increment on non-numeric string is deprecated, use str_increment() instead");
if (EG(exception)) {
zend_string_release(zstr);
return false;
}
/* A userland error handler can change the type from string to something else */
zval_ptr_dtor(str);
ZVAL_STR(str, zstr);
Comment on lines +2569 to +2570
Copy link
Member

Choose a reason for hiding this comment

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

Suggest to re-add the comment /* A userland error handler can change the type from string to something else */ here to remind why we are doing this


if (UNEXPECTED(Z_STRLEN_P(str) == 0)) {
zend_error(E_DEPRECATED, "Increment on non-alphanumeric string is deprecated");
if (EG(exception)) {
return false;
}
/* A userland error handler can change the type from string to something else */
zval_ptr_dtor(str);
ZVAL_CHAR(str, '1');
return true;
}

if (UNEXPECTED(!zend_string_only_has_ascii_alphanumeric(Z_STR_P(str)))) {
zend_string *zstr = Z_STR_P(str);
zend_string_addref(zstr);
zend_error(E_DEPRECATED, "Increment on non-alphanumeric string is deprecated");
if (EG(exception)) {
zend_string_release(zstr);
return false;
}
zval_ptr_dtor(str);
ZVAL_STR(str, zstr);
}

if (!Z_REFCOUNTED_P(str)) {
Z_STR_P(str) = zend_string_init(Z_STRVAL_P(str), Z_STRLEN_P(str), 0);
Z_TYPE_INFO_P(str) = IS_STRING_EX;
Expand Down
2 changes: 2 additions & 0 deletions ext/ffi/tests/025.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ object(FFI\CData:char)#%d (1) {
["cdata"]=>
string(1) "a"
}

Deprecated: Increment on non-numeric string is deprecated, use str_increment() instead in %s on line %d
object(FFI\CData:char)#%d (1) {
["cdata"]=>
string(1) "b"
Expand Down
Loading