diff options
| author | Jakub Zelenka <bukka@php.net> | 2016-06-12 18:56:55 +0100 |
|---|---|---|
| committer | Jakub Zelenka <bukka@php.net> | 2016-06-12 18:56:55 +0100 |
| commit | b44cf1a8540d321583a0d83ebca688ebab10d3b0 (patch) | |
| tree | b7fbafb4113ea150381a9bba7f98f45027e35b0b /Zend/tests | |
| parent | 6ac8bc4ecb1fdf112eefdd16d2c4f971e7ac232a (diff) | |
| parent | a2f4c32eb14221de79009aadaa3da9c3349e3526 (diff) | |
| download | php-git-b44cf1a8540d321583a0d83ebca688ebab10d3b0.tar.gz | |
Merge branch 'PHP-7.0' into openssl_error_store
Diffstat (limited to 'Zend/tests')
53 files changed, 1109 insertions, 21 deletions
diff --git a/Zend/tests/ArrayAccess_indirect_append.phpt b/Zend/tests/ArrayAccess_indirect_append.phpt new file mode 100644 index 0000000000..6f3da7c46c --- /dev/null +++ b/Zend/tests/ArrayAccess_indirect_append.phpt @@ -0,0 +1,43 @@ +--TEST-- +Using indirect append on ArrayAccess object +--FILE-- +<?php + +class AA implements ArrayAccess { + private $data = []; + public function &offsetGet($name) { + if (null === $name) { + return $this->data[]; + } else { + return $this->data[$name]; + } + } + public function offsetSet($name, $value) { + $this->data[$name] = $value; + } + public function offsetUnset($name) {} + public function offsetExists($name) {} +} + +$aa = new AA; +$aa[3] = 1; +$aa[][][0] = 2; +var_dump($aa); + +?> +--EXPECT-- +object(AA)#1 (1) { + ["data":"AA":private]=> + array(2) { + [3]=> + int(1) + [4]=> + array(1) { + [0]=> + array(1) { + [0]=> + int(2) + } + } + } +} diff --git a/Zend/tests/arg_unpack/by_ref_separation.phpt b/Zend/tests/arg_unpack/by_ref_separation.phpt new file mode 100644 index 0000000000..b52c28168a --- /dev/null +++ b/Zend/tests/arg_unpack/by_ref_separation.phpt @@ -0,0 +1,36 @@ +--TEST-- +Array must be separated if unpacking by reference +--FILE-- +<?php + +function inc(&... $args) { + foreach ($args as &$arg) { + $arg++; + } +} + +$arr = [1, 2]; +$arr[] = 3; +$arr2 = $arr; +inc(...$arr); +var_dump($arr); +var_dump($arr2); + +?> +--EXPECT-- +array(3) { + [0]=> + int(2) + [1]=> + int(3) + [2]=> + int(4) +} +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} diff --git a/Zend/tests/ast_serialize_backtick_literal.phpt b/Zend/tests/ast_serialize_backtick_literal.phpt new file mode 100644 index 0000000000..4dd65963c5 --- /dev/null +++ b/Zend/tests/ast_serialize_backtick_literal.phpt @@ -0,0 +1,11 @@ +--TEST-- +Serialization of backtick literal is incorrect +--INI-- +zend.assertions=1 +--FILE-- +<?php + +assert_options(ASSERT_WARNING); +assert(false && `echo -n ""`); +--EXPECTF-- +Warning: assert(): assert(false && `echo -n ""`) failed in %s%east_serialize_backtick_literal.php on line %d diff --git a/Zend/tests/bug34617.phpt b/Zend/tests/bug34617.phpt index 25f785f909..ded1aec2fd 100644 --- a/Zend/tests/bug34617.phpt +++ b/Zend/tests/bug34617.phpt @@ -8,7 +8,8 @@ class Thing {} function boom() { $reader = xml_parser_create(); - xml_set_object($reader, new Thing()); + $thing = new Thing(); + xml_set_object($reader, $thing); die("ok\n"); xml_parser_free($reader); } diff --git a/Zend/tests/bug41117_1.phpt b/Zend/tests/bug41117_1.phpt index f555b637ad..a612f07fed 100644 --- a/Zend/tests/bug41117_1.phpt +++ b/Zend/tests/bug41117_1.phpt @@ -10,5 +10,4 @@ class foo { $obj = new foo("Hello world"); ?> --EXPECTF-- -Fatal error: Cannot re-assign $this in %sbug41117_1.php on line 3 - +Fatal error: Cannot use $this as parameter in %s on line %d diff --git a/Zend/tests/bug62358.phpt b/Zend/tests/bug62358.phpt index 44480fc5ef..35bbc33835 100644 --- a/Zend/tests/bug62358.phpt +++ b/Zend/tests/bug62358.phpt @@ -23,4 +23,4 @@ class B extends A { } ?> --EXPECTF-- -Warning: Declaration of B::foo($var) should be compatible with A::foo() in %sbug62358.php on line %d +Fatal error: Declaration of B::foo($var) must be compatible with I::foo() in %sbug62358.php on line 17 diff --git a/Zend/tests/bug69467.phpt b/Zend/tests/bug69467.phpt index 22283003df..11ff72df18 100644 --- a/Zend/tests/bug69467.phpt +++ b/Zend/tests/bug69467.phpt @@ -18,4 +18,4 @@ $test = new Foo(); var_dump($test instanceof Baz); ?> --EXPECTF-- -Fatal error: Access level to Bar::bad() must be public (as in class Baz) in %sbug69467.php on line %d +Fatal error: Access level to Foo::bad() must be public (as in class Baz) in %sbug69467.php on line %d diff --git a/Zend/tests/bug69537.phpt b/Zend/tests/bug69537.phpt new file mode 100644 index 0000000000..3151c35081 --- /dev/null +++ b/Zend/tests/bug69537.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #69537 (__debugInfo with empty string for key gives error) +--FILE-- +<?php +class Foo { + + public function __debugInfo(){ + return ['' => 1]; + } +} + +var_dump(new Foo); +?> +--EXPECTF-- +object(Foo)#%d (%d) { + [""]=> + int(1) +} + diff --git a/Zend/tests/bug69955.phpt b/Zend/tests/bug69955.phpt index b6d74242ee..33c36850c0 100644 --- a/Zend/tests/bug69955.phpt +++ b/Zend/tests/bug69955.phpt @@ -27,8 +27,6 @@ $c10 = new C10; var_dump($c10[] += 5); --EXPECTF-- Inside C10::offsetGet - -Notice: Undefined variable: offset in %sbug69955.php on line 10 NULL Inside C10::offsetSet diff --git a/Zend/tests/bug71359.phpt b/Zend/tests/bug71359.phpt new file mode 100644 index 0000000000..b239549ee2 --- /dev/null +++ b/Zend/tests/bug71359.phpt @@ -0,0 +1,61 @@ +--TEST-- +Bug #71359: Null coalescing operator and magic +--FILE-- +<?php +class AA { + private $data = []; + public function __isset($name) { + echo "__isset($name)\n"; + return array_key_exists($name, $this->data); + } + public function &__get($name) { + echo "__get($name)\n"; + if (!array_key_exists($name, $this->data)) { + throw new Exception('Unknown offset'); + } + return $this->data[$name]; + } + public function __set($name, $value) { + echo "__set($name)\n"; + $this->data[$name] = $value; + } + public function __unset($name) { + echo "__unset($name)\n"; + unset($this->data[$name]); + } +} + +$aa = new AA; +var_dump(isset($aa->zero->one->two)); +var_dump(isset($aa->zero->foo)); +var_dump($aa->zero ?? 42); +var_dump($aa->zero->one->two ?? 42); +$aa->zero = new AA; +$aa->zero->one = new AA; +var_dump(isset($aa->zero->one->two)); +var_dump($aa->zero->one->two ?? 42); +?> +--EXPECT-- +__isset(zero) +bool(false) +__isset(zero) +bool(false) +__isset(zero) +int(42) +__isset(zero) +int(42) +__set(zero) +__get(zero) +__set(one) +__isset(zero) +__get(zero) +__isset(one) +__get(one) +__isset(two) +bool(false) +__isset(zero) +__get(zero) +__isset(one) +__get(one) +__isset(two) +int(42) diff --git a/Zend/tests/bug71414.phpt b/Zend/tests/bug71414.phpt new file mode 100644 index 0000000000..09f8b7dd32 --- /dev/null +++ b/Zend/tests/bug71414.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #71414 (Interface method override inherited method and implemented in a trait causes fatal error) +--FILE-- +<?php +interface InterfaceY { + public function z(): string; +} + +trait TraitY { + public function z(): string { + } +} + +class X { + public function z() { + } +} + +class Y extends X implements InterfaceY { + use TraitY; +} + +echo "ok"; +--EXPECT-- +ok diff --git a/Zend/tests/bug71428.1.phpt b/Zend/tests/bug71428.1.phpt new file mode 100644 index 0000000000..fbf342380f --- /dev/null +++ b/Zend/tests/bug71428.1.phpt @@ -0,0 +1,15 @@ +--TEST-- +bug #71428.1: inheritance with null default values +--XFAIL-- +This is a BC break +--FILE-- +<?php +class A { + public function m(array $a = null) {} +} +class B extends A { + public function m(array $a = []) {} +} +--EXPECTF-- +Warning: Declaration of B::m(array $a = Array) should be compatible with A::m(array $a = NULL) in %sbug71428.1.php on line 7 + diff --git a/Zend/tests/bug71428.2.phpt b/Zend/tests/bug71428.2.phpt new file mode 100644 index 0000000000..9a98ba7760 --- /dev/null +++ b/Zend/tests/bug71428.2.phpt @@ -0,0 +1,23 @@ +--TEST-- +bug #71428.2: inheritance of ye olde dynamic interfaces +--SKIPIF-- +<?php if (!extension_loaded('pdo')) die("skip PDO is not available"); ?> +--FILE-- +<?php +interface StatementInterface { + public function fetch($first = null, $second, $third); +} + +class Statement extends PDOStatement implements StatementInterface {} + +interface StatementInterface1 { + public function fetch($first = null, $second = null, $third = null); +} + +class Statement1 extends PDOStatement implements StatementInterface1 {} + +echo "ok"; +?> +--EXPECT-- +ok + diff --git a/Zend/tests/bug71428.3.phpt b/Zend/tests/bug71428.3.phpt new file mode 100644 index 0000000000..65d397052e --- /dev/null +++ b/Zend/tests/bug71428.3.phpt @@ -0,0 +1,13 @@ +--TEST-- +bug #71428: Validation type inheritance with = NULL +--XFAIL-- +This is a BC break +--FILE-- +<?php +class A { } +class B { public function m(A $a = NULL, $n) { echo "B.m";} }; +class C extends B { public function m(A $a , $n) { echo "C.m";} }; +?> +--EXPECTF-- +Warning: Declaration of C::m(A $a, $n) should be compatible with B::m(A $a = NULL, $n) in %sbug71428.3.php on line 4 + diff --git a/Zend/tests/bug71695.phpt b/Zend/tests/bug71695.phpt new file mode 100644 index 0000000000..6747ce0e14 --- /dev/null +++ b/Zend/tests/bug71695.phpt @@ -0,0 +1,17 @@ +--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/bug71724.phpt b/Zend/tests/bug71724.phpt new file mode 100644 index 0000000000..2f5e4ba9da --- /dev/null +++ b/Zend/tests/bug71724.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #71724: yield from does not count EOLs +--FILE-- +<?php + +function test() +{ + yield + + + + + from [__LINE__]; +} +var_dump(test()->current()); + +?> +--EXPECT-- +int(10) diff --git a/Zend/tests/bug71731.phpt b/Zend/tests/bug71731.phpt new file mode 100644 index 0000000000..46a79f1a34 --- /dev/null +++ b/Zend/tests/bug71731.phpt @@ -0,0 +1,64 @@ +--TEST-- +Bug #71731: Null coalescing operator and ArrayAccess +--FILE-- +<?php + +class AA implements ArrayAccess { + private $data = []; + public function offsetExists($name) { + echo "offsetExists($name)\n"; + return array_key_exists($name, $this->data); + } + public function &offsetGet($name) { + echo "offsetGet($name)\n"; + if (!array_key_exists($name, $this->data)) { + throw new Exception('Unknown offset'); + } + return $this->data[$name]; + } + public function offsetSet($name, $value) { + echo "offsetSet($name)\n"; + $this->data[$name] = $value; + } + public function offsetUnset($name) { + echo "offsetUnset($name)\n"; + unset($this->data[$name]); + } +} + +$aa = new AA; +var_dump(isset($aa[0][1][2])); +var_dump(isset($aa[0]->foo)); +var_dump($aa[0] ?? 42); +var_dump($aa[0][1][2] ?? 42); + +$aa[0] = new AA; +$aa[0][1] = new AA; +var_dump(isset($aa[0][1][2])); +var_dump($aa[0][1][2] ?? 42); + +?> +--EXPECT-- +offsetExists(0) +bool(false) +offsetExists(0) +bool(false) +offsetExists(0) +int(42) +offsetExists(0) +int(42) +offsetSet(0) +offsetGet(0) +offsetSet(1) +offsetExists(0) +offsetGet(0) +offsetExists(1) +offsetGet(1) +offsetExists(2) +bool(false) +offsetExists(0) +offsetGet(0) +offsetExists(1) +offsetGet(1) +offsetExists(2) +int(42) diff --git a/Zend/tests/bug71737.phpt b/Zend/tests/bug71737.phpt new file mode 100644 index 0000000000..b44de8e78e --- /dev/null +++ b/Zend/tests/bug71737.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #71737: Memory leak in closure with parameter named $this +--FILE-- +<?php + +class Test { + public function method() { + return function($this) {}; + } +} + +(new Test)->method()(new stdClass); + +?> +--EXPECTF-- +Fatal error: Cannot use $this as parameter in %s on line %d diff --git a/Zend/tests/bug71756.phpt b/Zend/tests/bug71756.phpt new file mode 100644 index 0000000000..42066f3c2e --- /dev/null +++ b/Zend/tests/bug71756.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #71756 (Call-by-reference widens scope to uninvolved functions when used in switch) +--FILE-- +<?php +function a ($option) { + b($option['bla']); + c($option); + var_dump($option); +} +function b (&$string) { + $string = 'changed'; +} +function c ($option) { + switch ($option['bla']) { + case 'changed': + $copy = $option; + $copy['bla'] = 'copy'; + break; + } +} +a(array('bla' => 'false')); +?> +--EXPECTF-- +array(1) { + ["bla"]=> + string(7) "changed" +} diff --git a/Zend/tests/bug71841.phpt b/Zend/tests/bug71841.phpt new file mode 100644 index 0000000000..f66761b3c9 --- /dev/null +++ b/Zend/tests/bug71841.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #71841 (EG(error_zval) is not handled well) +--INI-- +error_reporting=0 +--FILE-- +<?php +$z = unserialize('O:1:"A":0:{}'); +var_dump($z->e.=0); +var_dump(++$z->x); +var_dump($z->y++); + +$y = array(PHP_INT_MAX => 0); +var_dump($y[] .= 0); +var_dump(++$y[]); +var_dump($y[]++); +?> +--EXPECT-- +NULL +NULL +NULL +NULL +NULL +NULL diff --git a/Zend/tests/bug71859.phpt b/Zend/tests/bug71859.phpt new file mode 100644 index 0000000000..5b62209a1b --- /dev/null +++ b/Zend/tests/bug71859.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #71859 (zend_objects_store_call_destructors operates on realloced memory, crashing) +--FILE-- +<?php +class constructs_in_destructor { + public function __destruct() { + //We are now in zend_objects_store_call_destructors + //This causes a realloc in zend_objects_store_put + for ($i = 0; $i < 10000; ++$i) { + $GLOBALS["a$i"] = new stdClass; + } + //Returns to zend_objects_store_call_destructors, to access freed memory. + } +} + +$a = new constructs_in_destructor; +//Create cycle so destructors are ran only in zend_objects_store_call_destructors +$a->a = $a; + +// Create some objects so zend_objects_store_call_destructors has something +// to do after constructs_in_destructor is destroyed. +for ($i = 0; $i < 200; ++$i) { + $GLOBALS["b$i"] = new stdClass; +} +?> +okey +--EXPECT-- +okey diff --git a/Zend/tests/bug71871.phpt b/Zend/tests/bug71871.phpt new file mode 100644 index 0000000000..1781ff07aa --- /dev/null +++ b/Zend/tests/bug71871.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #71871: Interfaces allow final and abstract functions +--FILE-- +<?php + +interface test { + final function test(); +} + +?> +--EXPECTF-- +Fatal error: Access type for interface method test::test() must be omitted in %s on line %d diff --git a/Zend/tests/bug71871_2.phpt b/Zend/tests/bug71871_2.phpt new file mode 100644 index 0000000000..6a9404ea37 --- /dev/null +++ b/Zend/tests/bug71871_2.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #71871: Interfaces allow final and abstract functions +--FILE-- +<?php + +interface test { + abstract function test(); +} + +?> +--EXPECTF-- +Fatal error: Access type for interface method test::test() must be omitted in %s on line %d diff --git a/Zend/tests/bug71914.phpt b/Zend/tests/bug71914.phpt new file mode 100644 index 0000000000..a43eb56bbd --- /dev/null +++ b/Zend/tests/bug71914.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug #71914 (Reference is lost in "switch") +--FILE-- +<?php + +function bug(&$value) { + switch ($value) { + case "xxxx": + $value = true; + break; + } +} + +function returnArray() { + $array = array(); + $array["str"] = "xxxx"; + return $array; +} + +class Foo { + public $array = array("str" => "xxxx"); +} + +function test($arr, &$dummy) { + bug($arr["str"]); + var_dump($arr["str"]); +} + +$foo = new Foo(); +$arr = returnArray(); + +$array = array("str" => "xxxx"); +test($array, $array["str"]); +test($arr, $arr["str"]); +test($foo->array, $foo->array["str"]); +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) diff --git a/Zend/tests/bug71922.phpt b/Zend/tests/bug71922.phpt new file mode 100644 index 0000000000..986254cab7 --- /dev/null +++ b/Zend/tests/bug71922.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #71922: Crash on assert(new class{}); +--INI-- +zend.assertions=1 +assert.exception=1 +--FILE-- +<?php + +try { + assert(0 && new class { + } && new class(42) extends stdclass { + }); +} catch (AssertionError $e) { + echo "Assertion failure: ", $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +Assertion failure: assert(0 && new class { +} && new class(42) extends stdclass { +}) diff --git a/Zend/tests/bug71930.phpt b/Zend/tests/bug71930.phpt new file mode 100644 index 0000000000..4604b88493 --- /dev/null +++ b/Zend/tests/bug71930.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #71930 (_zval_dtor_func: Assertion `(arr)->gc.refcount <= 1' failed) +--SKIPIF-- +<?php +if (!extension_loaded("curl")) { + die("skip Require a resource which is able to hold a callbck"); +} +?> +--FILE-- +<?php + +class A { + public static function dummy() { + } +} + +$a = array(); +$a[] = "A"; +$a[] = "dummy"; + +$ch1 = curl_init(); +curl_setopt($ch1, CURLOPT_HEADERFUNCTION, $a); + +set_error_handler($a); +set_error_handler(function()use($ch1){}); +set_error_handler(function(){}); +?> +okey +--EXPECT-- +okey diff --git a/Zend/tests/bug71980.phpt b/Zend/tests/bug71980.phpt new file mode 100644 index 0000000000..cd98f6567d --- /dev/null +++ b/Zend/tests/bug71980.phpt @@ -0,0 +1,43 @@ +--TEST-- +Bug #71980: Decorated/Nested Generator is Uncloseable in Finally +--FILE-- +<?php + +class Dtor { + public function __destruct() { + echo "Dtor\n"; + } +} + +function gen1() { + try { + foreach ([42, new Dtor] as $value) { + yield $value; + } + } finally { + echo "Finally\n"; + } +} + +function gen2() { + try { + var_dump(new Dtor, yield); + } finally { + echo "Finally\n"; + } +} + +$gen = gen1(); +$gen->rewind(); +unset($gen); + +$gen = gen2(); +$gen->rewind(); +unset($gen); + +?> +--EXPECT-- +Dtor +Finally +Dtor +Finally diff --git a/Zend/tests/bug72038.phpt b/Zend/tests/bug72038.phpt new file mode 100644 index 0000000000..1e32af4c18 --- /dev/null +++ b/Zend/tests/bug72038.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #72038 (Function calls with values to a by-ref parameter don't always throw a notice) +--FILE-- +<?php + +test($foo = new stdClass); +var_dump($foo); +test($bar = 2); +var_dump($bar); +test($baz = &$bar); +var_dump($baz); + +function test(&$param) { + $param = 1; +} + +?> +--EXPECTF-- + +Notice: Only variables should be passed by reference in %s on line %d +object(stdClass)#1 (0) { +} + +Notice: Only variables should be passed by reference in %s on line %d +int(2) +int(1) + diff --git a/Zend/tests/bug72057.phpt b/Zend/tests/bug72057.phpt new file mode 100644 index 0000000000..e1a129bbc2 --- /dev/null +++ b/Zend/tests/bug72057.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #72057 (PHP hangs when user error handler throws exception after Notice from type coercion) +--FILE-- +<?php + +set_error_handler( + function() { + throw new Exception("My custom error"); + } +); + +(function (int $i) { bar(); })("7as"); + +--EXPECTF-- + +Fatal error: Uncaught Exception: My custom error in %s:%d +Stack trace: +#0 %s(%d): {closure}(8, 'A non well form...', '%s', %d, Array) +#1 %s(%d): {closure}('7as') +#2 {main} + thrown in %s on line %d diff --git a/Zend/tests/bug72101.phpt b/Zend/tests/bug72101.phpt new file mode 100644 index 0000000000..a04425cee4 --- /dev/null +++ b/Zend/tests/bug72101.phpt @@ -0,0 +1,85 @@ +--TEST-- +Bug #72101 (crash on complex code) +--FILE-- +<?php +class PHPUnit_Framework_MockObject_Stub_ReturnCallback { + protected $callback; + public function __construct($callback) { + $this->callback = $callback; + } + public function invoke($invocation) { + return call_user_func_array($this->callback, $invocation->parameters); + } +} + +class PHPUnit_Framework_MockObject_InvocationMocker { + protected $matchers = []; + public function addMatcher( $matcher) { + $this->matchers[] = $matcher; + } + public function invoke( $invocation) { + foreach ($this->matchers as $match) { + $match->invoked($invocation); + } + } +} + +class PHPUnit_Framework_MockObject_Matcher { + public $stub = null; + public function invoked($invocation) { + return $this->stub->invoke($invocation); + } +} + +class MethodCallbackByReference { + public function bar(&$a, &$b, $c) { + Legacy::bar($a, $b, $c); + } + public function callback(&$a, &$b, $c) { + $b = 1; + } +} +class PHPUnit_Framework_MockObject_Invocation_Static { + public $parameters; + public function __construct(array $parameters) { + $this->parameters = $parameters; + } +} + +class Mock_MethodCallbackByReference_7b180d26 extends MethodCallbackByReference { + public $inv_mocker; + public function bar(&$a, &$b, $c) { + $arguments = array($a, $b, $c); + $result = $this->inv_mocker->invoke( + new PHPUnit_Framework_MockObject_Invocation_Static( + $arguments + ) + ); + return $result; + } +} + +set_error_handler(function() { +// var_dump(func_get_args()); + DoesNotExists::$nope = true; +}, E_ALL | E_STRICT); + +$foo = new Mock_MethodCallbackByReference_7b180d26(); +$InvMocker = new PHPUnit_Framework_MockObject_InvocationMocker(); +$foo->inv_mocker = $InvMocker; +$OuterMatcher = new PHPUnit_Framework_MockObject_Matcher(); +$InvMocker->addMatcher($OuterMatcher); +$OuterMatcher->methodNameMatcher = null; +$OuterMatcher->stub = new PHPUnit_Framework_MockObject_Stub_ReturnCallback([$foo, 'callback']); +$a = $b = $c = 0; +$foo->bar($a, $b, $c); +--EXPECTF-- +Fatal error: Uncaught Error: Class 'DoesNotExists' not found in %sbug72101.php:61 +Stack trace: +#0 %sbug72101.php(8): {closure}(2, 'Parameter 1 to ...', '%s', 8, Array) +#1 %sbug72101.php(27): PHPUnit_Framework_MockObject_Stub_ReturnCallback->invoke(Object(PHPUnit_Framework_MockObject_Invocation_Static)) +#2 %sbug72101.php(19): PHPUnit_Framework_MockObject_Matcher->invoked(Object(PHPUnit_Framework_MockObject_Invocation_Static)) +#3 %sbug72101.php(51): PHPUnit_Framework_MockObject_InvocationMocker->invoke(Object(PHPUnit_Framework_MockObject_Invocation_Static)) +#4 %sbug72101.php(72): Mock_MethodCallbackByReference_7b180d26->bar(0, 0, 0) +#5 {main} + thrown in %sbug72101.php on line 61 diff --git a/Zend/tests/bug72119.phpt b/Zend/tests/bug72119.phpt new file mode 100644 index 0000000000..b8f070a25a --- /dev/null +++ b/Zend/tests/bug72119.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #72119 (Interface declaration compatibility regression with default values) +--FILE-- +<?php +interface Foo { + public function bar(array $baz = null); +} + +class Hello implements Foo { + public function bar(array $baz = []) + { + + } +} +echo "OK\n"; +?> +--EXPECT-- +OK diff --git a/Zend/tests/bug72162.phpt b/Zend/tests/bug72162.phpt new file mode 100644 index 0000000000..5902c585d8 --- /dev/null +++ b/Zend/tests/bug72162.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #72162 (use-after-free - error_reporting) +--FILE-- +<?php +error_reporting(E_ALL); +$var11 = new StdClass(); +$var16 = error_reporting($var11); +?> +--EXPECTF-- +Catchable fatal error: Object of class stdClass could not be converted to string in %sbug72162.php on line %d diff --git a/Zend/tests/call_user_func_array_prefer_ref.phpt b/Zend/tests/call_user_func_array_prefer_ref.phpt new file mode 100644 index 0000000000..d7a5fd913a --- /dev/null +++ b/Zend/tests/call_user_func_array_prefer_ref.phpt @@ -0,0 +1,73 @@ +--TEST-- +call_user_func_array() passes value to prefer-ref arg if element wasn't a reference +--FILE-- +<?php + +namespace { + call_user_func_array('array_multisort', [[3, 2, 1]]); + + $args = [[3, 2, 1]]; + call_user_func_array('array_multisort', $args); + var_dump($args); + unset($args); + + $array = [3, 2, 1]; + call_user_func('array_multisort', $array); + var_dump($array); + unset($array); +} + +namespace Foo { + call_user_func_array('array_multisort', [[3, 2, 1]]); + + $args = [[3, 2, 1]]; + call_user_func_array('array_multisort', $args); + var_dump($args); + unset($args); + + $array = [3, 2, 1]; + call_user_func('array_multisort', $array); + var_dump($array); + unset($array); +} + +?> +--EXPECT-- +array(1) { + [0]=> + array(3) { + [0]=> + int(3) + [1]=> + int(2) + [2]=> + int(1) + } +} +array(3) { + [0]=> + int(3) + [1]=> + int(2) + [2]=> + int(1) +} +array(1) { + [0]=> + array(3) { + [0]=> + int(3) + [1]=> + int(2) + [2]=> + int(1) + } +} +array(3) { + [0]=> + int(3) + [1]=> + int(2) + [2]=> + int(1) +} diff --git a/Zend/tests/closure_invoke_case_insensitive.phpt b/Zend/tests/closure_invoke_case_insensitive.phpt new file mode 100644 index 0000000000..d41d58a747 --- /dev/null +++ b/Zend/tests/closure_invoke_case_insensitive.phpt @@ -0,0 +1,16 @@ +--TEST-- +Closure::__invoke() is case insensitive +--FILE-- +<?php + +$inc = function(&$n) { + $n++; +}; + +$n = 1; +$inc->__INVOKE($n); +var_dump($n); + +?> +--EXPECT-- +int(2) diff --git a/Zend/tests/constant_expressions_coalesce.phpt b/Zend/tests/constant_expressions_coalesce.phpt new file mode 100644 index 0000000000..425aba69c4 --- /dev/null +++ b/Zend/tests/constant_expressions_coalesce.phpt @@ -0,0 +1,47 @@ +--TEST-- +Constant expressions with null coalescing operator ?? +--FILE-- +<?php + +const A = [1 => [[]]]; + +const T_1 = null ?? A[1]['undefined']['index'] ?? 1; +const T_2 = null ?? A['undefined']['index'] ?? 2; +const T_3 = null ?? A[1][0][2] ?? 3; +const T_4 = A[1][0][2] ?? 4; +const T_5 = null ?? __LINE__; +const T_6 = __LINE__ ?? "bar"; + +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((function(){ static $var = null ?? A[1]['undefined']['index'] ?? 1; return $var; })()); +var_dump((function(){ static $var = null ?? A['undefined']['index'] ?? 2; return $var; })()); +var_dump((function(){ static $var = null ?? A[1][0][2] ?? 3; return $var; })()); +var_dump((function(){ static $var = A[1][0][2] ?? 4; return $var; })()); + +var_dump((new class { public $var = null ?? A[1]['undefined']['index'] ?? 1; })->var); +var_dump((new class { public $var = null ?? A['undefined']['index'] ?? 2; })->var); +var_dump((new class { public $var = null ?? A[1][0][2] ?? 3; })->var); +var_dump((new class { public $var = A[1][0][2] ?? 4; })->var); + +?> +--EXPECTF-- +int(1) +int(2) +int(3) +int(4) +int(%d) +int(%d) +int(1) +int(2) +int(3) +int(4) +int(1) +int(2) +int(3) +int(4) diff --git a/Zend/tests/constant_expressions_coalesce_empty_dim.phpt b/Zend/tests/constant_expressions_coalesce_empty_dim.phpt new file mode 100644 index 0000000000..56ee43b789 --- /dev/null +++ b/Zend/tests/constant_expressions_coalesce_empty_dim.phpt @@ -0,0 +1,11 @@ +--TEST-- +Constant expressions with empty dimension fetch on coalesce +--FILE-- +<?php + +const A = [][] ?? 1; + +?> +--EXPECTF-- +Fatal error: Cannot use [] for reading in %s.php on line %d + diff --git a/Zend/tests/constant_expressions_dynamic.phpt b/Zend/tests/constant_expressions_dynamic.phpt index d4e06ee258..d038591036 100644 --- a/Zend/tests/constant_expressions_dynamic.phpt +++ b/Zend/tests/constant_expressions_dynamic.phpt @@ -35,10 +35,12 @@ const T_19 = [ false => false, true => true, ]; +eval("const T_20x = 'a';"); +const T_20 = null ?: (T_20x . 'bc'); var_dump( T_1, T_2, T_3, T_4, T_5, T_6, T_7, T_8, T_9, T_10, - T_11, T_12, T_13, T_14, T_15, T_16, T_17, T_18, T_19 + T_11, T_12, T_13, T_14, T_15, T_16, T_17, T_18, T_19, T_20 ); ?> @@ -75,3 +77,4 @@ array(6) { [1]=> bool(true) } +string(3) "abc" diff --git a/Zend/tests/dynamic_fully_qualified_call.phpt b/Zend/tests/dynamic_fully_qualified_call.phpt new file mode 100644 index 0000000000..cca6fa38b6 --- /dev/null +++ b/Zend/tests/dynamic_fully_qualified_call.phpt @@ -0,0 +1,15 @@ +--TEST-- +Crash when using dynamic call syntax with fully qualified name in a namespace +--FILE-- +<?php + +namespace Foo; +try { + ('\bar')(); +} catch (\Error $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +Call to undefined function bar() diff --git a/Zend/tests/each_002.phpt b/Zend/tests/each_002.phpt index f47ded4b14..31b749e5fd 100644 --- a/Zend/tests/each_002.phpt +++ b/Zend/tests/each_002.phpt @@ -3,10 +3,12 @@ Testing each() with array and object --FILE-- <?php -$foo = each(new stdClass); +$a = new stdClass; +$foo = each($a); var_dump($foo); -var_dump(each(new stdClass)); +$a = new stdClass; +var_dump(each($a)); $a = array(new stdClass); var_dump(each($a)); diff --git a/Zend/tests/generators/yield_from_force_closed.phpt b/Zend/tests/generators/yield_from_force_closed.phpt new file mode 100644 index 0000000000..87fcd2e8ed --- /dev/null +++ b/Zend/tests/generators/yield_from_force_closed.phpt @@ -0,0 +1,37 @@ +--TEST-- +Cannot "yield from" from force closed generator +--FILE-- +<?php + +function gen1() { + echo "gen1\n"; + yield 1; +} + +function gen2() { + try { + echo "try\n"; + yield from gen1(); + } finally { + echo "finally\n"; + yield from gen1(); + } +} + +try { + $gen = gen2(); + $gen->rewind(); + unset($gen); +} catch (Error $e) { + echo $e, "\n"; +} + +?> +--EXPECTF-- +try +gen1 +finally +Error: Cannot use "yield from" in a force-closed generator in %s:%d +Stack trace: +#0 %s(%d): gen2() +#1 {main} diff --git a/Zend/tests/grammar/regression_004.phpt b/Zend/tests/grammar/regression_004.phpt index e95674d8c9..edb32032ea 100644 --- a/Zend/tests/grammar/regression_004.phpt +++ b/Zend/tests/grammar/regression_004.phpt @@ -12,4 +12,4 @@ class Obj function echo(){} // not valid --EXPECTF-- -Parse error: syntax error, unexpected 'echo' (T_ECHO), expecting identifier (T_STRING) or '(' in %s on line 9 +Parse error: syntax error, unexpected 'echo' (T_ECHO), expecting %s in %s on line 9 diff --git a/Zend/tests/grammar/semi_reserved_001.phpt b/Zend/tests/grammar/semi_reserved_001.phpt index 26b3638a47..48937de39e 100644 --- a/Zend/tests/grammar/semi_reserved_001.phpt +++ b/Zend/tests/grammar/semi_reserved_001.phpt @@ -80,7 +80,6 @@ class Obj function __FILE__(){ echo __METHOD__, PHP_EOL; } function __DIR__(){ echo __METHOD__, PHP_EOL; } function __NAMESPACE__(){ echo __METHOD__, PHP_EOL; } - function __halt_compiler(){ echo __METHOD__, PHP_EOL; } } $obj = new Obj; @@ -160,7 +159,6 @@ $obj->__LINE__(); $obj->__FILE__(); $obj->__DIR__(); $obj->__NAMESPACE__(); -$obj->__halt_compiler(); echo "\nDone\n"; @@ -240,6 +238,5 @@ Obj::__LINE__ Obj::__FILE__ Obj::__DIR__ Obj::__NAMESPACE__ -Obj::__halt_compiler Done diff --git a/Zend/tests/grammar/semi_reserved_002.phpt b/Zend/tests/grammar/semi_reserved_002.phpt index 483ac8ce80..a082f9ddbb 100644 --- a/Zend/tests/grammar/semi_reserved_002.phpt +++ b/Zend/tests/grammar/semi_reserved_002.phpt @@ -80,7 +80,6 @@ class Obj static function __FILE__(){ echo __METHOD__, PHP_EOL; } static function __DIR__(){ echo __METHOD__, PHP_EOL; } static function __NAMESPACE__(){ echo __METHOD__, PHP_EOL; } - static function __halt_compiler(){ echo __METHOD__, PHP_EOL; } } Obj::empty(); @@ -158,7 +157,6 @@ Obj::__LINE__(); Obj::__FILE__(); Obj::__DIR__(); Obj::__NAMESPACE__(); -Obj::__halt_compiler(); echo "\nDone\n"; @@ -238,6 +236,5 @@ Obj::__LINE__ Obj::__FILE__ Obj::__DIR__ Obj::__NAMESPACE__ -Obj::__halt_compiler Done diff --git a/Zend/tests/grammar/semi_reserved_005.phpt b/Zend/tests/grammar/semi_reserved_005.phpt index b2b8471bf0..45d20ad0d8 100644 --- a/Zend/tests/grammar/semi_reserved_005.phpt +++ b/Zend/tests/grammar/semi_reserved_005.phpt @@ -79,7 +79,6 @@ class Obj const __FILE__ = '__FILE__'; const __DIR__ = '__DIR__'; const __NAMESPACE__ = '__NAMESPACE__'; - const __HALT_COMPILER = '__halt_compiler'; } echo Obj::EMPTY, PHP_EOL; @@ -156,7 +155,6 @@ echo Obj::__LINE__, PHP_EOL; echo Obj::__FILE__, PHP_EOL; echo Obj::__DIR__, PHP_EOL; echo Obj::__NAMESPACE__, PHP_EOL; -echo Obj::__HALT_COMPILER, PHP_EOL; echo "\nDone\n"; @@ -235,6 +233,5 @@ __LINE__ __FILE__ __DIR__ __NAMESPACE__ -__halt_compiler Done diff --git a/Zend/tests/invalid_parent_const_ref_leak.phpt b/Zend/tests/invalid_parent_const_ref_leak.phpt new file mode 100644 index 0000000000..33e2548f31 --- /dev/null +++ b/Zend/tests/invalid_parent_const_ref_leak.phpt @@ -0,0 +1,18 @@ +--TEST-- +Leak when using an invalid parent:: reference in a constant definition +--FILE-- +<?php + +class A { + const B = parent::C; +} + +try { + A::B; +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +Cannot access parent:: when current class scope has no parent diff --git a/Zend/tests/memory_get_peak_usage.phpt b/Zend/tests/memory_get_peak_usage.phpt index d3d8282fbd..aeca951304 100644 --- a/Zend/tests/memory_get_peak_usage.phpt +++ b/Zend/tests/memory_get_peak_usage.phpt @@ -2,6 +2,13 @@ int memory_get_peak_usage ([ bool $real_usage = false ] ); --CREDITS-- marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br +--SKIPIF-- +<?php +$zend_mm_enabled = getenv("USE_ZEND_ALLOC"); +if ($zend_mm_enabled === "0") { + die("skip Zend MM disabled"); +} +?> --INI-- memory_limit=-1 --FILE-- diff --git a/Zend/tests/modify_isref_value_return.phpt b/Zend/tests/modify_isref_value_return.phpt new file mode 100644 index 0000000000..1b3122711e --- /dev/null +++ b/Zend/tests/modify_isref_value_return.phpt @@ -0,0 +1,25 @@ +--TEST-- +Indirect modification of isref by-value return value not possible +--FILE-- +<?php + +class A { + public $b; +} + +$arr = []; + +$a = new A; +$a->b =& $arr; + +(new ReflectionProperty('A', 'b'))->getValue($a)[] = 42; + +var_dump($a); + +?> +--EXPECT-- +object(A)#1 (1) { + ["b"]=> + &array(0) { + } +} diff --git a/Zend/tests/name_collision_07.phpt b/Zend/tests/name_collision_07.phpt new file mode 100644 index 0000000000..bc596a3549 --- /dev/null +++ b/Zend/tests/name_collision_07.phpt @@ -0,0 +1,15 @@ +--TEST-- +Class declaration colliding with import (in namespace) +--FILE-- +<?php + +namespace Foo { + class Bar {} +} + +namespace Bazzle { + use Foo\Bar; + class Bar {} +} +--EXPECTF-- +Fatal error: Cannot declare class Bazzle\Bar because the name is already in use in %s on line %d diff --git a/Zend/tests/name_collision_08.phpt b/Zend/tests/name_collision_08.phpt new file mode 100644 index 0000000000..d897419102 --- /dev/null +++ b/Zend/tests/name_collision_08.phpt @@ -0,0 +1,15 @@ +--TEST-- +Function declaration colliding with import (in namespace) +--FILE-- +<?php + +namespace Foo { + function bar() {} +} + +namespace Bazzle { + use function Foo\bar; + function bar() {} +} +--EXPECTF-- +Fatal error: Cannot declare function Bazzle\bar because the name is already in use in %s on line %d diff --git a/Zend/tests/name_collision_09.phpt b/Zend/tests/name_collision_09.phpt new file mode 100644 index 0000000000..b46459eef6 --- /dev/null +++ b/Zend/tests/name_collision_09.phpt @@ -0,0 +1,15 @@ +--TEST-- +Class declaration colliding with import (in namespace) +--FILE-- +<?php + +namespace Foo { + const BAR = 42; +} + +namespace Bazzle { + use const Foo\BAR; + const BAR = 24; +} +--EXPECTF-- +Fatal error: Cannot declare const Bazzle\BAR because the name is already in use in %s on line %d diff --git a/Zend/tests/qm_assign_ref_unwrap_leak.phpt b/Zend/tests/qm_assign_ref_unwrap_leak.phpt new file mode 100644 index 0000000000..137aff5212 --- /dev/null +++ b/Zend/tests/qm_assign_ref_unwrap_leak.phpt @@ -0,0 +1,20 @@ +--TEST-- +Leak in QM_ASSIGN when unwrapping references (rc=1) +--FILE-- +<?php + +function &ref() { + $str = "str"; + $str .= "str"; + return $str; +} + +var_dump(true ? ref() : ref()); +var_dump(ref() ?: ref()); +var_dump(ref() ?? ref()); + +?> +--EXPECT-- +string(6) "strstr" +string(6) "strstr" +string(6) "strstr" diff --git a/Zend/tests/return_types/bug71978.phpt b/Zend/tests/return_types/bug71978.phpt new file mode 100644 index 0000000000..e3c8440212 --- /dev/null +++ b/Zend/tests/return_types/bug71978.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #71978 (Existence of return type hint affects other compatibility rules) +--FILE-- +<?php +class A { + function foo(int $a) {} +} +class B extends A { + function foo(string $a) {} +} +class A1 { + function foo(int $a): int {} +} +class B1 extends A1 { + function foo(string $a): int {} +} +?> +--EXPECTF-- +Warning: Declaration of B::foo(string $a) should be compatible with A::foo(int $a) in %s on line %d + +Warning: Declaration of B1::foo(string $a): int should be compatible with A1::foo(int $a): int in %s on line %d diff --git a/Zend/tests/traits/bug60153.phpt b/Zend/tests/traits/bug60153.phpt index 979eced1fb..8f01e72c2d 100644 --- a/Zend/tests/traits/bug60153.phpt +++ b/Zend/tests/traits/bug60153.phpt @@ -16,4 +16,4 @@ class C implements IFoo { } --EXPECTF-- -Fatal error: Declaration of TFoo::oneArgument() must be compatible with IFoo::oneArgument($a) in %s on line %d +Fatal error: Declaration of C::oneArgument() must be compatible with IFoo::oneArgument($a) in %s on line %d |
