Typehinting merge #50

已合并
belliash 2019-04-17 11:27:52 +02:00 将 298 次代码提交从 typehinting合并至 master
修改 2 个文件,包含 36 行新增0 行删除
仅显示提交 aae526b1d4 的更改 - 显示所有提交

28
tests/anon_filter.aer 普通文件
查看文件

@@ -0,0 +1,28 @@
class Program {
private callback $condition = bool(int $x) { return ($x > 100); };
private int[] $numbers = {34, 56, 22, 1, 5, 67, 897, 123, 55, 101};
int[] filter(callback $condition, int[] $numbers) {
int $len = sizeof($numbers);
int[] $filtered;
for(int $i = 0; $i < $len; $i++) {
if($condition($numbers[$i])) {
$filtered[] = $numbers[$i];
}
}
return $filtered;
}
void main() {
int[] $filtered = $this->filter($this->condition, $this->numbers);
var_dump($filtered);
}
}
/*
* Should output
Array ( [0] => 897 [1] => 123 )
*/

8
tests/anon_filter.exp 普通文件
查看文件

@@ -0,0 +1,8 @@
array(int, 3) {
[0] =>
int(897)
[1] =>
int(123)
[2] =>
int(101)
}