- 移除独立的 compiler_options.php 配置文件 - 将编译器选项定义移至 Php/Constants.php 中的 COMPILER_OPTIONS 常量 - 更新 CompilerBase.php 中的 getNamespacedClassName 调用方式 - 修改 Constants.php 中的 UNSUPPORTED_FUNCTIONS 为数组类型 - 更新 Translator.php 中配置加载方式,使用 Constants::COMPILER_OPTIONS 替代 require - 添加 objval 函数的相关测试用例pull/1/head
parent
5bf12a10ed
commit
12ff420d87
5 changed files with 113 additions and 76 deletions
@ -1,72 +0,0 @@ |
|||||||
<?php |
|
||||||
return [ |
|
||||||
'optimize' => [ |
|
||||||
'prefix' => 'O', |
|
||||||
'longPrefix' => 'optimize', |
|
||||||
'description' => 'Set the optimization level of the gcc compiler to 0 by default', |
|
||||||
'required' => false, |
|
||||||
'castTo' => 'int', |
|
||||||
'defaultValue' => 0, |
|
||||||
], |
|
||||||
'output' => [ |
|
||||||
'prefix' => 'o', |
|
||||||
'longPrefix' => 'output', |
|
||||||
'description' => 'Output file', |
|
||||||
], |
|
||||||
'help' => [ |
|
||||||
'prefix' => 'h', |
|
||||||
'longPrefix' => 'help', |
|
||||||
'description' => 'Show help', |
|
||||||
'noValue' => true, |
|
||||||
], |
|
||||||
'version' => [ |
|
||||||
'prefix' => 'v', |
|
||||||
'longPrefix' => 'version', |
|
||||||
'description' => 'Show Version', |
|
||||||
'noValue' => true, |
|
||||||
], |
|
||||||
'profile' => [ |
|
||||||
'longPrefix' => 'profile', |
|
||||||
'description' => 'Enable performance profiling', |
|
||||||
'required' => false, |
|
||||||
'noValue' => true, |
|
||||||
], |
|
||||||
'noLiteralStrings' => [ |
|
||||||
'longPrefix' => 'no-literal-strings', |
|
||||||
'description' => 'Disable literal strings optimization', |
|
||||||
'required' => false, |
|
||||||
'noValue' => true, |
|
||||||
], |
|
||||||
'force' => [ |
|
||||||
'prefix' => 'f', |
|
||||||
'longPrefix' => 'force', |
|
||||||
'description' => 'Force compile even if cache exists', |
|
||||||
'required' => false, |
|
||||||
'noValue' => true, |
|
||||||
], |
|
||||||
'mode' => [ |
|
||||||
'longPrefix' => 'mode', |
|
||||||
'prefix' => 'm', |
|
||||||
'description' => 'Build mode, -m bin(binary) or -m ext(extension), default: bin', |
|
||||||
'required' => false, |
|
||||||
'defaultValue' => 'bin', |
|
||||||
], |
|
||||||
'debug-line' => [ |
|
||||||
'longPrefix' => 'debug-line', |
|
||||||
'description' => 'Enable debug line', |
|
||||||
'required' => false, |
|
||||||
'defaultValue' => 0, |
|
||||||
], |
|
||||||
'debug-info' => [ |
|
||||||
'longPrefix' => 'debug-info', |
|
||||||
'description' => 'Enable debug info', |
|
||||||
'required' => false, |
|
||||||
], |
|
||||||
'job' => [ |
|
||||||
'prefix' => 'j', |
|
||||||
'longPrefix' => 'job', |
|
||||||
'description' => 'Number of jobs to run in parallel', |
|
||||||
'required' => false, |
|
||||||
'defaultValue' => 4, |
|
||||||
], |
|
||||||
]; |
|
||||||
@ -0,0 +1,37 @@ |
|||||||
|
--TEST-- |
||||||
|
objval |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
|
||||||
|
class TestObjval |
||||||
|
{ |
||||||
|
public int $a; |
||||||
|
public int $b; |
||||||
|
|
||||||
|
public function __construct(int $a, int $b) |
||||||
|
{ |
||||||
|
$this->a = $a; |
||||||
|
$this->b = $b; |
||||||
|
} |
||||||
|
|
||||||
|
public function test() |
||||||
|
{ |
||||||
|
return $this->a + $this->b; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function main() |
||||||
|
{ |
||||||
|
$obj = new TestObjval(1, 2); |
||||||
|
$arr = array(); |
||||||
|
$arr['obj'] = $obj; |
||||||
|
$obj2 = objval($arr['obj'], 'TestObjval'); |
||||||
|
var_dump($obj2->test()); |
||||||
|
|
||||||
|
$obj3 = objval($obj, TestObjval::class); |
||||||
|
var_dump($obj3->test()); |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
int(3) |
||||||
|
int(3) |
||||||
Loading…
Reference in new issue