summaryrefslogtreecommitdiff
path: root/Zend/tests/offset_string.phpt
diff options
context:
space:
mode:
authorGeorge Peter Banyard <girgias@php.net>2020-07-29 02:51:09 +0100
committerGeorge Peter Banyard <girgias@php.net>2020-07-29 02:51:09 +0100
commitb2248789ed21300aaf356336bf43b6b065183fcb (patch)
treec61dba0a43f72d27904e956318f911c7dc719dda /Zend/tests/offset_string.phpt
parentf759936591c08d9bff6ab707f2f8c192f61b5bf1 (diff)
downloadphp-git-b2248789ed21300aaf356336bf43b6b065183fcb.tar.gz
Implement 'Saner Numeric Strings' RFC:
RFC: https://wiki.php.net/rfc/saner-numeric-strings This removes the -1 allow_error mode from is_numeric_string functions and replaces it by a trailing boolean out argument to preserve BC in a couple of places. Most of the changes can be resumed to "numeric" strings which emitted a E_NOTICE now emit a E_WARNING and "numeric" strings which emitted a E_WARNING now throw a TypeError. This mostly affects: - String offsets - Arithmetic operations - Bitwise operations Closes GH-5762
Diffstat (limited to 'Zend/tests/offset_string.phpt')
-rw-r--r--Zend/tests/offset_string.phpt28
1 files changed, 16 insertions, 12 deletions
diff --git a/Zend/tests/offset_string.phpt b/Zend/tests/offset_string.phpt
index 4c7debcaa9..36481dccce 100644
--- a/Zend/tests/offset_string.phpt
+++ b/Zend/tests/offset_string.phpt
@@ -8,9 +8,17 @@ $str = "Sitting on a corner all alone, staring from the bottom of his soul";
var_dump($str[1]);
var_dump($str[0.0836]);
var_dump($str[NULL]);
-var_dump($str["run away"]);
+try {
+ var_dump($str["run away"]);
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
var_dump($str["13"]);
-var_dump($str["14.5"]);
+try {
+ var_dump($str["14.5"]);
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
var_dump($str["15 and then some"]);
var_dump($str[TRUE]);
@@ -47,15 +55,11 @@ string(1) "S"
Warning: String offset cast occurred in %s on line %d
string(1) "S"
-
-Warning: Illegal string offset "run away" in %s on line %d
-string(1) "S"
+Cannot access offset of type string on string
string(1) "c"
+Cannot access offset of type string on string
-Warning: Illegal string offset "14.5" in %s on line %d
-string(1) "o"
-
-Notice: A non well formed numeric value encountered in %s on line %d
+Warning: Illegal string offset "15 and then some" in %s on line %d
string(1) "r"
Warning: String offset cast occurred in %s on line %d
@@ -63,9 +67,9 @@ string(1) "i"
Warning: String offset cast occurred in %s on line %d
string(1) "S"
-Illegal offset type
+Cannot access offset of type resource on string
Notice: Object of class stdClass could not be converted to int in %s on line %d
-Illegal offset type
-Illegal offset type
+Cannot access offset of type stdClass on string
+Cannot access offset of type array on string
Done