summaryrefslogtreecommitdiff
path: root/Zend/tests
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/tests')
-rw-r--r--Zend/tests/array_self_add_globals.phpt1
-rw-r--r--Zend/tests/bug71539_6.phpt15
-rw-r--r--Zend/tests/bug71695.phpt17
-rw-r--r--Zend/tests/gc_010.phpt21
-rw-r--r--Zend/tests/globals_001.phpt2
-rw-r--r--Zend/tests/globals_002.phpt2
-rw-r--r--Zend/tests/globals_003.phpt2
-rw-r--r--Zend/tests/globals_004.phpt2
-rw-r--r--Zend/tests/lsb_023.phpt26
-rw-r--r--Zend/tests/lsb_024.phpt25
-rw-r--r--Zend/tests/multibyte/multibyte_encoding_001.phpt2
-rw-r--r--Zend/tests/multibyte/multibyte_encoding_003.phptbin328 -> 329 bytes
-rw-r--r--Zend/tests/named_params/undef_var.phpt2
-rw-r--r--Zend/tests/oct_whitespace.phpt8
-rw-r--r--Zend/tests/restrict_globals/globals_in_globals.phpt11
-rw-r--r--Zend/tests/restrict_globals/invalid_assign.phpt10
-rw-r--r--Zend/tests/restrict_globals/invalid_assign_list.phpt10
-rw-r--r--Zend/tests/restrict_globals/invalid_assign_list_ref.phpt10
-rw-r--r--Zend/tests/restrict_globals/invalid_assign_op.phpt10
-rw-r--r--Zend/tests/restrict_globals/invalid_assign_ref_lhs.phpt11
-rw-r--r--Zend/tests/restrict_globals/invalid_assign_ref_rhs.phpt11
-rw-r--r--Zend/tests/restrict_globals/invalid_foreach.phpt10
-rw-r--r--Zend/tests/restrict_globals/invalid_foreach_ref.phpt10
-rw-r--r--Zend/tests/restrict_globals/invalid_pass_by_ref.phpt23
-rw-r--r--Zend/tests/restrict_globals/invalid_unset.phpt10
-rw-r--r--Zend/tests/restrict_globals/key_canonicalization.phpt11
-rw-r--r--Zend/tests/restrict_globals/valid.phpt52
-rw-r--r--Zend/tests/undef_index_to_exception.phpt2
-rw-r--r--Zend/tests/unset_cv09.phpt14
-rw-r--r--Zend/tests/unset_cv10.phpt4
30 files changed, 258 insertions, 76 deletions
diff --git a/Zend/tests/array_self_add_globals.phpt b/Zend/tests/array_self_add_globals.phpt
index ebad7c3fdf..78dd3bf9a3 100644
--- a/Zend/tests/array_self_add_globals.phpt
+++ b/Zend/tests/array_self_add_globals.phpt
@@ -2,7 +2,6 @@
Add $GLOBALS to itself
--FILE--
<?php
-$GLOBALS += $GLOBALS;
$x = $GLOBALS + $GLOBALS;
?>
===DONE===
diff --git a/Zend/tests/bug71539_6.phpt b/Zend/tests/bug71539_6.phpt
deleted file mode 100644
index d690538595..0000000000
--- a/Zend/tests/bug71539_6.phpt
+++ /dev/null
@@ -1,15 +0,0 @@
---TEST--
-Bug #71539.5 (Memory error on $arr[$a] =& $arr[$b] if RHS rehashes)
---FILE--
-<?php
-$name = 'a';
-for ($i = 0; $i < 100000; $i++) {
- if ($name != 'i') {
- $$name =& $GLOBALS;
- }
- $name++;
-}
-?>
-OK
---EXPECT--
-OK
diff --git a/Zend/tests/bug71695.phpt b/Zend/tests/bug71695.phpt
deleted file mode 100644
index 31ae73a99d..0000000000
--- a/Zend/tests/bug71695.phpt
+++ /dev/null
@@ -1,17 +0,0 @@
---TEST--
-Bug #71695 (Global variables are reserved before execution)
---FILE--
-<?php
-function provideGlobals() {
- var_dump(array_key_exists("foo", $GLOBALS));
- var_dump(isset($GLOBALS["foo"]));
- $GLOBALS += array("foo" => "foo");
-}
-
-provideGlobals();
-echo $foo;
-?>
---EXPECT--
-bool(false)
-bool(false)
-foo
diff --git a/Zend/tests/gc_010.phpt b/Zend/tests/gc_010.phpt
deleted file mode 100644
index 756c8ebc2a..0000000000
--- a/Zend/tests/gc_010.phpt
+++ /dev/null
@@ -1,21 +0,0 @@
---TEST--
-GC 010: Cycle with reference to $GLOBALS
---INI--
-zend.enable_gc=1
---FILE--
-<?php
-$a = array();
-$a[] =& $a;
-var_dump($a);
-$a[] =& $GLOBALS;
-unset($a);
-var_dump(gc_collect_cycles());
-echo "ok\n"
-?>
---EXPECT--
-array(1) {
- [0]=>
- *RECURSION*
-}
-int(1)
-ok
diff --git a/Zend/tests/globals_001.phpt b/Zend/tests/globals_001.phpt
index 069e88730c..7c54046212 100644
--- a/Zend/tests/globals_001.phpt
+++ b/Zend/tests/globals_001.phpt
@@ -29,6 +29,6 @@ string(%d) "%s"
Warning: Undefined array key "PHP_SELF" in %s on line %d
NULL
-Warning: Undefined variable $_SERVER in %s on line %d
+Warning: Undefined global variable $_SERVER in %s on line %d
NULL
Done
diff --git a/Zend/tests/globals_002.phpt b/Zend/tests/globals_002.phpt
index d8f9ad4aa2..faa9b94ade 100644
--- a/Zend/tests/globals_002.phpt
+++ b/Zend/tests/globals_002.phpt
@@ -32,6 +32,6 @@ string(%d) "%s"
Warning: Undefined array key "PHP_SELF" in %s on line %d
NULL
-Warning: Undefined variable $_SERVER in %s on line %d
+Warning: Undefined global variable $_SERVER in %s on line %d
NULL
Done
diff --git a/Zend/tests/globals_003.phpt b/Zend/tests/globals_003.phpt
index 6ac9d9f779..36e74bde64 100644
--- a/Zend/tests/globals_003.phpt
+++ b/Zend/tests/globals_003.phpt
@@ -38,6 +38,6 @@ string(%d) "%s"
Warning: Undefined array key "PHP_SELF" in %s on line %d
NULL
-Warning: Undefined variable $_SERVER in %s on line %d
+Warning: Undefined global variable $_SERVER in %s on line %d
NULL
Done
diff --git a/Zend/tests/globals_004.phpt b/Zend/tests/globals_004.phpt
index 27520a220c..4c81e5e57a 100644
--- a/Zend/tests/globals_004.phpt
+++ b/Zend/tests/globals_004.phpt
@@ -23,6 +23,6 @@ string(%d) "%s"
Warning: Undefined array key "PHP_SELF" in %s on line %d
NULL
-Warning: Undefined variable $_SERVER in %s on line %d
+Warning: Undefined global variable $_SERVER in %s on line %d
NULL
Done
diff --git a/Zend/tests/lsb_023.phpt b/Zend/tests/lsb_023.phpt
new file mode 100644
index 0000000000..a8051aa85f
--- /dev/null
+++ b/Zend/tests/lsb_023.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Late Static Binding static:: calls protected / public method of child class even then
+the method is private in parent class
+--FILE--
+<?php
+class A {
+ public static function out() {
+ echo static::value(), PHP_EOL;
+ }
+
+ private static function value() { return 'A'; }
+}
+class B extends A {
+ protected static function value() { return 'B'; }
+}
+class C extends A {
+ public static function value() { return 'C'; }
+}
+A::out();
+B::out();
+C::out();
+echo PHP_EOL;
+--EXPECT--
+A
+B
+C
diff --git a/Zend/tests/lsb_024.phpt b/Zend/tests/lsb_024.phpt
new file mode 100644
index 0000000000..2c71c678d3
--- /dev/null
+++ b/Zend/tests/lsb_024.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Late Static Binding static:: accesses protected / public static variables of child
+class when the variable is private in parent class
+--FILE--
+<?php
+class A {
+ private static $value = 'A';
+
+ public static function out() {
+ echo static::$value, PHP_EOL;
+ }
+}
+class B extends A {
+ protected static $value = 'B';
+}
+class C extends A {
+ public static $value = 'C';
+}
+A::out();
+B::out();
+C::out();
+--EXPECT--
+A
+B
+C
diff --git a/Zend/tests/multibyte/multibyte_encoding_001.phpt b/Zend/tests/multibyte/multibyte_encoding_001.phpt
index 3b26dcb989..f95b4311a9 100644
--- a/Zend/tests/multibyte/multibyte_encoding_001.phpt
+++ b/Zend/tests/multibyte/multibyte_encoding_001.phpt
@@ -13,7 +13,7 @@ internal_encoding=SJIS
<?php
declare(encoding='Shift_JIS');
$s = "•\"; // 0x95+0x5c in script, not somewhere else "
-printf("%x:%x\n", ord($s[0]), ord($s[1]));
+printf("%x:%x", ord($s[0]), ord($s[1]));
?>
--EXPECT--
95:5c
diff --git a/Zend/tests/multibyte/multibyte_encoding_003.phpt b/Zend/tests/multibyte/multibyte_encoding_003.phpt
index a0983329f4..f0fb60f6cd 100644
--- a/Zend/tests/multibyte/multibyte_encoding_003.phpt
+++ b/Zend/tests/multibyte/multibyte_encoding_003.phpt
Binary files differ
diff --git a/Zend/tests/named_params/undef_var.phpt b/Zend/tests/named_params/undef_var.phpt
index b1d5682434..5ef41e26dd 100644
--- a/Zend/tests/named_params/undef_var.phpt
+++ b/Zend/tests/named_params/undef_var.phpt
@@ -1,5 +1,5 @@
--TEST--
-Passing undefined variabled to named arg
+Passing undefined variable to named arg
--FILE--
<?php
diff --git a/Zend/tests/oct_whitespace.phpt b/Zend/tests/oct_whitespace.phpt
new file mode 100644
index 0000000000..cb0bf4ad7a
--- /dev/null
+++ b/Zend/tests/oct_whitespace.phpt
@@ -0,0 +1,8 @@
+--TEST--
+Octal literal followed by whitespace and another number
+--FILE--
+<?php
+var_dump(0o0 2);
+?>
+--EXPECTF--
+Parse error: syntax error, unexpected integer "2", expecting ")" in %s on line %d
diff --git a/Zend/tests/restrict_globals/globals_in_globals.phpt b/Zend/tests/restrict_globals/globals_in_globals.phpt
new file mode 100644
index 0000000000..fbb811708c
--- /dev/null
+++ b/Zend/tests/restrict_globals/globals_in_globals.phpt
@@ -0,0 +1,11 @@
+--TEST--
+$GLOBALS no longer contains 'GLOBALS'
+--FILE--
+<?php
+
+$g = $GLOBALS;
+var_dump(isset($g['GLOBALS']));
+
+?>
+--EXPECT--
+bool(false)
diff --git a/Zend/tests/restrict_globals/invalid_assign.phpt b/Zend/tests/restrict_globals/invalid_assign.phpt
new file mode 100644
index 0000000000..c42cc9e1f9
--- /dev/null
+++ b/Zend/tests/restrict_globals/invalid_assign.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Cannot assign to $GLOBALS
+--FILE--
+<?php
+
+$GLOBALS = [];
+
+?>
+--EXPECTF--
+Fatal error: $GLOBALS can only be modified using the $GLOBALS[$name] = $value syntax in %s on line %d
diff --git a/Zend/tests/restrict_globals/invalid_assign_list.phpt b/Zend/tests/restrict_globals/invalid_assign_list.phpt
new file mode 100644
index 0000000000..8fc3e524a9
--- /dev/null
+++ b/Zend/tests/restrict_globals/invalid_assign_list.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Cannot list-assign to $GLOBALS
+--FILE--
+<?php
+
+list($GLOBALS) = [1];
+
+?>
+--EXPECTF--
+Fatal error: $GLOBALS can only be modified using the $GLOBALS[$name] = $value syntax in %s on line %d
diff --git a/Zend/tests/restrict_globals/invalid_assign_list_ref.phpt b/Zend/tests/restrict_globals/invalid_assign_list_ref.phpt
new file mode 100644
index 0000000000..594a308ea1
--- /dev/null
+++ b/Zend/tests/restrict_globals/invalid_assign_list_ref.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Cannot list-assign to $GLOBALS (by-ref)
+--FILE--
+<?php
+
+list(&$GLOBALS) = [1];
+
+?>
+--EXPECTF--
+Fatal error: Cannot assign reference to non referencable value in %s on line %d
diff --git a/Zend/tests/restrict_globals/invalid_assign_op.phpt b/Zend/tests/restrict_globals/invalid_assign_op.phpt
new file mode 100644
index 0000000000..a9b36853ea
--- /dev/null
+++ b/Zend/tests/restrict_globals/invalid_assign_op.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Cannot compound assign to $GLOBALS
+--FILE--
+<?php
+
+$GLOBALS += [];
+
+?>
+--EXPECTF--
+Fatal error: $GLOBALS can only be modified using the $GLOBALS[$name] = $value syntax in %s on line %d
diff --git a/Zend/tests/restrict_globals/invalid_assign_ref_lhs.phpt b/Zend/tests/restrict_globals/invalid_assign_ref_lhs.phpt
new file mode 100644
index 0000000000..b14c167646
--- /dev/null
+++ b/Zend/tests/restrict_globals/invalid_assign_ref_lhs.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Cannot by-ref assign to $GLOBALS (LHS)
+--FILE--
+<?php
+
+$var = [];
+$GLOBALS =& $var;
+
+?>
+--EXPECTF--
+Fatal error: $GLOBALS can only be modified using the $GLOBALS[$name] = $value syntax in %s on line %d
diff --git a/Zend/tests/restrict_globals/invalid_assign_ref_rhs.phpt b/Zend/tests/restrict_globals/invalid_assign_ref_rhs.phpt
new file mode 100644
index 0000000000..3cdab0f9c9
--- /dev/null
+++ b/Zend/tests/restrict_globals/invalid_assign_ref_rhs.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Cannot by-ref assign to $GLOBALS (RHS)
+--FILE--
+<?php
+
+$var = [];
+$var =& $GLOBALS;
+
+?>
+--EXPECTF--
+Fatal error: Cannot acquire reference to $GLOBALS in %s on line %d
diff --git a/Zend/tests/restrict_globals/invalid_foreach.phpt b/Zend/tests/restrict_globals/invalid_foreach.phpt
new file mode 100644
index 0000000000..0e7c74881a
--- /dev/null
+++ b/Zend/tests/restrict_globals/invalid_foreach.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Cannot use $GLOBALS as foreach result variable
+--FILE--
+<?php
+
+foreach ([1] as $GLOBALS) {}
+
+?>
+--EXPECTF--
+Fatal error: $GLOBALS can only be modified using the $GLOBALS[$name] = $value syntax in %s on line %d
diff --git a/Zend/tests/restrict_globals/invalid_foreach_ref.phpt b/Zend/tests/restrict_globals/invalid_foreach_ref.phpt
new file mode 100644
index 0000000000..2c355c09ae
--- /dev/null
+++ b/Zend/tests/restrict_globals/invalid_foreach_ref.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Cannot use $GLOBALS as foreach result variable (by-ref)
+--FILE--
+<?php
+
+foreach ([1] as &$GLOBALS) {}
+
+?>
+--EXPECTF--
+Fatal error: $GLOBALS can only be modified using the $GLOBALS[$name] = $value syntax in %s on line %d
diff --git a/Zend/tests/restrict_globals/invalid_pass_by_ref.phpt b/Zend/tests/restrict_globals/invalid_pass_by_ref.phpt
new file mode 100644
index 0000000000..a0145a0624
--- /dev/null
+++ b/Zend/tests/restrict_globals/invalid_pass_by_ref.phpt
@@ -0,0 +1,23 @@
+--TEST--
+$GLOBALS cannot be passed by reference (runtime error)
+--FILE--
+<?php
+
+function by_ref(&$ref) {}
+try {
+ by_ref($GLOBALS);
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
+}
+
+try {
+ by_ref2($GLOBALS);
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
+}
+function by_ref2(&$ref) {}
+
+?>
+--EXPECT--
+by_ref(): Argument #1 ($ref) cannot be passed by reference
+by_ref2(): Argument #1 ($ref) cannot be passed by reference
diff --git a/Zend/tests/restrict_globals/invalid_unset.phpt b/Zend/tests/restrict_globals/invalid_unset.phpt
new file mode 100644
index 0000000000..781388b9b2
--- /dev/null
+++ b/Zend/tests/restrict_globals/invalid_unset.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Cannot unset $GLOBALS
+--FILE--
+<?php
+
+unset($GLOBALS);
+
+?>
+--EXPECTF--
+Fatal error: $GLOBALS can only be modified using the $GLOBALS[$name] = $value syntax in %s on line %d
diff --git a/Zend/tests/restrict_globals/key_canonicalization.phpt b/Zend/tests/restrict_globals/key_canonicalization.phpt
new file mode 100644
index 0000000000..66d9a29a92
--- /dev/null
+++ b/Zend/tests/restrict_globals/key_canonicalization.phpt
@@ -0,0 +1,11 @@
+--TEST--
+$GLOBALS should have canonicalized keys
+--FILE--
+<?php
+
+${1} = 42;
+var_dump($GLOBALS[1]);
+
+?>
+--EXPECT--
+int(42)
diff --git a/Zend/tests/restrict_globals/valid.phpt b/Zend/tests/restrict_globals/valid.phpt
new file mode 100644
index 0000000000..b99bbe402f
--- /dev/null
+++ b/Zend/tests/restrict_globals/valid.phpt
@@ -0,0 +1,52 @@
+--TEST--
+Supported operations on $GLOBALS
+--FILE--
+<?php
+
+function test() {
+ var_dump($GLOBALS['x']);
+ $GLOBALS['x'] = 1;
+ var_dump($GLOBALS['x']);
+ $GLOBALS['x']++;
+ var_dump($GLOBALS['x']);
+ $GLOBALS['x'] += 2;
+ var_dump($GLOBALS['x']);
+ unset($GLOBALS['y']);
+ var_dump(isset($GLOBALS['x']));
+ var_dump(isset($GLOBALS['y']));
+ $GLOBALS['z'][] = 1;
+}
+
+$y = 1;
+test();
+var_dump($x, $y, $z);
+
+$ref = 1;
+$GLOBALS['z'] =& $ref;
+$ref++;
+var_dump($z);
+
+$x = 1;
+$ref2 =& $GLOBALS['x'];
+$ref2++;
+var_dump($x);
+
+?>
+--EXPECTF--
+Warning: Undefined global variable $x in %s on line %d
+NULL
+int(1)
+int(2)
+int(4)
+bool(true)
+bool(false)
+
+Warning: Undefined variable $y in %s on line %d
+int(4)
+NULL
+array(1) {
+ [0]=>
+ int(1)
+}
+int(2)
+int(2)
diff --git a/Zend/tests/undef_index_to_exception.phpt b/Zend/tests/undef_index_to_exception.phpt
index c01aaba658..bbe13c0e71 100644
--- a/Zend/tests/undef_index_to_exception.phpt
+++ b/Zend/tests/undef_index_to_exception.phpt
@@ -42,5 +42,5 @@ array(0) {
Undefined array key "key"
array(0) {
}
-Undefined array key "test"
+Undefined global variable $test
Undefined variable $test
diff --git a/Zend/tests/unset_cv09.phpt b/Zend/tests/unset_cv09.phpt
deleted file mode 100644
index 63a7eab0f2..0000000000
--- a/Zend/tests/unset_cv09.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-unset() CV 9 (unset() of global variable in array_pop($GLOBALS))
---FILE--
-<?php
-$x = "ok\n";
-echo array_pop($GLOBALS);
-echo $x;
-echo "ok\n";
-?>
---EXPECTF--
-ok
-
-Warning: Undefined variable $x in %s on line %d
-ok
diff --git a/Zend/tests/unset_cv10.phpt b/Zend/tests/unset_cv10.phpt
index c62b8ae57a..e8908be0f7 100644
--- a/Zend/tests/unset_cv10.phpt
+++ b/Zend/tests/unset_cv10.phpt
@@ -2,6 +2,7 @@
unset() CV 10 (unset() of global variable in ArrayObject::offsetUnset($GLOBALS))
--FILE--
<?php
+/* This is working on a copy of $GLOBALS, so nothing interesting happens here. */
$a = new ArrayObject($GLOBALS);
$x = "ok\n";
echo $x;
@@ -12,5 +13,6 @@ echo "ok\n";
--EXPECTF--
ok
-Warning: Undefined variable $x in %s on line %d
+Warning: Undefined array key "x" in %s on line %d
+ok
ok