- 修复了编译器中return语句缺少分号的问题 - 修正了未定义变量错误提示中的变量名显示格式 - 统一使用errorUndefinedVariable方法处理闭包中未定义变量的情况 - 添加了对closure_011和closure_013测试用例的支持pull/1/head
parent
67427f342d
commit
bd06dcf0a5
3 changed files with 46 additions and 4 deletions
@ -0,0 +1,14 @@ |
||||
--TEST-- |
||||
Closure 011: Lexical copies not static in closure |
||||
--FILE-- |
||||
<?php |
||||
$i = 1; |
||||
$lambda = function () use ($i) { |
||||
return ++$i; |
||||
}; |
||||
$lambda(); |
||||
echo $lambda()."\n"; |
||||
//early prototypes gave 3 here because $i was static in $lambda |
||||
?> |
||||
--EXPECT-- |
||||
2 |
||||
@ -0,0 +1,28 @@ |
||||
--TEST-- |
||||
Closure 013: __invoke() on temporary result |
||||
--FILE-- |
||||
<?php |
||||
class Foo { |
||||
function __invoke() { |
||||
echo "Hello World!\n"; |
||||
} |
||||
} |
||||
|
||||
function foo() { |
||||
return function() { |
||||
echo "Hello World!\n"; |
||||
}; |
||||
} |
||||
|
||||
function main() { |
||||
$test = new Foo; |
||||
$test->__invoke(); |
||||
$test = foo(); |
||||
$test->__invoke(); |
||||
$test = foo()->__invoke(); |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
Hello World! |
||||
Hello World! |
||||
Hello World! |
||||
Loading…
Reference in new issue