- 添加了对 compact('this') 的支持,允许在类方法中使用 this 变量
- 实现了 'this' 变量的特殊处理逻辑,避免未定义变量错误
- 添加了类上下文检查,防止在类外部使用 compact('this')
- 创建了新的测试文件来验证 compact('this') 在不同场景下的行为
- 更新了函数调用优化器以正确处理 'this' 变量的特殊情况
pull/3/head
parent
989395d7e1
commit
1e6fb4972a
4 changed files with 39 additions and 2 deletions
@ -0,0 +1,10 @@ |
||||
<?php |
||||
function main() { |
||||
var_dump( |
||||
(new class { |
||||
function test() { |
||||
return compact('this'); |
||||
} |
||||
})->test() |
||||
); |
||||
} |
||||
@ -0,0 +1,4 @@ |
||||
<?php |
||||
function testCompactThisOutsideClass() { |
||||
var_dump(compact('this')); |
||||
} |
||||
@ -0,0 +1,18 @@ |
||||
<?php |
||||
function main() { |
||||
|
||||
|
||||
var_dump( |
||||
(new class { |
||||
function test(){ |
||||
return (static function(){ return compact('this'); })(); |
||||
} |
||||
})->test() |
||||
); |
||||
|
||||
var_dump(compact('this')); |
||||
|
||||
var_dump((function(){ return compact('this'); })()); |
||||
|
||||
|
||||
} |
||||
Loading…
Reference in new issue