diff options
Diffstat (limited to 'Zend/tests')
-rwxr-xr-x | Zend/tests/closure_033.phpt | 28 | ||||
-rwxr-xr-x | Zend/tests/closure_034.phpt | 233 |
2 files changed, 261 insertions, 0 deletions
diff --git a/Zend/tests/closure_033.phpt b/Zend/tests/closure_033.phpt new file mode 100755 index 0000000000..f6510066bb --- /dev/null +++ b/Zend/tests/closure_033.phpt @@ -0,0 +1,28 @@ +--TEST-- +Closure 033: Dynamic closure property and private function +--FILE-- +<?php + +class Test { + public $func; + function __construct() { + $this->func = function() { + echo __METHOD__ . "()\n"; + }; + } + private function func() { + echo __METHOD__ . "()\n"; + } +} + +$o = new Test; +$f = $o->func; +$f(); +$o->func(); + +?> +===DONE=== +--EXPECTF-- +Test::{closure}() + +Fatal error: Call to private method Test::func() from context '' in %sclosure_033.php on line %d diff --git a/Zend/tests/closure_034.phpt b/Zend/tests/closure_034.phpt new file mode 100755 index 0000000000..c919671cd0 --- /dev/null +++ b/Zend/tests/closure_034.phpt @@ -0,0 +1,233 @@ +--TEST-- +Closure 034: var_dump() of a Closure +--FILE-- +<?php + +$outer = 25; + +class Test { + public $func1; + public $var = 42; + function __construct() { + global $outer; + $this->func1 = function($param, $other = "default") use ($outer) { + }; + } +} + +$o = new Test; +var_dump($o->func1); + +$o->func2 = function($param, $other = "default") use ($outer) { +}; + +var_dump($o->func2); + +$func3 = function($param, $other = "default") use ($outer) { +}; + +var_dump($func3); + +?> +===DONE=== +--EXPECTF-- +object(Closure)#%d (3) { + ["this"]=> + object(Test)#%d (2) { + ["func1"]=> + object(Closure)#%d (3) { + ["this"]=> + object(Test)#%d (2) { + ["func1"]=> + object(Closure)#%d (3) { + ["this"]=> + *RECURSION* + ["static"]=> + array(1) { + ["outer"]=> + int(25) + } + ["parameter"]=> + array(2) { + ["$param"]=> + string(10) "<required>" + ["$other"]=> + string(10) "<optional>" + } + } + ["var"]=> + int(42) + } + ["static"]=> + array(1) { + ["outer"]=> + int(25) + } + ["parameter"]=> + array(2) { + ["$param"]=> + string(10) "<required>" + ["$other"]=> + string(10) "<optional>" + } + } + ["var"]=> + int(42) + } + ["static"]=> + array(1) { + ["outer"]=> + int(25) + } + ["parameter"]=> + array(2) { + ["$param"]=> + string(10) "<required>" + ["$other"]=> + string(10) "<optional>" + } +} +object(Closure)#%d (3) { + ["this"]=> + object(Test)#%d (3) { + ["func1"]=> + object(Closure)#%d (3) { + ["this"]=> + object(Test)#%d (3) { + ["func1"]=> + object(Closure)#%d (3) { + ["this"]=> + *RECURSION* + ["static"]=> + array(1) { + ["outer"]=> + int(25) + } + ["parameter"]=> + array(2) { + ["$param"]=> + string(10) "<required>" + ["$other"]=> + string(10) "<optional>" + } + } + ["var"]=> + int(42) + ["func2"]=> + object(Closure)#%d (3) { + ["this"]=> + *RECURSION* + ["static"]=> + array(1) { + ["outer"]=> + &int(25) + } + ["parameter"]=> + array(2) { + ["$param"]=> + string(10) "<required>" + ["$other"]=> + string(10) "<optional>" + } + } + } + ["static"]=> + array(1) { + ["outer"]=> + int(25) + } + ["parameter"]=> + array(2) { + ["$param"]=> + string(10) "<required>" + ["$other"]=> + string(10) "<optional>" + } + } + ["var"]=> + int(42) + ["func2"]=> + object(Closure)#%d (3) { + ["this"]=> + object(Test)#%d (3) { + ["func1"]=> + object(Closure)#%d (3) { + ["this"]=> + *RECURSION* + ["static"]=> + array(1) { + ["outer"]=> + int(25) + } + ["parameter"]=> + array(2) { + ["$param"]=> + string(10) "<required>" + ["$other"]=> + string(10) "<optional>" + } + } + ["var"]=> + int(42) + ["func2"]=> + object(Closure)#%d (3) { + ["this"]=> + *RECURSION* + ["static"]=> + array(1) { + ["outer"]=> + &int(25) + } + ["parameter"]=> + array(2) { + ["$param"]=> + string(10) "<required>" + ["$other"]=> + string(10) "<optional>" + } + } + } + ["static"]=> + array(1) { + ["outer"]=> + &int(25) + } + ["parameter"]=> + array(2) { + ["$param"]=> + string(10) "<required>" + ["$other"]=> + string(10) "<optional>" + } + } + } + ["static"]=> + array(1) { + ["outer"]=> + &int(25) + } + ["parameter"]=> + array(2) { + ["$param"]=> + string(10) "<required>" + ["$other"]=> + string(10) "<optional>" + } +} +object(Closure)#%d (3) { + ["this"]=> + NULL + ["static"]=> + array(1) { + ["outer"]=> + int(25) + } + ["parameter"]=> + array(2) { + ["$param"]=> + string(10) "<required>" + ["$other"]=> + string(10) "<optional>" + } +} +===DONE=== |