summaryrefslogtreecommitdiff
path: root/Zend/tests
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/tests')
-rw-r--r--Zend/tests/67468.phpt11
-rw-r--r--Zend/tests/arg_unpack/basic.phpt110
-rw-r--r--Zend/tests/arg_unpack/by_ref.phpt145
-rw-r--r--Zend/tests/arg_unpack/dynamic.phpt37
-rw-r--r--Zend/tests/arg_unpack/internal.phpt43
-rw-r--r--Zend/tests/arg_unpack/invalid_type.phpt59
-rw-r--r--Zend/tests/arg_unpack/many_args.phpt15
-rw-r--r--Zend/tests/arg_unpack/method.phpt32
-rw-r--r--Zend/tests/arg_unpack/new.phpt35
-rw-r--r--Zend/tests/arg_unpack/positional_arg_after_unpack_error.phpt10
-rw-r--r--Zend/tests/arg_unpack/string_keys.phpt20
-rw-r--r--Zend/tests/arg_unpack/traversable_throwing_exception.phpt33
-rw-r--r--Zend/tests/arg_unpack/traversable_with_by_ref_parameters.phpt31
-rw-r--r--Zend/tests/bug30820.phpt1
-rw-r--r--Zend/tests/bug65784.phpt2
-rw-r--r--Zend/tests/bug66015.phpt30
-rw-r--r--Zend/tests/bug66252.phpt14
-rw-r--r--Zend/tests/bug66660.phpt13
-rw-r--r--Zend/tests/bug67169.phpt26
-rw-r--r--Zend/tests/bug67368.phpt12
-rw-r--r--Zend/tests/bug67436/bug67436_nohandler.phpt2
-rw-r--r--Zend/tests/bug67938.phpt27
-rw-r--r--Zend/tests/bug68446.phpt36
-rw-r--r--Zend/tests/class_properties_dynamic.phpt13
-rw-r--r--Zend/tests/class_properties_static.phpt20
-rw-r--r--Zend/tests/closure_018.phpt5
-rw-r--r--Zend/tests/closure_019.phpt3
-rw-r--r--Zend/tests/constant_expressions.phpt96
-rw-r--r--Zend/tests/constant_expressions_arrays.phpt66
-rw-r--r--Zend/tests/constant_expressions_classes.phpt43
-rw-r--r--Zend/tests/constant_expressions_dynamic.phpt11
-rw-r--r--Zend/tests/constant_expressions_self_referencing_array.phpt13
-rw-r--r--Zend/tests/debug_info-error-0.0.phpt19
-rw-r--r--Zend/tests/debug_info-error-0.phpt19
-rw-r--r--Zend/tests/debug_info-error-1.0.phpt19
-rw-r--r--Zend/tests/debug_info-error-1.phpt19
-rw-r--r--Zend/tests/debug_info-error-empty_str.phpt19
-rw-r--r--Zend/tests/debug_info-error-false.phpt19
-rw-r--r--Zend/tests/debug_info-error-object.phpt19
-rw-r--r--Zend/tests/debug_info-error-resource.phpt19
-rw-r--r--Zend/tests/debug_info-error-str.phpt19
-rw-r--r--Zend/tests/debug_info-error-true.phpt19
-rw-r--r--Zend/tests/debug_info.phpt39
-rw-r--r--Zend/tests/dereference_002.phpt2
-rw-r--r--Zend/tests/errmsg_040.phpt12
-rw-r--r--Zend/tests/finally_goto_001.phpt14
-rw-r--r--Zend/tests/finally_goto_002.phpt14
-rw-r--r--Zend/tests/finally_goto_003.phpt15
-rw-r--r--Zend/tests/finally_goto_004.phpt14
-rw-r--r--Zend/tests/function_arguments_003.phpt17
-rw-r--r--Zend/tests/incompat_ctx_user.phpt20
-rw-r--r--Zend/tests/ns_059.phpt7
-rw-r--r--Zend/tests/static_variable.phpt29
-rw-r--r--Zend/tests/use_const/alias.phpt26
-rw-r--r--Zend/tests/use_const/basic.phpt22
-rw-r--r--Zend/tests/use_const/case_sensivity.phpt12
-rw-r--r--Zend/tests/use_const/conflicting_use.phpt21
-rw-r--r--Zend/tests/use_const/conflicting_use_alias.phpt18
-rw-r--r--Zend/tests/use_const/define_imported.phpt14
-rw-r--r--Zend/tests/use_const/define_imported_before.phpt18
-rw-r--r--Zend/tests/use_const/includes/foo_bar.php5
-rw-r--r--Zend/tests/use_const/includes/foo_php_version.php5
-rw-r--r--Zend/tests/use_const/includes/global_bar.php3
-rw-r--r--Zend/tests/use_const/includes/global_baz.php3
-rw-r--r--Zend/tests/use_const/no_global_fallback.phpt14
-rw-r--r--Zend/tests/use_const/self_parent.phpt12
-rw-r--r--Zend/tests/use_const/shadow_core.phpt16
-rw-r--r--Zend/tests/use_const/shadow_global.phpt25
-rw-r--r--Zend/tests/use_function/alias.phpt30
-rw-r--r--Zend/tests/use_function/basic.phpt26
-rw-r--r--Zend/tests/use_function/case_insensivity.phpt13
-rw-r--r--Zend/tests/use_function/conditional_function_declaration.phpt17
-rw-r--r--Zend/tests/use_function/conflicting_use.phpt25
-rw-r--r--Zend/tests/use_function/conflicting_use_alias.phpt20
-rw-r--r--Zend/tests/use_function/conflicting_use_const_alias.phpt23
-rw-r--r--Zend/tests/use_function/define_imported.phpt14
-rw-r--r--Zend/tests/use_function/define_imported_before.phpt18
-rw-r--r--Zend/tests/use_function/ignore_constants.phpt23
-rw-r--r--Zend/tests/use_function/includes/foo_bar.php7
-rw-r--r--Zend/tests/use_function/includes/foo_strlen.php7
-rw-r--r--Zend/tests/use_function/includes/global_bar.php5
-rw-r--r--Zend/tests/use_function/includes/global_baz.php4
-rw-r--r--Zend/tests/use_function/no_global_fallback.phpt13
-rw-r--r--Zend/tests/use_function/no_global_fallback2.phpt18
-rw-r--r--Zend/tests/use_function/self_parent.phpt12
-rw-r--r--Zend/tests/use_function/shadow_core.phpt16
-rw-r--r--Zend/tests/use_function/shadow_global.phpt25
-rw-r--r--Zend/tests/variadic/adding_additional_optional_parameter.phpt17
-rw-r--r--Zend/tests/variadic/adding_additional_optional_parameter_error.phpt16
-rw-r--r--Zend/tests/variadic/basic.phpt57
-rw-r--r--Zend/tests/variadic/by_ref.phpt24
-rw-r--r--Zend/tests/variadic/by_ref_error.phpt12
-rw-r--r--Zend/tests/variadic/no_default_error.phpt10
-rw-r--r--Zend/tests/variadic/non_variadic_implements_variadic_error.phpt16
-rw-r--r--Zend/tests/variadic/only_last_error.phpt10
-rw-r--r--Zend/tests/variadic/optional_params.phpt49
-rw-r--r--Zend/tests/variadic/removing_parameter_error.phpt20
-rw-r--r--Zend/tests/variadic/typehint_error.phpt36
-rw-r--r--Zend/tests/variadic/typehint_suppressed_error.phpt33
-rw-r--r--Zend/tests/variadic/variadic_changed_byref_error.phpt16
-rw-r--r--Zend/tests/variadic/variadic_changed_typehint_error.phpt16
-rw-r--r--Zend/tests/variadic/variadic_implements_non_variadic.phpt17
-rw-r--r--Zend/tests/zend_signed_multiply-32bit.phpt14
-rw-r--r--Zend/tests/zend_signed_multiply-64bit.phpt14
104 files changed, 2286 insertions, 8 deletions
diff --git a/Zend/tests/67468.phpt b/Zend/tests/67468.phpt
new file mode 100644
index 0000000000..767217644a
--- /dev/null
+++ b/Zend/tests/67468.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Bug #67468 (Segfault in highlight_file()/highlight_string())
+--SKIPIF--
+<?php if(!function_exists("leak")) print "skip only for debug builds"; ?>
+--FILE--
+<?php
+highlight_string("<?php __CLASS__;", true);
+echo "done";
+?>
+--EXPECT--
+done
diff --git a/Zend/tests/arg_unpack/basic.phpt b/Zend/tests/arg_unpack/basic.phpt
new file mode 100644
index 0000000000..f8bd019378
--- /dev/null
+++ b/Zend/tests/arg_unpack/basic.phpt
@@ -0,0 +1,110 @@
+--TEST--
+Basic argument unpacking
+--FILE--
+<?php
+
+function test(...$args) {
+ var_dump($args);
+}
+
+function test2($arg1, $arg2, $arg3 = null) {
+ var_dump($arg1, $arg2, $arg3);
+}
+
+function getArray($array) {
+ return $array;
+}
+
+function arrayGen($array) {
+ foreach ($array as $element) {
+ yield $element;
+ }
+}
+
+$array = [1, 2, 3];
+
+test(...[]);
+test(...[1, 2, 3]);
+test(...$array);
+test(...getArray([1, 2, 3]));
+test(...arrayGen([]));
+test(...arrayGen([1, 2, 3]));
+
+test(1, ...[2, 3], ...[4, 5]);
+test(1, ...getArray([2, 3]), ...arrayGen([4, 5]));
+
+test2(...[1, 2]);
+test2(...[1, 2, 3]);
+test2(...[1], ...[], ...[], ...[2, 3], ...[4, 5]);
+
+?>
+--EXPECT--
+array(0) {
+}
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+array(0) {
+}
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+array(5) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ [3]=>
+ int(4)
+ [4]=>
+ int(5)
+}
+array(5) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ [3]=>
+ int(4)
+ [4]=>
+ int(5)
+}
+int(1)
+int(2)
+NULL
+int(1)
+int(2)
+int(3)
+int(1)
+int(2)
+int(3)
diff --git a/Zend/tests/arg_unpack/by_ref.phpt b/Zend/tests/arg_unpack/by_ref.phpt
new file mode 100644
index 0000000000..7c8a86be48
--- /dev/null
+++ b/Zend/tests/arg_unpack/by_ref.phpt
@@ -0,0 +1,145 @@
+--TEST--
+Argument unpacking with by-ref arguments
+--FILE--
+<?php
+
+error_reporting(E_ALL);
+
+function test1(&...$args) {
+ foreach ($args as &$arg) {
+ $arg++;
+ }
+}
+
+test1(...[1, 2, 3]);
+
+$array = [1, 2, 3];
+test1(...$array);
+var_dump($array);
+
+$array1 = [1, 2]; $array2 = [3, 4];
+test1(...$array1, ...$array2);
+var_dump($array1, $array2);
+
+function test2($val1, &$ref1, $val2, &$ref2) {
+ $ref1++;
+ $ref2++;
+}
+
+$array = [0, 0, 0, 0];
+test2(...$array);
+var_dump($array);
+
+$array1 = [1, 2]; $array2 = [4, 5];
+test1(...$array1, ...$array2);
+var_dump($array1, $array2);
+
+$a = $b = $c = $d = 0;
+$array = [0, 0, 0, 0];
+
+test2($a, ...$array);
+var_dump($a, $array);
+
+test2($a, $b, ...$array);
+var_dump($a, $b, $array);
+
+test2($a, $b, $c, ...$array);
+var_dump($a, $b, $c, $array);
+
+test2($a, $b, $c, $d, ...$array);
+var_dump($a, $b, $c, $d, $array);
+
+?>
+--EXPECTF--
+array(3) {
+ [0]=>
+ int(2)
+ [1]=>
+ int(3)
+ [2]=>
+ int(4)
+}
+array(2) {
+ [0]=>
+ int(2)
+ [1]=>
+ int(3)
+}
+array(2) {
+ [0]=>
+ int(4)
+ [1]=>
+ int(5)
+}
+array(4) {
+ [0]=>
+ int(0)
+ [1]=>
+ int(1)
+ [2]=>
+ int(0)
+ [3]=>
+ int(1)
+}
+array(2) {
+ [0]=>
+ int(2)
+ [1]=>
+ int(3)
+}
+array(2) {
+ [0]=>
+ int(5)
+ [1]=>
+ int(6)
+}
+int(0)
+array(4) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(0)
+ [2]=>
+ int(1)
+ [3]=>
+ int(0)
+}
+int(0)
+int(1)
+array(4) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(1)
+ [2]=>
+ int(1)
+ [3]=>
+ int(0)
+}
+int(0)
+int(2)
+int(0)
+array(4) {
+ [0]=>
+ int(2)
+ [1]=>
+ int(1)
+ [2]=>
+ int(1)
+ [3]=>
+ int(0)
+}
+int(0)
+int(3)
+int(0)
+int(1)
+array(4) {
+ [0]=>
+ int(2)
+ [1]=>
+ int(1)
+ [2]=>
+ int(1)
+ [3]=>
+ int(0)
+}
diff --git a/Zend/tests/arg_unpack/dynamic.phpt b/Zend/tests/arg_unpack/dynamic.phpt
new file mode 100644
index 0000000000..8f129f85a6
--- /dev/null
+++ b/Zend/tests/arg_unpack/dynamic.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Unpack arguments for dynamic call
+--FILE--
+<?php
+
+$fn = function(...$args) {
+ var_dump($args);
+};
+
+$fn(...[]);
+$fn(...[1, 2, 3]);
+$fn(1, ...[2, 3], ...[], ...[4, 5]);
+
+?>
+--EXPECT--
+array(0) {
+}
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+array(5) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ [3]=>
+ int(4)
+ [4]=>
+ int(5)
+}
diff --git a/Zend/tests/arg_unpack/internal.phpt b/Zend/tests/arg_unpack/internal.phpt
new file mode 100644
index 0000000000..adc985d940
--- /dev/null
+++ b/Zend/tests/arg_unpack/internal.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Argument unpacking with internal functions
+--FILE--
+<?php
+
+$arrays = [
+ [1, 2, 3],
+ [4, 5, 6],
+ [7, 8, 9],
+];
+var_dump(array_map(null, ...$arrays));
+
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(4)
+ [2]=>
+ int(7)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(2)
+ [1]=>
+ int(5)
+ [2]=>
+ int(8)
+ }
+ [2]=>
+ array(3) {
+ [0]=>
+ int(3)
+ [1]=>
+ int(6)
+ [2]=>
+ int(9)
+ }
+}
diff --git a/Zend/tests/arg_unpack/invalid_type.phpt b/Zend/tests/arg_unpack/invalid_type.phpt
new file mode 100644
index 0000000000..1ef545558c
--- /dev/null
+++ b/Zend/tests/arg_unpack/invalid_type.phpt
@@ -0,0 +1,59 @@
+--TEST--
+Only arrays and Traversables can be unpacked
+--FILE--
+<?php
+
+function test(...$args) {
+ var_dump($args);
+}
+
+test(...null);
+test(...42);
+test(...new stdClass);
+
+test(1, 2, 3, ..."foo", ...[4, 5]);
+test(1, 2, 3, ...new StdClass, ...3.14, ...[4, 5]);
+
+?>
+--EXPECTF--
+Warning: Only arrays and Traversables can be unpacked in %s on line %d
+array(0) {
+}
+
+Warning: Only arrays and Traversables can be unpacked in %s on line %d
+array(0) {
+}
+
+Warning: Only arrays and Traversables can be unpacked in %s on line %d
+array(0) {
+}
+
+Warning: Only arrays and Traversables can be unpacked in %s on line %d
+array(5) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ [3]=>
+ int(4)
+ [4]=>
+ int(5)
+}
+
+Warning: Only arrays and Traversables can be unpacked in %s on line %d
+
+Warning: Only arrays and Traversables can be unpacked in %s on line %d
+array(5) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ [3]=>
+ int(4)
+ [4]=>
+ int(5)
+}
diff --git a/Zend/tests/arg_unpack/many_args.phpt b/Zend/tests/arg_unpack/many_args.phpt
new file mode 100644
index 0000000000..0ef5a30d6d
--- /dev/null
+++ b/Zend/tests/arg_unpack/many_args.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Argument unpacking with many arguments
+--FILE--
+<?php
+
+function fn(...$args) {
+ var_dump(count($args));
+}
+
+$array = array_fill(0, 10000, 42);
+fn(...$array, ...$array);
+
+?>
+--EXPECT--
+int(20000)
diff --git a/Zend/tests/arg_unpack/method.phpt b/Zend/tests/arg_unpack/method.phpt
new file mode 100644
index 0000000000..fb9ace8378
--- /dev/null
+++ b/Zend/tests/arg_unpack/method.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Unpack arguments for method calls
+--FILE--
+<?php
+
+class Foo {
+ public function test(...$args) {
+ var_dump($args);
+ }
+
+ public static function test2(...$args) {
+ var_dump($args);
+ }
+}
+
+$foo = new Foo;
+Foo::test2(1, 2, ...[3, 4], ...[], ...[5]);
+
+?>
+--EXPECT--
+array(5) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ [3]=>
+ int(4)
+ [4]=>
+ int(5)
+}
diff --git a/Zend/tests/arg_unpack/new.phpt b/Zend/tests/arg_unpack/new.phpt
new file mode 100644
index 0000000000..7a0968e2c9
--- /dev/null
+++ b/Zend/tests/arg_unpack/new.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Unpack arguments for new expression
+--FILE--
+<?php
+
+class Foo {
+ public function __construct(...$args) {
+ var_dump($args);
+ }
+}
+
+new Foo(...[]);
+new Foo(...[1, 2, 3]);
+new Foo(...[1], ...[], ...[2, 3]);
+
+?>
+--EXPECT--
+array(0) {
+}
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
diff --git a/Zend/tests/arg_unpack/positional_arg_after_unpack_error.phpt b/Zend/tests/arg_unpack/positional_arg_after_unpack_error.phpt
new file mode 100644
index 0000000000..30e13e3d10
--- /dev/null
+++ b/Zend/tests/arg_unpack/positional_arg_after_unpack_error.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Positional arguments cannot be used after argument unpacking
+--FILE--
+<?php
+
+var_dump(...[1, 2, 3], 4);
+
+?>
+--EXPECTF--
+Fatal error: Cannot use positional argument after argument unpacking in %s on line %d
diff --git a/Zend/tests/arg_unpack/string_keys.phpt b/Zend/tests/arg_unpack/string_keys.phpt
new file mode 100644
index 0000000000..443a882941
--- /dev/null
+++ b/Zend/tests/arg_unpack/string_keys.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Argument unpacking does not work with string keys (forward compatibility for named args)
+--FILE--
+<?php
+
+set_error_handler(function($errno, $errstr) {
+ var_dump($errstr);
+});
+
+var_dump(...[1, 2, "foo" => 3, 4]);
+var_dump(...new ArrayIterator([1, 2, "foo" => 3, 4]));
+
+?>
+--EXPECTF--
+string(36) "Cannot unpack array with string keys"
+int(1)
+int(2)
+string(42) "Cannot unpack Traversable with string keys"
+int(1)
+int(2)
diff --git a/Zend/tests/arg_unpack/traversable_throwing_exception.phpt b/Zend/tests/arg_unpack/traversable_throwing_exception.phpt
new file mode 100644
index 0000000000..abbf537587
--- /dev/null
+++ b/Zend/tests/arg_unpack/traversable_throwing_exception.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Traversables that throw exceptions are properly handled during argument unpack
+--FILE--
+<?php
+
+function test(...$args) {
+ var_dump($args);
+}
+
+class Foo implements IteratorAggregate {
+ public function getIterator() {
+ throw new Exception('getIterator');
+ }
+}
+
+function gen() {
+ yield 1;
+ yield 2;
+ throw new Exception('gen');
+}
+
+try {
+ test(1, 2, ...new Foo, ...[3, 4]);
+} catch (Exception $e) { var_dump($e->getMessage()); }
+
+try {
+ test(1, 2, ...gen(), ...[3, 4]);
+} catch (Exception $e) { var_dump($e->getMessage()); }
+
+?>
+--EXPECT--
+string(11) "getIterator"
+string(3) "gen"
diff --git a/Zend/tests/arg_unpack/traversable_with_by_ref_parameters.phpt b/Zend/tests/arg_unpack/traversable_with_by_ref_parameters.phpt
new file mode 100644
index 0000000000..711287eded
--- /dev/null
+++ b/Zend/tests/arg_unpack/traversable_with_by_ref_parameters.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Traversables cannot be unpacked into by-reference parameters
+--FILE--
+<?php
+
+function test($val1, $val2, $val3, &$ref) {
+ $ref = 42;
+}
+
+function gen($array) {
+ foreach ($array as $element) {
+ yield $element;
+ }
+}
+
+test(1, 2, 3, $b, ...gen([4, 5, 6]));
+var_dump($b);
+
+test(...gen([1, 2, 3, 4]));
+test(1, 2, ...gen([3, 4]));
+test(...gen([1, 2]), ...gen([3, 4]));
+
+?>
+--EXPECTF--
+int(42)
+
+Warning: Cannot pass by-reference argument 4 of test() by unpacking a Traversable, passing by-value instead in %s on line %d
+
+Warning: Cannot pass by-reference argument 4 of test() by unpacking a Traversable, passing by-value instead in %s on line %d
+
+Warning: Cannot pass by-reference argument 4 of test() by unpacking a Traversable, passing by-value instead in %s on line %d
diff --git a/Zend/tests/bug30820.phpt b/Zend/tests/bug30820.phpt
index 97e46e9287..a0f71e72a7 100644
--- a/Zend/tests/bug30820.phpt
+++ b/Zend/tests/bug30820.phpt
@@ -2,6 +2,7 @@
Bug #30820 (static member conflict with $this->member silently ignored)
--INI--
error_reporting=4095
+opcache.optimization_level=0
--FILE--
<?php
class Blah {
diff --git a/Zend/tests/bug65784.phpt b/Zend/tests/bug65784.phpt
index adc34113a5..29f086b5e3 100644
--- a/Zend/tests/bug65784.phpt
+++ b/Zend/tests/bug65784.phpt
@@ -1,7 +1,5 @@
--TEST--
Fixed Bug #65784 (Segfault with finally)
---XFAIL--
-This bug is not fixed in 5.5 due to ABI BC
--FILE--
<?php
function foo1() {
diff --git a/Zend/tests/bug66015.phpt b/Zend/tests/bug66015.phpt
new file mode 100644
index 0000000000..4f6d51e0dd
--- /dev/null
+++ b/Zend/tests/bug66015.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Bug #66015 (wrong array indexing in class's static property)
+--FILE--
+<?php
+class Test
+{
+ const FIRST = 1;
+ const SECOND = 2;
+ const THIRD = 3;
+
+ protected static $array = [
+ self::FIRST => 'first',
+ 'second',
+ 'third'
+ ];
+
+ public function __construct()
+ {
+ var_export(self::$array);
+ }
+}
+
+$test = new Test();
+?>
+--EXPECTF--
+array (
+ 1 => 'first',
+ 2 => 'second',
+ 3 => 'third',
+)
diff --git a/Zend/tests/bug66252.phpt b/Zend/tests/bug66252.phpt
new file mode 100644
index 0000000000..e692a8e706
--- /dev/null
+++ b/Zend/tests/bug66252.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #66252 (Problems in AST evaluation invalidating valid parent:: reference)
+--FILE--
+<?php
+class A {
+ const HW = "this is A";
+}
+class B extends A {
+ const BHW = parent::HW . " extended by B";
+}
+const C = B::BHW;
+echo C, "\n";
+--EXPECT--
+this is A extended by B
diff --git a/Zend/tests/bug66660.phpt b/Zend/tests/bug66660.phpt
new file mode 100644
index 0000000000..9ae8a27336
--- /dev/null
+++ b/Zend/tests/bug66660.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #66660 (Composer.phar install/update fails)
+--STDIN--
+<?php __CLASS__ ?>
+--FILE--
+<?php
+file_put_contents(__DIR__."/bug66660.tmp.php", "<?php __CLASS__ ?>");
+echo php_strip_whitespace(__DIR__."/bug66660.tmp.php");
+?>
+--CLEAN--
+<?php unlink(__DIR__."/bug66660.tmp.php"); ?>
+--EXPECT--
+<?php __CLASS__ ?>
diff --git a/Zend/tests/bug67169.phpt b/Zend/tests/bug67169.phpt
new file mode 100644
index 0000000000..8aa6aaf24a
--- /dev/null
+++ b/Zend/tests/bug67169.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #67169: array_splice all elements, then []= gives wrong index
+--FILE--
+<?php
+
+$array = array('a', 'b');
+array_splice($array, 0, 2);
+$array[] = 'c';
+var_dump($array);
+
+$array = array('a', 'b');
+array_shift($array);
+array_shift($array);
+$array[] = 'c';
+var_dump($array);
+
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ string(1) "c"
+}
+array(1) {
+ [0]=>
+ string(1) "c"
+}
diff --git a/Zend/tests/bug67368.phpt b/Zend/tests/bug67368.phpt
new file mode 100644
index 0000000000..c92e994b94
--- /dev/null
+++ b/Zend/tests/bug67368.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Bug #67368 (Memory leak with immediately dereferenced array in class constant)
+--INI--
+report_memleaks=1
+--FILE--
+<?php
+class FooBar {
+ const bar = ["bar" => 3]["bar"];
+}
+echo "okey";
+--EXPECTF--
+okey
diff --git a/Zend/tests/bug67436/bug67436_nohandler.phpt b/Zend/tests/bug67436/bug67436_nohandler.phpt
index 464f711532..f1760c6462 100644
--- a/Zend/tests/bug67436/bug67436_nohandler.phpt
+++ b/Zend/tests/bug67436/bug67436_nohandler.phpt
@@ -19,6 +19,6 @@ $b = new b();
$b->test();
--EXPECTF--
-Strict Standards: Declaration of b::test() should be compatible with a::test($arg = c::TESTCONSTANT) in %s/bug67436/b.php on line %d
+Strict Standards: Declaration of b::test() should be compatible with a::test($arg = c::TESTCONSTANT) in %s%ebug67436%eb.php on line %d
b::test()
a::test(c::TESTCONSTANT)
diff --git a/Zend/tests/bug67938.phpt b/Zend/tests/bug67938.phpt
new file mode 100644
index 0000000000..6597c4895f
--- /dev/null
+++ b/Zend/tests/bug67938.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Bug #67938: Segfault when extending interface method with variadic
+--FILE--
+<?php
+
+interface TestInterface {
+ public function foo();
+ public function bar(array $bar);
+}
+
+class Test implements TestInterface {
+ public function foo(...$args) {
+ echo __METHOD__, "\n";
+ }
+ public function bar(array $bar, ...$args) {
+ echo __METHOD__, "\n";
+ }
+}
+
+$obj = new Test;
+$obj->foo();
+$obj->bar([]);
+
+?>
+--EXPECT--
+Test::foo
+Test::bar
diff --git a/Zend/tests/bug68446.phpt b/Zend/tests/bug68446.phpt
new file mode 100644
index 0000000000..48e6f52f1c
--- /dev/null
+++ b/Zend/tests/bug68446.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Bug #68446 (Array constant not accepted for array parameter default)
+--FILE--
+<?php
+const FOO = [1];
+const BAR = null;
+
+function a(array $a = FOO) {
+ var_dump($a);
+}
+
+function b(array $b = BAR) {
+ var_dump($b);
+}
+
+b(null);
+b([]);
+b();
+a([]);
+a();
+a(null);
+?>
+--EXPECTF--
+NULL
+array(0) {
+}
+NULL
+array(0) {
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+
+Catchable fatal error: Argument 1 passed to a() must be of the type array, null given, called in %s on line %d and defined in %s on line %d
+
diff --git a/Zend/tests/class_properties_dynamic.phpt b/Zend/tests/class_properties_dynamic.phpt
new file mode 100644
index 0000000000..8a1fc6f029
--- /dev/null
+++ b/Zend/tests/class_properties_dynamic.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Class Property Expressions
+--FILE--
+<?php
+class Foo {
+ const BAR = 1 << 0;
+ const BAZ = 1 << 1;
+ public $bar = self::BAR | self::BAZ;
+}
+echo (new Foo)->bar;
+?>
+--EXPECTF--
+3
diff --git a/Zend/tests/class_properties_static.phpt b/Zend/tests/class_properties_static.phpt
new file mode 100644
index 0000000000..9a56466340
--- /dev/null
+++ b/Zend/tests/class_properties_static.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Static Class Property Expressions
+--FILE--
+<?php
+class Foo {
+ public $b1 = 1 + 1;
+ public $b2 = 1 << 2;
+ public $b3 = "foo " . " bar " . " baz";
+}
+$f = new Foo;
+var_dump(
+ $f->b1,
+ $f->b2,
+ $f->b3
+);
+?>
+--EXPECT--
+int(2)
+int(4)
+string(13) "foo bar baz"
diff --git a/Zend/tests/closure_018.phpt b/Zend/tests/closure_018.phpt
index d98c78aeac..2dcf15c6aa 100644
--- a/Zend/tests/closure_018.phpt
+++ b/Zend/tests/closure_018.phpt
@@ -21,8 +21,11 @@ var_dump($x = $test->test($y));
var_dump($y, $x);
?>
---EXPECT--
+--EXPECTF--
+Notice: Only variable references should be returned by reference in %sclosure_018.php on line 7
int(4)
+
+Notice: Only variable references should be returned by reference in %sclosure_018.php on line 7
int(16)
int(16)
int(16)
diff --git a/Zend/tests/closure_019.phpt b/Zend/tests/closure_019.phpt
index 0c4c34e163..57aa2dec17 100644
--- a/Zend/tests/closure_019.phpt
+++ b/Zend/tests/closure_019.phpt
@@ -20,7 +20,10 @@ test();
?>
--EXPECTF--
+Notice: Only variable references should be returned by reference in %sclosure_019.php on line 4
int(9)
+
+Notice: Only variable references should be returned by reference in %sclosure_019.php on line 4
int(81)
Fatal error: Cannot pass parameter 1 by reference in %s on line %d
diff --git a/Zend/tests/constant_expressions.phpt b/Zend/tests/constant_expressions.phpt
new file mode 100644
index 0000000000..cf6474bd63
--- /dev/null
+++ b/Zend/tests/constant_expressions.phpt
@@ -0,0 +1,96 @@
+--TEST--
+Constant Expressions
+--FILE--
+<?php
+const T_1 = 1 << 1;
+const T_2 = 1 / 2;
+const T_3 = 1.5 + 1.5;
+const T_4 = "foo" . "bar";
+const T_5 = (1.5 + 1.5) * 2;
+const T_6 = "foo" . 2 . 3 . 4.0;
+const T_7 = __LINE__;
+const T_8 = <<<ENDOFSTRING
+This is a test string
+ENDOFSTRING;
+const T_9 = ~-1;
+const T_10 = (-1?:1) + (0?2:3);
+const T_11 = 1 && 0;
+const T_12 = 1 and 1;
+const T_13 = 0 || 0;
+const T_14 = 1 or 0;
+const T_15 = 1 xor 1;
+const T_16 = 1 xor 0;
+const T_17 = 1 < 0;
+const T_18 = 0 <= 0;
+const T_19 = 1 > 0;
+const T_20 = 1 >= 0;
+const T_21 = 1 === 1;
+const T_22 = 1 !== 1;
+const T_23 = 0 != "0";
+const T_24 = 1 == "1";
+
+// Test order of operations
+const T_25 = 1 + 2 * 3;
+
+// Test for memory leaks
+const T_26 = "1" + 2 + "3";
+
+// Allow T_POW
+const T_27 = 2 ** 3;
+
+var_dump(T_1);
+var_dump(T_2);
+var_dump(T_3);
+var_dump(T_4);
+var_dump(T_5);
+var_dump(T_6);
+var_dump(T_7);
+var_dump(T_8);
+var_dump(T_9);
+var_dump(T_10);
+var_dump(T_11);
+var_dump(T_12);
+var_dump(T_13);
+var_dump(T_14);
+var_dump(T_15);
+var_dump(T_16);
+var_dump(T_17);
+var_dump(T_18);
+var_dump(T_19);
+var_dump(T_20);
+var_dump(T_21);
+var_dump(T_22);
+var_dump(T_23);
+var_dump(T_24);
+var_dump(T_25);
+var_dump(T_26);
+var_dump(T_27);
+?>
+--EXPECT--
+int(2)
+float(0.5)
+float(3)
+string(6) "foobar"
+float(6)
+string(6) "foo234"
+int(8)
+string(21) "This is a test string"
+int(0)
+int(2)
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+bool(true)
+int(7)
+int(6)
+int(8)
diff --git a/Zend/tests/constant_expressions_arrays.phpt b/Zend/tests/constant_expressions_arrays.phpt
new file mode 100644
index 0000000000..2ab03453de
--- /dev/null
+++ b/Zend/tests/constant_expressions_arrays.phpt
@@ -0,0 +1,66 @@
+--TEST--
+Constant expressions with arrays
+--FILE--
+<?php
+const a = [1,2,[3,[4]]];
+const b = a[0];
+const c = a[2][0];
+const d = a[2];
+const e = ["string" => [1]]["string"][0];
+
+var_dump(b, c, e);
+
+function test ($a = d[1][0]) {
+ var_dump($a);
+}
+
+test();
+
+class foo {
+ const bar = [1][0];
+}
+
+var_dump(foo::bar);
+
+var_dump(a, a[0], a[2], a[2][1], a[3]);
+
+?>
+--EXPECTF--
+int(1)
+int(3)
+int(1)
+int(4)
+int(1)
+
+Notice: Undefined offset: 3 in %s on line %d
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ array(2) {
+ [0]=>
+ int(3)
+ [1]=>
+ array(1) {
+ [0]=>
+ int(4)
+ }
+ }
+}
+int(1)
+array(2) {
+ [0]=>
+ int(3)
+ [1]=>
+ array(1) {
+ [0]=>
+ int(4)
+ }
+}
+array(1) {
+ [0]=>
+ int(4)
+}
+NULL
diff --git a/Zend/tests/constant_expressions_classes.phpt b/Zend/tests/constant_expressions_classes.phpt
new file mode 100644
index 0000000000..6298ff66d6
--- /dev/null
+++ b/Zend/tests/constant_expressions_classes.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Constant scalar expressions with autoloading and classes
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+--SKIPIF--
+<?php if (!extension_loaded('Zend OPcache') || php_sapi_name() != "cli") die("skip CLI only"); ?>
+--FILE--
+<?php
+
+# This test validates that autoloading works for common const expression (AST) use cases
+$classlist = [
+ 'A'=> 'class A { const HW = "this is A"; }',
+ 'B'=> 'class B extends A { const HW = parent::HW." extended by B"; }',
+ 'space1\C' => 'namespace space1; class C { const HW = "this is space1\C"; }',
+ 'D' => 'class D { const HW = \space1\C::HW." extented by D"; }',
+ 'trE' => 'trait trE { public static function getHW() { return parent::HW; } }',
+ 'E' => 'class E extends B { use trE; }',
+ 'F' => 'class F { const XX = "this is F"; }',
+ 'G' => 'class G extends F { const XX = parent::XX." extended by G"; public static function get_me($x = "got ".self::XX) { return $x; } }',
+];
+
+spl_autoload_register(function ($class) use ($classlist) {
+ if (isset($classlist[$class])) {
+ eval($classlist[$class]);
+ } else {
+ die("Cannot autoload $class\n");
+ }
+});
+
+printf("B::HW = %s\n", B::HW);
+printf("D::HW = %s\n", D::HW);
+
+printf("E::getHW() = %s\n", E::getHW());
+printf("G::get_me() = %s\n", G::get_me());
+
+?>
+--EXPECT--
+B::HW = this is A extended by B
+D::HW = this is space1\C extented by D
+E::getHW() = this is A extended by B
+G::get_me() = got this is F extended by G
diff --git a/Zend/tests/constant_expressions_dynamic.phpt b/Zend/tests/constant_expressions_dynamic.phpt
new file mode 100644
index 0000000000..21c9216cc1
--- /dev/null
+++ b/Zend/tests/constant_expressions_dynamic.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Dynamic Constant Expressions
+--FILE--
+<?php
+const FOO = 1;
+const BAR = FOO | 2;
+
+echo BAR;
+?>
+--EXPECTF--
+3
diff --git a/Zend/tests/constant_expressions_self_referencing_array.phpt b/Zend/tests/constant_expressions_self_referencing_array.phpt
new file mode 100644
index 0000000000..ae76a08602
--- /dev/null
+++ b/Zend/tests/constant_expressions_self_referencing_array.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Self-referencing constant expression (part of a constant AST)
+--FILE--
+<?php
+class A {
+ const FOO = [self::BAR];
+ const BAR = [self::FOO];
+}
+var_dump(A::FOO);
+?>
+--EXPECTF--
+Fatal error: Cannot declare self-referencing constant 'self::FOO' in %s on line %d
+
diff --git a/Zend/tests/debug_info-error-0.0.phpt b/Zend/tests/debug_info-error-0.0.phpt
new file mode 100644
index 0000000000..1c8dfc8853
--- /dev/null
+++ b/Zend/tests/debug_info-error-0.0.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing __debugInfo() magic method with bad returns ZERO (float)
+--FILE--
+<?php
+
+class C {
+ public $val;
+ public function __debugInfo() {
+ return $this->val;
+ }
+ public function __construct($val) {
+ $this->val = $val;
+ }
+}
+
+$c = new C(0.0);
+var_dump($c);
+--EXPECTF--
+Fatal error: __debuginfo() must return an array in %s%eZend%etests%edebug_info-error-0.0.php on line %d
diff --git a/Zend/tests/debug_info-error-0.phpt b/Zend/tests/debug_info-error-0.phpt
new file mode 100644
index 0000000000..868ac2f75f
--- /dev/null
+++ b/Zend/tests/debug_info-error-0.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing __debugInfo() magic method with bad returns ZERO
+--FILE--
+<?php
+
+class C {
+ public $val;
+ public function __debugInfo() {
+ return $this->val;
+ }
+ public function __construct($val) {
+ $this->val = $val;
+ }
+}
+
+$c = new C(0);
+var_dump($c);
+--EXPECTF--
+Fatal error: __debuginfo() must return an array in %s%eZend%etests%edebug_info-error-0.php on line %d
diff --git a/Zend/tests/debug_info-error-1.0.phpt b/Zend/tests/debug_info-error-1.0.phpt
new file mode 100644
index 0000000000..27611237bb
--- /dev/null
+++ b/Zend/tests/debug_info-error-1.0.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing __debugInfo() magic method with bad returns ONE (float)
+--FILE--
+<?php
+
+class C {
+ public $val;
+ public function __debugInfo() {
+ return $this->val;
+ }
+ public function __construct($val) {
+ $this->val = $val;
+ }
+}
+
+$c = new C(1.0);
+var_dump($c);
+--EXPECTF--
+Fatal error: __debuginfo() must return an array in %s%eZend%etests%edebug_info-error-1.0.php on line %d
diff --git a/Zend/tests/debug_info-error-1.phpt b/Zend/tests/debug_info-error-1.phpt
new file mode 100644
index 0000000000..e2e9823ed4
--- /dev/null
+++ b/Zend/tests/debug_info-error-1.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing __debugInfo() magic method with bad returns ONE
+--FILE--
+<?php
+
+class C {
+ public $val;
+ public function __debugInfo() {
+ return $this->val;
+ }
+ public function __construct($val) {
+ $this->val = $val;
+ }
+}
+
+$c = new C(1);
+var_dump($c);
+--EXPECTF--
+Fatal error: __debuginfo() must return an array in %s%eZend%etests%edebug_info-error-1.php on line %d
diff --git a/Zend/tests/debug_info-error-empty_str.phpt b/Zend/tests/debug_info-error-empty_str.phpt
new file mode 100644
index 0000000000..72ab85d7d8
--- /dev/null
+++ b/Zend/tests/debug_info-error-empty_str.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing __debugInfo() magic method with bad returns EMPTY STRING
+--FILE--
+<?php
+
+class C {
+ public $val;
+ public function __debugInfo() {
+ return $this->val;
+ }
+ public function __construct($val) {
+ $this->val = $val;
+ }
+}
+
+$c = new C("");
+var_dump($c);
+--EXPECTF--
+Fatal error: __debuginfo() must return an array in %s%eZend%etests%edebug_info-error-empty_str.php on line %d
diff --git a/Zend/tests/debug_info-error-false.phpt b/Zend/tests/debug_info-error-false.phpt
new file mode 100644
index 0000000000..d6e19938af
--- /dev/null
+++ b/Zend/tests/debug_info-error-false.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing __debugInfo() magic method with bad returns FALSE
+--FILE--
+<?php
+
+class C {
+ public $val;
+ public function __debugInfo() {
+ return $this->val;
+ }
+ public function __construct($val) {
+ $this->val = $val;
+ }
+}
+
+$c = new C(false);
+var_dump($c);
+--EXPECTF--
+Fatal error: __debuginfo() must return an array in %s%eZend%etests%edebug_info-error-false.php on line %d
diff --git a/Zend/tests/debug_info-error-object.phpt b/Zend/tests/debug_info-error-object.phpt
new file mode 100644
index 0000000000..40737db2b6
--- /dev/null
+++ b/Zend/tests/debug_info-error-object.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing __debugInfo() magic method with bad returns OBJECT
+--FILE--
+<?php
+
+class C {
+ public $val;
+ public function __debugInfo() {
+ return $this->val;
+ }
+ public function __construct($val) {
+ $this->val = $val;
+ }
+}
+
+$c = new C(new stdClass);
+var_dump($c);
+--EXPECTF--
+Fatal error: __debuginfo() must return an array in %s%eZend%etests%edebug_info-error-object.php on line %d
diff --git a/Zend/tests/debug_info-error-resource.phpt b/Zend/tests/debug_info-error-resource.phpt
new file mode 100644
index 0000000000..ebdc37e534
--- /dev/null
+++ b/Zend/tests/debug_info-error-resource.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing __debugInfo() magic method with bad returns RESOURCE
+--FILE--
+<?php
+
+class C {
+ public $val;
+ public function __debugInfo() {
+ return $this->val;
+ }
+ public function __construct($val) {
+ $this->val = $val;
+ }
+}
+
+$c = new C(fopen("data:text/plain,Foo", 'r'));
+var_dump($c);
+--EXPECTF--
+Fatal error: __debuginfo() must return an array in %s%eZend%etests%edebug_info-error-resource.php on line %d
diff --git a/Zend/tests/debug_info-error-str.phpt b/Zend/tests/debug_info-error-str.phpt
new file mode 100644
index 0000000000..aa16d5bf7c
--- /dev/null
+++ b/Zend/tests/debug_info-error-str.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing __debugInfo() magic method with bad returns STRING
+--FILE--
+<?php
+
+class C {
+ public $val;
+ public function __debugInfo() {
+ return $this->val;
+ }
+ public function __construct($val) {
+ $this->val = $val;
+ }
+}
+
+$c = new C("foo");
+var_dump($c);
+--EXPECTF--
+Fatal error: __debuginfo() must return an array in %s%eZend%etests%edebug_info-error-str.php on line %d
diff --git a/Zend/tests/debug_info-error-true.phpt b/Zend/tests/debug_info-error-true.phpt
new file mode 100644
index 0000000000..2501e8a412
--- /dev/null
+++ b/Zend/tests/debug_info-error-true.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing __debugInfo() magic method with bad returns TRUE
+--FILE--
+<?php
+
+class C {
+ public $val;
+ public function __debugInfo() {
+ return $this->val;
+ }
+ public function __construct($val) {
+ $this->val = $val;
+ }
+}
+
+$c = new C(true);
+var_dump($c);
+--EXPECTF--
+Fatal error: __debuginfo() must return an array in %s%eZend%etests%edebug_info-error-true.php on line %d
diff --git a/Zend/tests/debug_info.phpt b/Zend/tests/debug_info.phpt
new file mode 100644
index 0000000000..c82ddb2143
--- /dev/null
+++ b/Zend/tests/debug_info.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Testing __debugInfo() magic method
+--FILE--
+<?php
+
+class Foo {
+ public $d = 4;
+ protected $e = 5;
+ private $f = 6;
+
+ public function __debugInfo() {
+ return ['a'=>1, "\0*\0b"=>2, "\0Foo\0c"=>3];
+ }
+}
+
+class Bar {
+ public $val = 123;
+
+ public function __debugInfo() {
+ return null;
+ }
+}
+
+$f = new Foo;
+var_dump($f);
+
+$b = new Bar;
+var_dump($b);
+--EXPECTF--
+object(Foo)#%d (3) {
+ ["a"]=>
+ int(1)
+ ["b":protected]=>
+ int(2)
+ ["c":"Foo":private]=>
+ int(3)
+}
+object(Bar)#%d (0) {
+}
diff --git a/Zend/tests/dereference_002.phpt b/Zend/tests/dereference_002.phpt
index 022ff370d2..da13decc39 100644
--- a/Zend/tests/dereference_002.phpt
+++ b/Zend/tests/dereference_002.phpt
@@ -76,4 +76,4 @@ NULL
Notice: Undefined offset: 3 in %s on line %d
-Fatal error: Call to a member function bar() on a non-object in %s on line %d
+Fatal error: Call to a member function bar() on null in %s on line %d
diff --git a/Zend/tests/errmsg_040.phpt b/Zend/tests/errmsg_040.phpt
index f3d0afcf0a..cda8d4c76a 100644
--- a/Zend/tests/errmsg_040.phpt
+++ b/Zend/tests/errmsg_040.phpt
@@ -7,7 +7,17 @@ class test {
const TEST = array(1,2,3);
}
+var_dump(test::TEST);
+
echo "Done\n";
?>
--EXPECTF--
-Fatal error: Arrays are not allowed in class constants in %s on line %d
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+Done
diff --git a/Zend/tests/finally_goto_001.phpt b/Zend/tests/finally_goto_001.phpt
new file mode 100644
index 0000000000..990f78d4c7
--- /dev/null
+++ b/Zend/tests/finally_goto_001.phpt
@@ -0,0 +1,14 @@
+--TEST--
+jmp into a finally block 01
+--FILE--
+<?php
+function foo() {
+ goto test;
+ try {
+ } finally {
+test:
+ }
+}
+?>
+--EXPECTF--
+Fatal error: jump into a finally block is disallowed in %sfinally_goto_001.php on line %d
diff --git a/Zend/tests/finally_goto_002.phpt b/Zend/tests/finally_goto_002.phpt
new file mode 100644
index 0000000000..a6bd9e307f
--- /dev/null
+++ b/Zend/tests/finally_goto_002.phpt
@@ -0,0 +1,14 @@
+--TEST--
+jmp into a finally block 02
+--FILE--
+<?php
+function foo() {
+ try {
+ goto test;
+ } finally {
+test:
+ }
+}
+?>
+--EXPECTF--
+Fatal error: jump into a finally block is disallowed in %sfinally_goto_002.php on line %d
diff --git a/Zend/tests/finally_goto_003.phpt b/Zend/tests/finally_goto_003.phpt
new file mode 100644
index 0000000000..8529ff7865
--- /dev/null
+++ b/Zend/tests/finally_goto_003.phpt
@@ -0,0 +1,15 @@
+--TEST--
+jmp into a finally block 03
+--FILE--
+<?php
+function foo() {
+ try {
+ } finally {
+ goto test;
+test:
+ }
+}
+echo "okey";
+?>
+--EXPECTF--
+okey
diff --git a/Zend/tests/finally_goto_004.phpt b/Zend/tests/finally_goto_004.phpt
new file mode 100644
index 0000000000..d88ceedf52
--- /dev/null
+++ b/Zend/tests/finally_goto_004.phpt
@@ -0,0 +1,14 @@
+--TEST--
+jmp into a finally block 03
+--FILE--
+<?php
+function foo() {
+ try {
+ } finally {
+test:
+ }
+ goto test;
+}
+?>
+--EXPECTF--
+Fatal error: jump into a finally block is disallowed in %sfinally_goto_004.php on line %d
diff --git a/Zend/tests/function_arguments_003.phpt b/Zend/tests/function_arguments_003.phpt
new file mode 100644
index 0000000000..b882476d1d
--- /dev/null
+++ b/Zend/tests/function_arguments_003.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Function Argument Parsing #003
+--FILE--
+<?php
+const a = 10;
+
+function t1($a = 1 + 1, $b = 1 << 2, $c = "foo" . "bar", $d = a * 10) {
+ var_dump($a, $b, $c, $d);
+}
+
+t1();
+?>
+--EXPECT--
+int(2)
+int(4)
+string(6) "foobar"
+int(100)
diff --git a/Zend/tests/incompat_ctx_user.phpt b/Zend/tests/incompat_ctx_user.phpt
new file mode 100644
index 0000000000..2d9b59c1e8
--- /dev/null
+++ b/Zend/tests/incompat_ctx_user.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Incompatible context call (non-internal function)
+--INI--
+error_reporting=E_ALL
+--FILE--
+<?php
+
+class A {
+ function foo() { var_dump(get_class($this)); }
+}
+class B {
+ function bar() { A::foo(); }
+}
+$b = new B;
+$b->bar();
+
+?>
+--EXPECTF--
+Deprecated: Non-static method A::foo() should not be called statically, assuming $this from incompatible context in %s on line %d
+string(1) "B"
diff --git a/Zend/tests/ns_059.phpt b/Zend/tests/ns_059.phpt
index ea66037b43..701e448812 100644
--- a/Zend/tests/ns_059.phpt
+++ b/Zend/tests/ns_059.phpt
@@ -3,6 +3,9 @@
--FILE--
<?php
const C = array();
---EXPECTF--
-Fatal error: Arrays are not allowed as constants in %sns_059.php on line 2
+var_dump(C);
+?>
+--EXPECTF--
+array(0) {
+}
diff --git a/Zend/tests/static_variable.phpt b/Zend/tests/static_variable.phpt
new file mode 100644
index 0000000000..62ca565ffe
--- /dev/null
+++ b/Zend/tests/static_variable.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Static Variable Expressions
+--FILE--
+<?php
+const bar = 2, baz = bar + 1;
+
+function foo() {
+ static $a = 1 + 1;
+ static $b = [bar => 1 + 1, baz * 2 => 1 << 2];
+ static $c = [1 => bar, 3 => baz];
+ var_dump($a, $b, $c);
+}
+
+foo();
+?>
+--EXPECT--
+int(2)
+array(2) {
+ [2]=>
+ int(2)
+ [6]=>
+ int(4)
+}
+array(2) {
+ [1]=>
+ int(2)
+ [3]=>
+ int(3)
+}
diff --git a/Zend/tests/use_const/alias.phpt b/Zend/tests/use_const/alias.phpt
new file mode 100644
index 0000000000..f179393006
--- /dev/null
+++ b/Zend/tests/use_const/alias.phpt
@@ -0,0 +1,26 @@
+--TEST--
+aliasing imported constants to resolve naming conflicts
+--FILE--
+<?php
+
+namespace foo {
+ const baz = 42;
+}
+
+namespace bar {
+ const baz = 43;
+}
+
+namespace {
+ use const foo\baz as foo_baz,
+ bar\baz as bar_baz;
+ var_dump(foo_baz);
+ var_dump(bar_baz);
+ echo "Done\n";
+}
+
+?>
+--EXPECT--
+int(42)
+int(43)
+Done
diff --git a/Zend/tests/use_const/basic.phpt b/Zend/tests/use_const/basic.phpt
new file mode 100644
index 0000000000..6eaed7f27d
--- /dev/null
+++ b/Zend/tests/use_const/basic.phpt
@@ -0,0 +1,22 @@
+--TEST--
+import namespaced constant
+--FILE--
+<?php
+
+namespace foo\bar {
+ const baz = 42;
+ const qux = 43;
+}
+
+namespace {
+ use const foo\bar\baz, foo\bar\qux;
+ var_dump(baz);
+ var_dump(qux);
+ echo "Done\n";
+}
+
+?>
+--EXPECT--
+int(42)
+int(43)
+Done
diff --git a/Zend/tests/use_const/case_sensivity.phpt b/Zend/tests/use_const/case_sensivity.phpt
new file mode 100644
index 0000000000..1977daa93b
--- /dev/null
+++ b/Zend/tests/use_const/case_sensivity.phpt
@@ -0,0 +1,12 @@
+--TEST--
+importing const with same name but different case
+--FILE--
+<?php
+
+namespace {
+ use const foo\bar;
+ use const foo\BAR;
+}
+
+?>
+--EXPECT--
diff --git a/Zend/tests/use_const/conflicting_use.phpt b/Zend/tests/use_const/conflicting_use.phpt
new file mode 100644
index 0000000000..3b3c4b3262
--- /dev/null
+++ b/Zend/tests/use_const/conflicting_use.phpt
@@ -0,0 +1,21 @@
+--TEST--
+use const statements with conflicting names
+--FILE--
+<?php
+
+namespace foo {
+ const baz = 42;
+}
+
+namespace bar {
+ const baz = 42;
+}
+
+namespace {
+ use const foo\baz, bar\baz;
+ echo "Done\n";
+}
+
+?>
+--EXPECTF--
+Fatal error: Cannot use const bar\baz as baz because the name is already in use in %s on line %d
diff --git a/Zend/tests/use_const/conflicting_use_alias.phpt b/Zend/tests/use_const/conflicting_use_alias.phpt
new file mode 100644
index 0000000000..8b563a4ca9
--- /dev/null
+++ b/Zend/tests/use_const/conflicting_use_alias.phpt
@@ -0,0 +1,18 @@
+--TEST--
+use and use const with the same alias
+--FILE--
+<?php
+
+namespace {
+ const foo = 'foo';
+}
+
+namespace x {
+ use foo as bar;
+ use const foo as bar;
+ var_dump(bar);
+}
+
+?>
+--EXPECT--
+string(3) "foo"
diff --git a/Zend/tests/use_const/define_imported.phpt b/Zend/tests/use_const/define_imported.phpt
new file mode 100644
index 0000000000..5eb44be64a
--- /dev/null
+++ b/Zend/tests/use_const/define_imported.phpt
@@ -0,0 +1,14 @@
+--TEST--
+defining const with same name as imported should fail
+--FILE--
+<?php
+
+namespace {
+ use const foo\bar;
+
+ const bar = 42;
+}
+
+?>
+--EXPECTF--
+Fatal error: Cannot declare const bar because the name is already in use in %s on line %d
diff --git a/Zend/tests/use_const/define_imported_before.phpt b/Zend/tests/use_const/define_imported_before.phpt
new file mode 100644
index 0000000000..f674ce81e8
--- /dev/null
+++ b/Zend/tests/use_const/define_imported_before.phpt
@@ -0,0 +1,18 @@
+--TEST--
+using const with same name as defined should fail
+--FILE--
+<?php
+
+namespace {
+ const bar = 42;
+
+ use const foo\bar;
+}
+
+namespace {
+ echo "Done";
+}
+
+?>
+--EXPECTF--
+Fatal error: Cannot use const foo\bar as bar because the name is already in use in %s on line %d
diff --git a/Zend/tests/use_const/includes/foo_bar.php b/Zend/tests/use_const/includes/foo_bar.php
new file mode 100644
index 0000000000..90ed451f36
--- /dev/null
+++ b/Zend/tests/use_const/includes/foo_bar.php
@@ -0,0 +1,5 @@
+<?php
+
+namespace foo;
+
+const bar = 'local bar';
diff --git a/Zend/tests/use_const/includes/foo_php_version.php b/Zend/tests/use_const/includes/foo_php_version.php
new file mode 100644
index 0000000000..08f9fd150e
--- /dev/null
+++ b/Zend/tests/use_const/includes/foo_php_version.php
@@ -0,0 +1,5 @@
+<?php
+
+namespace foo;
+
+const PHP_VERSION = 42;
diff --git a/Zend/tests/use_const/includes/global_bar.php b/Zend/tests/use_const/includes/global_bar.php
new file mode 100644
index 0000000000..609d17b7b5
--- /dev/null
+++ b/Zend/tests/use_const/includes/global_bar.php
@@ -0,0 +1,3 @@
+<?php
+
+const bar = 'global bar';
diff --git a/Zend/tests/use_const/includes/global_baz.php b/Zend/tests/use_const/includes/global_baz.php
new file mode 100644
index 0000000000..8b6fba97b3
--- /dev/null
+++ b/Zend/tests/use_const/includes/global_baz.php
@@ -0,0 +1,3 @@
+<?php
+
+const baz = NULL;
diff --git a/Zend/tests/use_const/no_global_fallback.phpt b/Zend/tests/use_const/no_global_fallback.phpt
new file mode 100644
index 0000000000..a128f353ed
--- /dev/null
+++ b/Zend/tests/use_const/no_global_fallback.phpt
@@ -0,0 +1,14 @@
+--TEST--
+non-existent imported constants should not be looked up in the global table
+--FILE--
+<?php
+
+require 'includes/global_baz.php';
+
+use const foo\bar\baz;
+var_dump(baz);
+
+?>
+--EXPECTF--
+Notice: Use of undefined constant baz - assumed 'baz' in %s on line %d
+string(3) "baz"
diff --git a/Zend/tests/use_const/self_parent.phpt b/Zend/tests/use_const/self_parent.phpt
new file mode 100644
index 0000000000..b71f2ecc81
--- /dev/null
+++ b/Zend/tests/use_const/self_parent.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Allow self and parent in use const statement
+--FILE--
+<?php
+
+namespace {
+ use const self as foo;
+ use const parent as bar;
+}
+
+?>
+--EXPECT--
diff --git a/Zend/tests/use_const/shadow_core.phpt b/Zend/tests/use_const/shadow_core.phpt
new file mode 100644
index 0000000000..7d8bcbd189
--- /dev/null
+++ b/Zend/tests/use_const/shadow_core.phpt
@@ -0,0 +1,16 @@
+--TEST--
+shadowing a global core constant with a local version
+--FILE--
+<?php
+
+require 'includes/foo_php_version.php';
+
+use const foo\PHP_VERSION;
+
+var_dump(PHP_VERSION);
+echo "Done\n";
+
+?>
+--EXPECTF--
+int(42)
+Done
diff --git a/Zend/tests/use_const/shadow_global.phpt b/Zend/tests/use_const/shadow_global.phpt
new file mode 100644
index 0000000000..930cc9f0b8
--- /dev/null
+++ b/Zend/tests/use_const/shadow_global.phpt
@@ -0,0 +1,25 @@
+--TEST--
+shadowing a global constant with a local version
+--FILE--
+<?php
+
+namespace {
+ require 'includes/global_bar.php';
+ require 'includes/foo_bar.php';
+}
+
+namespace {
+ var_dump(bar);
+}
+
+namespace {
+ use const foo\bar;
+ var_dump(bar);
+ echo "Done\n";
+}
+
+?>
+--EXPECT--
+string(10) "global bar"
+string(9) "local bar"
+Done
diff --git a/Zend/tests/use_function/alias.phpt b/Zend/tests/use_function/alias.phpt
new file mode 100644
index 0000000000..5f7e97fff8
--- /dev/null
+++ b/Zend/tests/use_function/alias.phpt
@@ -0,0 +1,30 @@
+--TEST--
+aliasing imported functions to resolve naming conflicts
+--FILE--
+<?php
+
+namespace foo {
+ function baz() {
+ return 'foo.baz';
+ }
+}
+
+namespace bar {
+ function baz() {
+ return 'bar.baz';
+ }
+}
+
+namespace {
+ use function foo\baz as foo_baz,
+ bar\baz as bar_baz;
+ var_dump(foo_baz());
+ var_dump(bar_baz());
+ echo "Done\n";
+}
+
+?>
+--EXPECT--
+string(7) "foo.baz"
+string(7) "bar.baz"
+Done
diff --git a/Zend/tests/use_function/basic.phpt b/Zend/tests/use_function/basic.phpt
new file mode 100644
index 0000000000..513a96620c
--- /dev/null
+++ b/Zend/tests/use_function/basic.phpt
@@ -0,0 +1,26 @@
+--TEST--
+import namespaced function
+--FILE--
+<?php
+
+namespace foo\bar {
+ function baz() {
+ return 'foo.bar.baz';
+ }
+ function qux() {
+ return baz();
+ }
+}
+
+namespace {
+ use function foo\bar\baz, foo\bar\qux;
+ var_dump(baz());
+ var_dump(qux());
+ echo "Done\n";
+}
+
+?>
+--EXPECT--
+string(11) "foo.bar.baz"
+string(11) "foo.bar.baz"
+Done
diff --git a/Zend/tests/use_function/case_insensivity.phpt b/Zend/tests/use_function/case_insensivity.phpt
new file mode 100644
index 0000000000..ba6e3a7e4b
--- /dev/null
+++ b/Zend/tests/use_function/case_insensivity.phpt
@@ -0,0 +1,13 @@
+--TEST--
+importing function with same name but different case should fail
+--FILE--
+<?php
+
+namespace {
+ use function foo\bar;
+ use function foo\BAR;
+}
+
+?>
+--EXPECTF--
+Fatal error: Cannot use function foo\BAR as BAR because the name is already in use in %s on line %d
diff --git a/Zend/tests/use_function/conditional_function_declaration.phpt b/Zend/tests/use_function/conditional_function_declaration.phpt
new file mode 100644
index 0000000000..ccfb96103a
--- /dev/null
+++ b/Zend/tests/use_function/conditional_function_declaration.phpt
@@ -0,0 +1,17 @@
+--TEST--
+function that is conditionally defined at runtime should not cause compiler error
+--FILE--
+<?php
+
+if (0) {
+ function foo() {
+ }
+}
+
+use function bar\foo;
+
+echo "Done";
+
+?>
+--EXPECT--
+Done
diff --git a/Zend/tests/use_function/conflicting_use.phpt b/Zend/tests/use_function/conflicting_use.phpt
new file mode 100644
index 0000000000..0221fbdebb
--- /dev/null
+++ b/Zend/tests/use_function/conflicting_use.phpt
@@ -0,0 +1,25 @@
+--TEST--
+use function statements with conflicting names
+--FILE--
+<?php
+
+namespace foo {
+ function baz() {
+ return 'foo.baz';
+ }
+}
+
+namespace bar {
+ function baz() {
+ return 'bar.baz';
+ }
+}
+
+namespace {
+ use function foo\baz, bar\baz;
+ echo "Done\n";
+}
+
+?>
+--EXPECTF--
+Fatal error: Cannot use function bar\baz as baz because the name is already in use in %s on line %d
diff --git a/Zend/tests/use_function/conflicting_use_alias.phpt b/Zend/tests/use_function/conflicting_use_alias.phpt
new file mode 100644
index 0000000000..2870512014
--- /dev/null
+++ b/Zend/tests/use_function/conflicting_use_alias.phpt
@@ -0,0 +1,20 @@
+--TEST--
+use and use function with the same alias
+--FILE--
+<?php
+
+namespace {
+ function foo() {
+ return 'foo';
+ }
+}
+
+namespace x {
+ use foo as bar;
+ use function foo as bar;
+ var_dump(bar());
+}
+
+?>
+--EXPECT--
+string(3) "foo"
diff --git a/Zend/tests/use_function/conflicting_use_const_alias.phpt b/Zend/tests/use_function/conflicting_use_const_alias.phpt
new file mode 100644
index 0000000000..2e0faf0da2
--- /dev/null
+++ b/Zend/tests/use_function/conflicting_use_const_alias.phpt
@@ -0,0 +1,23 @@
+--TEST--
+use const and use function with the same alias
+--FILE--
+<?php
+
+namespace {
+ const foo = 'foo.const';
+ function foo() {
+ return 'foo.function';
+ }
+}
+
+namespace x {
+ use const foo as bar;
+ use function foo as bar;
+ var_dump(bar);
+ var_dump(bar());
+}
+
+?>
+--EXPECT--
+string(9) "foo.const"
+string(12) "foo.function"
diff --git a/Zend/tests/use_function/define_imported.phpt b/Zend/tests/use_function/define_imported.phpt
new file mode 100644
index 0000000000..c542a4d549
--- /dev/null
+++ b/Zend/tests/use_function/define_imported.phpt
@@ -0,0 +1,14 @@
+--TEST--
+defining function with same name as imported should fail
+--FILE--
+<?php
+
+namespace {
+ use function foo\bar;
+
+ function bar() {}
+}
+
+?>
+--EXPECTF--
+Fatal error: Cannot declare function bar because the name is already in use in %s on line %d
diff --git a/Zend/tests/use_function/define_imported_before.phpt b/Zend/tests/use_function/define_imported_before.phpt
new file mode 100644
index 0000000000..91974e0783
--- /dev/null
+++ b/Zend/tests/use_function/define_imported_before.phpt
@@ -0,0 +1,18 @@
+--TEST--
+using function with same name as defined should fail
+--FILE--
+<?php
+
+namespace {
+ function bar() {}
+
+ use function foo\bar;
+}
+
+namespace {
+ echo "Done";
+}
+
+?>
+--EXPECTF--
+Fatal error: Cannot use function foo\bar as bar because the name is already in use in %s on line %d
diff --git a/Zend/tests/use_function/ignore_constants.phpt b/Zend/tests/use_function/ignore_constants.phpt
new file mode 100644
index 0000000000..c50ff7357a
--- /dev/null
+++ b/Zend/tests/use_function/ignore_constants.phpt
@@ -0,0 +1,23 @@
+--TEST--
+use function should ignore namespaced constants
+--FILE--
+<?php
+
+namespace foo {
+ const bar = 42;
+}
+
+namespace {
+ const bar = 43;
+}
+
+namespace {
+ use function foo\bar;
+ var_dump(bar);
+ echo "Done\n";
+}
+
+?>
+--EXPECT--
+int(43)
+Done
diff --git a/Zend/tests/use_function/includes/foo_bar.php b/Zend/tests/use_function/includes/foo_bar.php
new file mode 100644
index 0000000000..6d2f8cab45
--- /dev/null
+++ b/Zend/tests/use_function/includes/foo_bar.php
@@ -0,0 +1,7 @@
+<?php
+
+namespace foo;
+
+function bar() {
+ return 'local bar';
+}
diff --git a/Zend/tests/use_function/includes/foo_strlen.php b/Zend/tests/use_function/includes/foo_strlen.php
new file mode 100644
index 0000000000..d2df2aa2b4
--- /dev/null
+++ b/Zend/tests/use_function/includes/foo_strlen.php
@@ -0,0 +1,7 @@
+<?php
+
+namespace foo;
+
+function strlen($str) {
+ return 4;
+}
diff --git a/Zend/tests/use_function/includes/global_bar.php b/Zend/tests/use_function/includes/global_bar.php
new file mode 100644
index 0000000000..6d7d91f805
--- /dev/null
+++ b/Zend/tests/use_function/includes/global_bar.php
@@ -0,0 +1,5 @@
+<?php
+
+function bar() {
+ return 'global bar';
+}
diff --git a/Zend/tests/use_function/includes/global_baz.php b/Zend/tests/use_function/includes/global_baz.php
new file mode 100644
index 0000000000..6383b9dd38
--- /dev/null
+++ b/Zend/tests/use_function/includes/global_baz.php
@@ -0,0 +1,4 @@
+<?php
+
+function baz() {
+}
diff --git a/Zend/tests/use_function/no_global_fallback.phpt b/Zend/tests/use_function/no_global_fallback.phpt
new file mode 100644
index 0000000000..6597d0d301
--- /dev/null
+++ b/Zend/tests/use_function/no_global_fallback.phpt
@@ -0,0 +1,13 @@
+--TEST--
+non-existent imported functions should not be looked up in the global table
+--FILE--
+<?php
+
+require 'includes/global_baz.php';
+
+use function foo\bar\baz;
+var_dump(baz());
+
+?>
+--EXPECTF--
+Fatal error: Call to undefined function foo\bar\baz() in %s on line %d
diff --git a/Zend/tests/use_function/no_global_fallback2.phpt b/Zend/tests/use_function/no_global_fallback2.phpt
new file mode 100644
index 0000000000..5d012c10e5
--- /dev/null
+++ b/Zend/tests/use_function/no_global_fallback2.phpt
@@ -0,0 +1,18 @@
+--TEST--
+non-existent imported functions should not be looked up in the global table
+--FILE--
+<?php
+
+namespace {
+ function test() {
+ echo "NO!";
+ }
+}
+namespace foo {
+ use function bar\test;
+ test();
+}
+
+?>
+--EXPECTF--
+Fatal error: Call to undefined function bar\test() in %s on line %d
diff --git a/Zend/tests/use_function/self_parent.phpt b/Zend/tests/use_function/self_parent.phpt
new file mode 100644
index 0000000000..f1e1fa84f1
--- /dev/null
+++ b/Zend/tests/use_function/self_parent.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Allow self and parent in use function statement
+--FILE--
+<?php
+
+namespace {
+ use function self as foo;
+ use function parent as bar;
+}
+
+?>
+--EXPECT--
diff --git a/Zend/tests/use_function/shadow_core.phpt b/Zend/tests/use_function/shadow_core.phpt
new file mode 100644
index 0000000000..8f92ff1e1b
--- /dev/null
+++ b/Zend/tests/use_function/shadow_core.phpt
@@ -0,0 +1,16 @@
+--TEST--
+shadowing a global core function with a local version
+--FILE--
+<?php
+
+require 'includes/foo_strlen.php';
+
+use function foo\strlen;
+
+var_dump(strlen('foo bar baz'));
+echo "Done\n";
+
+?>
+--EXPECT--
+int(4)
+Done
diff --git a/Zend/tests/use_function/shadow_global.phpt b/Zend/tests/use_function/shadow_global.phpt
new file mode 100644
index 0000000000..791bcdf4d5
--- /dev/null
+++ b/Zend/tests/use_function/shadow_global.phpt
@@ -0,0 +1,25 @@
+--TEST--
+shadowing a global function with a local version
+--FILE--
+<?php
+
+namespace {
+ require 'includes/global_bar.php';
+ require 'includes/foo_bar.php';
+}
+
+namespace {
+ var_dump(bar());
+}
+
+namespace {
+ use function foo\bar;
+ var_dump(bar());
+ echo "Done\n";
+}
+
+?>
+--EXPECT--
+string(10) "global bar"
+string(9) "local bar"
+Done
diff --git a/Zend/tests/variadic/adding_additional_optional_parameter.phpt b/Zend/tests/variadic/adding_additional_optional_parameter.phpt
new file mode 100644
index 0000000000..b4e797803d
--- /dev/null
+++ b/Zend/tests/variadic/adding_additional_optional_parameter.phpt
@@ -0,0 +1,17 @@
+--TEST--
+It's possible to add additional optional arguments with matching signature
+--FILE--
+<?php
+
+interface DB {
+ public function query($query, string ...$params);
+}
+
+class MySQL implements DB {
+ public function query($query, string $extraParam = null, string ...$params) { }
+}
+
+?>
+===DONE===
+--EXPECT--
+===DONE===
diff --git a/Zend/tests/variadic/adding_additional_optional_parameter_error.phpt b/Zend/tests/variadic/adding_additional_optional_parameter_error.phpt
new file mode 100644
index 0000000000..2f31d47dc6
--- /dev/null
+++ b/Zend/tests/variadic/adding_additional_optional_parameter_error.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Additional optional parameters must have a matching prototype
+--FILE--
+<?php
+
+interface DB {
+ public function query($query, string ...$params);
+}
+
+class MySQL implements DB {
+ public function query($query, int $extraParam = null, string ...$params) { }
+}
+
+?>
+--EXPECTF--
+Fatal error: Declaration of MySQL::query() must be compatible with DB::query($query, string ...$params) in %s on line %d
diff --git a/Zend/tests/variadic/basic.phpt b/Zend/tests/variadic/basic.phpt
new file mode 100644
index 0000000000..810d4756aa
--- /dev/null
+++ b/Zend/tests/variadic/basic.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Basic variadic function
+--FILE--
+<?php
+
+function test1(... $args) {
+ var_dump($args);
+}
+
+test1();
+test1(1);
+test1(1, 2, 3);
+
+function test2($arg1, $arg2, ...$args) {
+ var_dump($arg1, $arg2, $args);
+}
+
+test2(1, 2);
+test2(1, 2, 3);
+test2(1, 2, 3, 4, 5);
+
+?>
+--EXPECT--
+array(0) {
+}
+array(1) {
+ [0]=>
+ int(1)
+}
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}
+int(1)
+int(2)
+array(0) {
+}
+int(1)
+int(2)
+array(1) {
+ [0]=>
+ int(3)
+}
+int(1)
+int(2)
+array(3) {
+ [0]=>
+ int(3)
+ [1]=>
+ int(4)
+ [2]=>
+ int(5)
+}
diff --git a/Zend/tests/variadic/by_ref.phpt b/Zend/tests/variadic/by_ref.phpt
new file mode 100644
index 0000000000..e1635f4ecf
--- /dev/null
+++ b/Zend/tests/variadic/by_ref.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Variadic arguments with by-reference passing
+--FILE--
+<?php
+
+function test(&... $args) {
+ $i = 0;
+ foreach ($args as &$arg) {
+ $arg = $i++;
+ }
+}
+
+test();
+test($a);
+var_dump($a);
+test($b, $c, $d);
+var_dump($b, $c, $d);
+
+?>
+--EXPECT--
+int(0)
+int(0)
+int(1)
+int(2)
diff --git a/Zend/tests/variadic/by_ref_error.phpt b/Zend/tests/variadic/by_ref_error.phpt
new file mode 100644
index 0000000000..7f21014146
--- /dev/null
+++ b/Zend/tests/variadic/by_ref_error.phpt
@@ -0,0 +1,12 @@
+--TEST--
+By-ref variadics enforce the reference
+--FILE--
+<?php
+
+function test(&... $args) { }
+
+test(1);
+
+?>
+--EXPECTF--
+Fatal error: Only variables can be passed by reference in %s on line %d
diff --git a/Zend/tests/variadic/no_default_error.phpt b/Zend/tests/variadic/no_default_error.phpt
new file mode 100644
index 0000000000..427ebed028
--- /dev/null
+++ b/Zend/tests/variadic/no_default_error.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Variadic argument cannot have a default value
+--FILE--
+<?php
+
+function test(...$args = 123) {}
+
+?>
+--EXPECTF--
+Fatal error: Variadic parameter cannot have a default value in %s on line %d
diff --git a/Zend/tests/variadic/non_variadic_implements_variadic_error.phpt b/Zend/tests/variadic/non_variadic_implements_variadic_error.phpt
new file mode 100644
index 0000000000..f447837ca4
--- /dev/null
+++ b/Zend/tests/variadic/non_variadic_implements_variadic_error.phpt
@@ -0,0 +1,16 @@
+--TEST--
+It's not possible to turn a variadic function into a non-variadic one
+--FILE--
+<?php
+
+interface DB {
+ public function query($query, ...$params);
+}
+
+class MySQL implements DB {
+ public function query($query, $params) { }
+}
+
+?>
+--EXPECTF--
+Fatal error: Declaration of MySQL::query() must be compatible with DB::query($query, ...$params) in %s on line %d
diff --git a/Zend/tests/variadic/only_last_error.phpt b/Zend/tests/variadic/only_last_error.phpt
new file mode 100644
index 0000000000..ee6ff3f777
--- /dev/null
+++ b/Zend/tests/variadic/only_last_error.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Only the last argument can be variadic
+--FILE--
+<?php
+
+function test($foo, ...$bar, $baz) {}
+
+?>
+--EXPECTF--
+Fatal error: Only the last parameter can be variadic in %s on line %d
diff --git a/Zend/tests/variadic/optional_params.phpt b/Zend/tests/variadic/optional_params.phpt
new file mode 100644
index 0000000000..ba965e538c
--- /dev/null
+++ b/Zend/tests/variadic/optional_params.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Optional parameter before variadic parameter
+--FILE--
+<?php
+
+function fn($reqParam, $optParam = null, ...$params) {
+ var_dump($reqParam, $optParam, $params);
+}
+
+fn(1);
+fn(1, 2);
+fn(1, 2, 3);
+fn(1, 2, 3, 4);
+fn(1, 2, 3, 4, 5);
+
+?>
+--EXPECT--
+int(1)
+NULL
+array(0) {
+}
+int(1)
+int(2)
+array(0) {
+}
+int(1)
+int(2)
+array(1) {
+ [0]=>
+ int(3)
+}
+int(1)
+int(2)
+array(2) {
+ [0]=>
+ int(3)
+ [1]=>
+ int(4)
+}
+int(1)
+int(2)
+array(3) {
+ [0]=>
+ int(3)
+ [1]=>
+ int(4)
+ [2]=>
+ int(5)
+}
diff --git a/Zend/tests/variadic/removing_parameter_error.phpt b/Zend/tests/variadic/removing_parameter_error.phpt
new file mode 100644
index 0000000000..a189e5cf09
--- /dev/null
+++ b/Zend/tests/variadic/removing_parameter_error.phpt
@@ -0,0 +1,20 @@
+--TEST--
+It's not possible to remove required parameter before a variadic parameter
+--FILE--
+<?php
+
+/* Theoretically this should be valid because it weakens the constraint, but
+ * PHP does not allow this (for non-variadics), so I'm not allowing it here, too,
+ * to stay consistent. */
+
+interface DB {
+ public function query($query, ...$params);
+}
+
+class MySQL implements DB {
+ public function query(...$params) { }
+}
+
+?>
+--EXPECTF--
+Fatal error: Declaration of MySQL::query() must be compatible with DB::query($query, ...$params) in %s on line %d
diff --git a/Zend/tests/variadic/typehint_error.phpt b/Zend/tests/variadic/typehint_error.phpt
new file mode 100644
index 0000000000..3006b99957
--- /dev/null
+++ b/Zend/tests/variadic/typehint_error.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Variadic arguments enforce typehints
+--FILE--
+<?php
+
+function test(array... $args) {
+ var_dump($args);
+}
+
+test();
+test([0], [1], [2]);
+test([0], [1], 2);
+
+?>
+--EXPECTF--
+array(0) {
+}
+array(3) {
+ [0]=>
+ array(1) {
+ [0]=>
+ int(0)
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ int(1)
+ }
+ [2]=>
+ array(1) {
+ [0]=>
+ int(2)
+ }
+}
+
+Catchable fatal error: Argument 3 passed to test() must be of the type array, integer given, called in %s on line %d
diff --git a/Zend/tests/variadic/typehint_suppressed_error.phpt b/Zend/tests/variadic/typehint_suppressed_error.phpt
new file mode 100644
index 0000000000..5048e1c1bb
--- /dev/null
+++ b/Zend/tests/variadic/typehint_suppressed_error.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Error suppression for typehints on variadic arguments works
+--FILE--
+<?php
+
+function test(array... $args) {
+ var_dump($args);
+}
+
+set_error_handler(function($errno, $errstr) {
+ var_dump($errstr);
+ return true;
+});
+
+test([0], [1], 2);
+
+?>
+--EXPECTF--
+string(%d) "Argument 3 passed to test() must be of the type array, integer given, called in %s on line %d and defined"
+array(3) {
+ [0]=>
+ array(1) {
+ [0]=>
+ int(0)
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ int(1)
+ }
+ [2]=>
+ int(2)
+}
diff --git a/Zend/tests/variadic/variadic_changed_byref_error.phpt b/Zend/tests/variadic/variadic_changed_byref_error.phpt
new file mode 100644
index 0000000000..14fb6ae5eb
--- /dev/null
+++ b/Zend/tests/variadic/variadic_changed_byref_error.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Variadic arguments must have compatible passing modes
+--FILE--
+<?php
+
+interface DB {
+ public function query($query, &...$params);
+}
+
+class MySQL implements DB {
+ public function query($query, ...$params) { }
+}
+
+?>
+--EXPECTF--
+Fatal error: Declaration of MySQL::query() must be compatible with DB::query($query, &...$params) in %s on line %d
diff --git a/Zend/tests/variadic/variadic_changed_typehint_error.phpt b/Zend/tests/variadic/variadic_changed_typehint_error.phpt
new file mode 100644
index 0000000000..00df33a042
--- /dev/null
+++ b/Zend/tests/variadic/variadic_changed_typehint_error.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Typehints for variadic arguments have to be compatible
+--FILE--
+<?php
+
+interface DB {
+ public function query($query, string ...$params);
+}
+
+class MySQL implements DB {
+ public function query($query, int ...$params) { }
+}
+
+?>
+--EXPECTF--
+Fatal error: Declaration of MySQL::query() must be compatible with DB::query($query, string ...$params) in %s on line %d
diff --git a/Zend/tests/variadic/variadic_implements_non_variadic.phpt b/Zend/tests/variadic/variadic_implements_non_variadic.phpt
new file mode 100644
index 0000000000..a66ec280b8
--- /dev/null
+++ b/Zend/tests/variadic/variadic_implements_non_variadic.phpt
@@ -0,0 +1,17 @@
+--TEST--
+A non-variadic function can be turned into a variadic one
+--FILE--
+<?php
+
+interface DB {
+ public function query($query);
+}
+
+class MySQL implements DB {
+ public function query($query, ...$params) { }
+}
+
+?>
+===DONE===
+--EXPECT--
+===DONE===
diff --git a/Zend/tests/zend_signed_multiply-32bit.phpt b/Zend/tests/zend_signed_multiply-32bit.phpt
new file mode 100644
index 0000000000..3f37cbac19
--- /dev/null
+++ b/Zend/tests/zend_signed_multiply-32bit.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Zend signed multiply 32-bit
+--SKIPIF--
+<?php if ((1 << 31) > 0) print "skip Running on 64-bit target"; ?>
+--FILE--
+<?php
+var_dump(0x8000 * -0xffff);
+var_dump(0x8001 * 0xfffe);
+var_dump(0x8001 * -0xffff);
+?>
+--EXPECTF--
+int(-2147450880)
+int(2147483646)
+float(-2147516415)
diff --git a/Zend/tests/zend_signed_multiply-64bit.phpt b/Zend/tests/zend_signed_multiply-64bit.phpt
new file mode 100644
index 0000000000..94a6e035fa
--- /dev/null
+++ b/Zend/tests/zend_signed_multiply-64bit.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Zend signed multiply 64-bit
+--SKIPIF--
+<?php if ((1 << 31) < 0) print "skip Running on 32-bit target"; ?>
+--FILE--
+<?php
+var_dump(0x80000000 * -0xffffffff);
+var_dump(0x80000001 * 0xfffffffe);
+var_dump(0x80000001 * -0xffffffff);
+?>
+--EXPECTF--
+int(-9223372034707292160)
+int(9223372036854775806)
+float(-9.2233720390023E+18)