forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RFC] Path to Saner Increment/Decrement operators (php#10358)
* Add behavioural tests for incdec operators * Add support to ++/-- for objects castable to _IS_NUMBER * Add str_increment() function * Add str_decrement() function RFC: https://wiki.php.net/rfc/saner-inc-dec-operators Co-authored-by: Ilija Tovilo <[email protected]> Co-authored-by: Arnaud Le Blanc <[email protected]>
- Loading branch information
1 parent
2f318cf
commit d8696f9
Showing
59 changed files
with
1,897 additions
and
361 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--TEST-- | ||
Decrementing min int values 32bit | ||
--SKIPIF-- | ||
<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?> | ||
--INI-- | ||
precision=14 | ||
--FILE-- | ||
<?php | ||
|
||
$values = [ | ||
-PHP_INT_MAX-1, | ||
(string)(-PHP_INT_MAX-1), | ||
]; | ||
|
||
foreach ($values as $var) { | ||
$var--; | ||
var_dump($var); | ||
} | ||
|
||
echo "Done\n"; | ||
?> | ||
--EXPECT-- | ||
float(-2147483649) | ||
float(-2147483649) | ||
Done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--TEST-- | ||
Decrementing min int values 64bit | ||
--SKIPIF-- | ||
<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?> | ||
--INI-- | ||
precision=14 | ||
--FILE-- | ||
<?php | ||
|
||
$values = [ | ||
-PHP_INT_MAX-1, | ||
(string)(-PHP_INT_MAX-1), | ||
]; | ||
|
||
foreach ($values as $var) { | ||
$var--; | ||
var_dump($var); | ||
} | ||
|
||
echo "Done\n"; | ||
?> | ||
--EXPECT-- | ||
float(-9.223372036854776E+18) | ||
float(-9.223372036854776E+18) | ||
Done |
19 changes: 19 additions & 0 deletions
19
Zend/tests/in-de-crement/decrement_diagnostic_change_type.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--TEST-- | ||
Error handler can change type of operand of -- | ||
--FILE-- | ||
<?php | ||
|
||
set_error_handler(function () { | ||
global $x; | ||
$x = 1; | ||
}); | ||
|
||
$x = ''; | ||
$x--; | ||
var_dump($x); | ||
|
||
?> | ||
DONE | ||
--EXPECT-- | ||
int(-1) | ||
DONE |
Oops, something went wrong.