fix(compiler): 修复方法调用解析中的参数传递错误

- 修正了 BackendOptionsTest 中的优化级别断言,从 /O2 改为 /O1
- 修复了 CompilerBase 中的方法名参数传递错误,将 $method 改为 $methodName
- 在无法调用方法时添加了致命错误提示
- 删除了 PreprocessorTest 中已弃用的缓存测试方法
pull/1/head
韩天峰 3 months ago
parent 08f90e2df9
commit 8faac7d972
  1. 2
      phpunit/src/Backend/BackendOptionsTest.php
  2. 15
      phpunit/src/PreprocessorTest.php
  3. 3
      src/Php/CompilerBase.php

@ -441,7 +441,7 @@ class BackendOptionsTest extends TestCase
// O1
$opt1 = $compiler->buildCompileOptions(['optimize' => 1]);
$this->assertStringContainsString('/O2', $opt1);
$this->assertStringContainsString('/O1', $opt1);
// O2
$opt2 = $compiler->buildCompileOptions(['optimize' => 2]);

@ -187,21 +187,6 @@ class PreprocessorTest extends TestCase
$this->assertEquals('App\\Entity\\Base', $result);
}
// ========================================================================
// hasCppFileCache
// ========================================================================
public function testHasCppFileCacheWhenDisabled(): void
{
// enableCache defaults to false, so cache should always return false
$this->assertFalse($this->compiler->hasCppFileCache('/tmp/test.php'));
}
public function testHasCppFileCacheNonexistentFile(): void
{
$this->assertFalse($this->compiler->hasCppFileCache('/nonexistent/path/test.php'));
}
// ========================================================================
// sortFiles
// ========================================================================

@ -5412,8 +5412,9 @@ class CompilerBase extends \PhpAot\Core\Translator
if ($type === self::TYPE_STREAM) {
return $this->genStreamNullGuard($expr, $object, $methodName, $fn);
}
return $this->parseUniversalMethodCall($expr, $object, $method, $fn);
return $this->parseUniversalMethodCall($expr, $object, $methodName, $fn);
}
$this->fatalError($expr, "Cannot call method `{$methodName}()` on variable of type {$type}");
}
$this->context->beforeStmtLines[] = '// Method Call: ' . $object . '->' . $this->parseIdentifier($expr->name) . '()';
try {

Loading…
Cancel
Save