summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorrjhdby <andrewgrom@rambler.ru>2019-03-13 13:51:31 +0300
committerNikita Popov <nikita.ppv@gmail.com>2019-07-19 10:06:10 +0200
commitd574df63dc375f5fc9202ce5afde23f866b6450a (patch)
tree5fd118cf3045f46cef4de60235a6bc9e980ac4a9 /tests
parentd5943f5a11976ffbe89b9634b86d9a0b2adda30a (diff)
downloadphp-git-d574df63dc375f5fc9202ce5afde23f866b6450a.tar.gz
Deprecate alternative array access syntax
RFC: https://wiki.php.net/rfc/deprecate_curly_braces_array_access
Diffstat (limited to 'tests')
-rw-r--r--tests/strings/offsets_chaining_2.phpt2
-rw-r--r--tests/strings/offsets_chaining_4.phpt2
-rw-r--r--tests/strings/offsets_general.phpt38
3 files changed, 34 insertions, 8 deletions
diff --git a/tests/strings/offsets_chaining_2.phpt b/tests/strings/offsets_chaining_2.phpt
index bbc170a6e6..0c3c0074b1 100644
--- a/tests/strings/offsets_chaining_2.phpt
+++ b/tests/strings/offsets_chaining_2.phpt
@@ -5,7 +5,7 @@ error_reporting=E_ALL | E_DEPRECATED
--FILE--
<?php
$string = "foobar";
-var_dump($string{0}{0}[0][0]);
+var_dump($string[0][0][0][0]);
?>
--EXPECT--
string(1) "f"
diff --git a/tests/strings/offsets_chaining_4.phpt b/tests/strings/offsets_chaining_4.phpt
index d1f3de26af..fc11b8d797 100644
--- a/tests/strings/offsets_chaining_4.phpt
+++ b/tests/strings/offsets_chaining_4.phpt
@@ -5,7 +5,7 @@ error_reporting=E_ALL | E_DEPRECATED
--FILE--
<?php
$string = "foobar";
-var_dump(isset($string{0}{0}[0][0]));
+var_dump(isset($string[0][0][0][0]));
?>
--EXPECT--
bool(true)
diff --git a/tests/strings/offsets_general.phpt b/tests/strings/offsets_general.phpt
index 4ec6aa5b86..b2ceea088a 100644
--- a/tests/strings/offsets_general.phpt
+++ b/tests/strings/offsets_general.phpt
@@ -1,24 +1,46 @@
--TEST--
testing the behavior of string offsets
---INI--
-error_reporting=E_ALL | E_DEPRECATED
--FILE--
<?php
$string = "foobar";
+const FOO = "BAR"[0];
+var_dump(FOO);
var_dump($string[0]);
var_dump($string[1]);
var_dump(isset($string[0]));
var_dump(isset($string[0][0]));
var_dump($string["foo"]);
var_dump(isset($string["foo"]["bar"]));
-var_dump($string{0});
+
+const FOO_DEPRECATED = "BAR"{0};
+var_dump(FOO_DEPRECATED);
+var_dump([$string{0}]); // 1 notice
var_dump($string{1});
var_dump(isset($string{0}));
-var_dump(isset($string{0}{0}));
+var_dump(isset($string{0}{0})); // 2 notices
var_dump($string{"foo"});
-var_dump(isset($string{"foo"}{"bar"}));
+var_dump(isset($string{"foo"}{"bar"})); // 2 notices
?>
--EXPECTF--
+
+Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
+
+Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
+
+Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
+
+Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
+
+Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
+
+Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
+
+Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
+
+Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
+
+Deprecated: Array and string offset access syntax with curly braces is deprecated in %s line %d
+string(1) "B"
string(1) "f"
string(1) "o"
bool(true)
@@ -27,7 +49,11 @@ bool(true)
Warning: Illegal string offset 'foo' in %s line %d
string(1) "f"
bool(false)
-string(1) "f"
+string(1) "B"
+array(1) {
+ [0]=>
+ string(1) "f"
+}
string(1) "o"
bool(true)
bool(true)