diff options
author | Dmitry Stogov <dmitry@zend.com> | 2015-10-06 23:59:36 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2015-10-06 23:59:36 +0300 |
commit | e0b3b3c7524603d57dce62ae1cb1eae3b1bc3e42 (patch) | |
tree | 59103633d3a6a7a08d77841fb0626bffab3acdb9 /Zend/tests/closure_061.phpt | |
parent | e193d35c1ed1307b06cc25c2b720d0141703798c (diff) | |
download | php-git-e0b3b3c7524603d57dce62ae1cb1eae3b1bc3e42.tar.gz |
Revert "Fixed bug #70630 (Closure::call/bind() crash with ReflectionFunction->getClosure())"
This reverts commit 517b5536259ecf7697f353f4bfbafde857fc1f81.
Diffstat (limited to 'Zend/tests/closure_061.phpt')
-rw-r--r-- | Zend/tests/closure_061.phpt | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/Zend/tests/closure_061.phpt b/Zend/tests/closure_061.phpt deleted file mode 100644 index a195956840..0000000000 --- a/Zend/tests/closure_061.phpt +++ /dev/null @@ -1,64 +0,0 @@ ---TEST-- -Closure::call() or Closure::bind() to independent class must fail ---FILE-- -<?php - -class foo { - public $var; - - function initClass() { - $this->var = __CLASS__; - } -} - -class bar { - public $var; - - function initClass() { - $this->var = __CLASS__; - } - - function getVar() { - assert($this->var !== null); // ensure initClass was called - return $this->var; - } -} - -class baz extends bar { - public $var; - - function initClass() { - $this->var = __CLASS__; - } -} - -function callMethodOn($class, $method, $object) { - $closure = (new ReflectionMethod($class, $method))->getClosure((new ReflectionClass($class))->newInstanceWithoutConstructor()); - $closure = $closure->bindTo($object, $class); - return $closure(); -} - -$baz = new baz; - -callMethodOn("baz", "initClass", $baz); -var_dump($baz->getVar()); - -callMethodOn("bar", "initClass", $baz); -var_dump($baz->getVar()); - -callMethodOn("foo", "initClass", $baz); -var_dump($baz->getVar()); - -?> ---EXPECTF-- -string(3) "baz" -string(3) "bar" - -Warning: Cannot bind function foo::initClass to object of class baz in %s on line %d - -Fatal error: Uncaught Error: Using $this when not in object context in %s:%d -Stack trace: -#0 %s(%d): initClass() -#1 %s(%d): callMethodOn('foo', 'initClass', Object(baz)) -#2 {main} - thrown in %s on line %d |