- 添加 closure-002.phpt 测试闭包中 use 语法的功能 - 添加 func-self-type.phpt 测试 self 类型提示的功能 - 修改 gen_stub.php 中 self 类型处理逻辑 - 为 ClassInfo 类添加当前类名静态属性 - 更新类解析时设置当前类名信息pull/1/head
parent
dd46d6fa5f
commit
6a9b75d91f
3 changed files with 64 additions and 1 deletions
@ -0,0 +1,38 @@ |
|||||||
|
--TEST-- |
||||||
|
closure 001 |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
function main() |
||||||
|
{ |
||||||
|
$a = 100; |
||||||
|
$b = [1, 2, 3]; |
||||||
|
$fn = function ($x) use ($a, &$b) { |
||||||
|
var_dump($a); |
||||||
|
var_dump($b); |
||||||
|
var_dump($x); |
||||||
|
$b = [4, 5, 6]; |
||||||
|
}; |
||||||
|
$fn(1000); |
||||||
|
var_dump($b); |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
int(100) |
||||||
|
array(3) { |
||||||
|
[0]=> |
||||||
|
int(1) |
||||||
|
[1]=> |
||||||
|
int(2) |
||||||
|
[2]=> |
||||||
|
int(3) |
||||||
|
} |
||||||
|
int(1000) |
||||||
|
array(3) { |
||||||
|
[0]=> |
||||||
|
int(4) |
||||||
|
[1]=> |
||||||
|
int(5) |
||||||
|
[2]=> |
||||||
|
int(6) |
||||||
|
} |
||||||
|
|
||||||
@ -0,0 +1,23 @@ |
|||||||
|
--TEST-- |
||||||
|
static calls |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
namespace Foo { |
||||||
|
class Stream |
||||||
|
{ |
||||||
|
public function pipe(self $stream): void |
||||||
|
{ |
||||||
|
var_dump(get_class($stream)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
namespace { |
||||||
|
function main() { |
||||||
|
$stream1 = new Foo\Stream(); |
||||||
|
$stream2 = new Foo\Stream(); |
||||||
|
$stream1->pipe($stream2); |
||||||
|
} |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
string(10) "Foo\Stream" |
||||||
Loading…
Reference in new issue