diff options
Diffstat (limited to 'Zend/tests')
24 files changed, 368 insertions, 110 deletions
diff --git a/Zend/tests/arg_unpack/basic.phpt b/Zend/tests/arg_unpack/basic.phpt index 9c0365586a..f8bd019378 100644 --- a/Zend/tests/arg_unpack/basic.phpt +++ b/Zend/tests/arg_unpack/basic.phpt @@ -30,12 +30,12 @@ test(...getArray([1, 2, 3])); test(...arrayGen([])); test(...arrayGen([1, 2, 3])); -test(1, ...[2, 3], ...[4, 5], 6); -test(1, ...getArray([2, 3]), ...arrayGen([4, 5]), 6); +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, 6]); +test2(...[1], ...[], ...[], ...[2, 3], ...[4, 5]); ?> --EXPECT-- @@ -75,7 +75,7 @@ array(3) { [2]=> int(3) } -array(6) { +array(5) { [0]=> int(1) [1]=> @@ -86,10 +86,8 @@ array(6) { int(4) [4]=> int(5) - [5]=> - int(6) } -array(6) { +array(5) { [0]=> int(1) [1]=> @@ -100,8 +98,6 @@ array(6) { int(4) [4]=> int(5) - [5]=> - int(6) } int(1) int(2) diff --git a/Zend/tests/arg_unpack/by_ref.phpt b/Zend/tests/arg_unpack/by_ref.phpt index 0619a3bab8..7c8a86be48 100644 --- a/Zend/tests/arg_unpack/by_ref.phpt +++ b/Zend/tests/arg_unpack/by_ref.phpt @@ -17,46 +17,37 @@ $array = [1, 2, 3]; test1(...$array); var_dump($array); -$array1 = [1, 2]; $val2 = 3; $array2 = [4, 5]; -test1(...$array1, $val2, ...$array2); -var_dump($array1, $val2, $array2); +$array1 = [1, 2]; $array2 = [3, 4]; +test1(...$array1, ...$array2); +var_dump($array1, $array2); function test2($val1, &$ref1, $val2, &$ref2) { $ref1++; $ref2++; } -$array = [1, 2, 3, 4]; +$array = [0, 0, 0, 0]; test2(...$array); var_dump($array); -$a = $b = $c = $d = 0; +$array1 = [1, 2]; $array2 = [4, 5]; +test1(...$array1, ...$array2); +var_dump($array1, $array2); -$array = []; -test2(...$array, $a, $b, $c, $d); -var_dump($array, $a, $b, $c, $d); +$a = $b = $c = $d = 0; +$array = [0, 0, 0, 0]; -$array = [1]; -test2(...$array, $a, $b, $c, $d); -var_dump($array, $a, $b, $c, $d); +test2($a, ...$array); +var_dump($a, $array); -$array = [1, 2]; -test2(...$array, $a, $b, $c, $d); -var_dump($array, $a, $b, $c, $d); +test2($a, $b, ...$array); +var_dump($a, $b, $array); -$array = [1, 2, 3]; -test2(...$array, $a, $b, $c, $d); -var_dump($array, $a, $b, $c, $d); +test2($a, $b, $c, ...$array); +var_dump($a, $b, $c, $array); -$vars = []; -$array = []; -test2(...$array, $vars['a'], $vars['b'], $vars['c'], $vars['d']); -var_dump($vars); - -$vars = []; -$array = [1]; -test2(...$array, $vars['a'], $vars['b'], $vars['c'], $vars['d']); -var_dump($vars); +test2($a, $b, $c, $d, ...$array); +var_dump($a, $b, $c, $d, $array); ?> --EXPECTF-- @@ -74,76 +65,81 @@ array(2) { [1]=> int(3) } -int(4) array(2) { [0]=> - int(5) + int(4) [1]=> - int(6) + int(5) } array(4) { [0]=> - int(1) + int(0) [1]=> - int(3) + int(1) [2]=> - int(3) + int(0) [3]=> - int(5) -} -array(0) { + int(1) } -int(0) -int(1) -int(0) -int(1) -array(1) { +array(2) { [0]=> - int(1) + int(2) + [1]=> + int(3) } -int(1) -int(1) -int(1) -int(1) array(2) { [0]=> + int(5) + [1]=> + int(6) +} +int(0) +array(4) { + [0]=> int(1) [1]=> - int(3) + int(0) + [2]=> + int(1) + [3]=> + int(0) } +int(0) int(1) -int(2) -int(1) -int(1) -array(3) { +array(4) { [0]=> int(1) [1]=> - int(3) + int(1) [2]=> - int(3) + int(1) + [3]=> + int(0) } +int(0) int(2) -int(2) -int(1) -int(1) - -Notice: Undefined index: a in %s on line %d - -Notice: Undefined index: c in %s on line %d -array(2) { - ["b"]=> +int(0) +array(4) { + [0]=> + int(2) + [1]=> int(1) - ["d"]=> + [2]=> int(1) + [3]=> + int(0) } - -Notice: Undefined index: b in %s on line %d - -Notice: Undefined index: d in %s on line %d -array(2) { - ["a"]=> +int(0) +int(3) +int(0) +int(1) +array(4) { + [0]=> + int(2) + [1]=> int(1) - ["c"]=> + [2]=> int(1) + [3]=> + int(0) } diff --git a/Zend/tests/arg_unpack/dynamic.phpt b/Zend/tests/arg_unpack/dynamic.phpt index efed84da78..8f129f85a6 100644 --- a/Zend/tests/arg_unpack/dynamic.phpt +++ b/Zend/tests/arg_unpack/dynamic.phpt @@ -9,7 +9,7 @@ $fn = function(...$args) { $fn(...[]); $fn(...[1, 2, 3]); -$fn(1, ...[2, 3], ...[], 4, 5); +$fn(1, ...[2, 3], ...[], ...[4, 5]); ?> --EXPECT-- diff --git a/Zend/tests/arg_unpack/invalid_type.phpt b/Zend/tests/arg_unpack/invalid_type.phpt index 3efffebc76..1ef545558c 100644 --- a/Zend/tests/arg_unpack/invalid_type.phpt +++ b/Zend/tests/arg_unpack/invalid_type.phpt @@ -12,7 +12,7 @@ test(...42); test(...new stdClass); test(1, 2, 3, ..."foo", ...[4, 5]); -test(1, 2, ...new StdClass, 3, ...3.14, ...[4, 5]); +test(1, 2, 3, ...new StdClass, ...3.14, ...[4, 5]); ?> --EXPECTF-- diff --git a/Zend/tests/arg_unpack/method.phpt b/Zend/tests/arg_unpack/method.phpt index d6a6e4712b..fb9ace8378 100644 --- a/Zend/tests/arg_unpack/method.phpt +++ b/Zend/tests/arg_unpack/method.phpt @@ -14,8 +14,7 @@ class Foo { } $foo = new Foo; -$foo->test(...[1, 2], 3, 4, ...[], 5); -Foo::test2(1, 2, ...[3, 4], ...[], 5); +Foo::test2(1, 2, ...[3, 4], ...[], ...[5]); ?> --EXPECT-- @@ -31,15 +30,3 @@ array(5) { [4]=> int(5) } -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 index 3cf224f288..7a0968e2c9 100644 --- a/Zend/tests/arg_unpack/new.phpt +++ b/Zend/tests/arg_unpack/new.phpt @@ -11,7 +11,7 @@ class Foo { new Foo(...[]); new Foo(...[1, 2, 3]); -new Foo(...[1], 2, ...[], ...[3, 4], 5); +new Foo(...[1], ...[], ...[2, 3]); ?> --EXPECT-- @@ -25,15 +25,11 @@ array(3) { [2]=> int(3) } -array(5) { +array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) - [3]=> - int(4) - [4]=> - int(5) } 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/traversable_throwing_exception.phpt b/Zend/tests/arg_unpack/traversable_throwing_exception.phpt index 8ddc24dc74..abbf537587 100644 --- a/Zend/tests/arg_unpack/traversable_throwing_exception.phpt +++ b/Zend/tests/arg_unpack/traversable_throwing_exception.phpt @@ -20,11 +20,11 @@ function gen() { } try { - test(1, 2, ...new Foo, 3, 4); + test(1, 2, ...new Foo, ...[3, 4]); } catch (Exception $e) { var_dump($e->getMessage()); } try { - test(1, 2, ...gen(), 3, 4); + test(1, 2, ...gen(), ...[3, 4]); } catch (Exception $e) { var_dump($e->getMessage()); } ?> diff --git a/Zend/tests/arg_unpack/traversable_with_by_ref_parameters.phpt b/Zend/tests/arg_unpack/traversable_with_by_ref_parameters.phpt index e862341652..711287eded 100644 --- a/Zend/tests/arg_unpack/traversable_with_by_ref_parameters.phpt +++ b/Zend/tests/arg_unpack/traversable_with_by_ref_parameters.phpt @@ -13,8 +13,6 @@ function gen($array) { } } -test(...gen([1, 2, 3]), $a); -var_dump($a); test(1, 2, 3, $b, ...gen([4, 5, 6])); var_dump($b); @@ -25,7 +23,6 @@ test(...gen([1, 2]), ...gen([3, 4])); ?> --EXPECTF-- int(42) -int(42) 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/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/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/constant_expressions.phpt b/Zend/tests/constant_expressions.phpt index 7dea0d83f7..cf6474bd63 100644 --- a/Zend/tests/constant_expressions.phpt +++ b/Zend/tests/constant_expressions.phpt @@ -35,6 +35,9 @@ 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); @@ -61,6 +64,7 @@ var_dump(T_23); var_dump(T_24); var_dump(T_25); var_dump(T_26); +var_dump(T_27); ?> --EXPECT-- int(2) @@ -89,3 +93,4 @@ bool(false) bool(true) int(7) int(6) +int(8) 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/generators/errors/serialize_unserialize_error.phpt b/Zend/tests/generators/errors/serialize_unserialize_error.phpt index aa2d4693f7..b5e77e5028 100644 --- a/Zend/tests/generators/errors/serialize_unserialize_error.phpt +++ b/Zend/tests/generators/errors/serialize_unserialize_error.phpt @@ -32,12 +32,11 @@ Stack trace: #0 %s(%d): serialize(Object(Generator)) #1 {main} -exception 'Exception' with message 'Unserialization of 'Generator' is not allowed' in %s:%d -Stack trace: -#0 [internal function]: Generator->__wakeup() -#1 %s(%d): unserialize('O:9:"Generator"...') -#2 {main} +Warning: Erroneous data format for unserializing 'Generator' in %sserialize_unserialize_error.php on line %d + +Notice: unserialize(): Error at offset 19 of 20 bytes in %sserialize_unserialize_error.php on line %s +bool(false) exception 'Exception' with message 'Unserialization of 'Generator' is not allowed' in %s:%d Stack trace: #0 %s(%d): unserialize('C:9:"Generator"...') |