diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 5d377ea3..50e06312 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -4599,7 +4599,7 @@ class CompilerBase extends \PhpAot\Core\Translator } // 保护方法,只能当前类和子类使用 if ($flags & Modifiers::PROTECTED) { - return $this->isInheritedFrom($this->classDef->getNamespacedName(), $classDef->getNamespacedName()); + return $this->isInheritedFrom($this->classDef->getNamespacedName(false), $classDef->getNamespacedName(false)); } // 类外部调用,只允许调用 public 方法 return true; @@ -4615,7 +4615,7 @@ class CompilerBase extends \PhpAot\Core\Translator { $classDef = null; if ($object === 'this_') { - $class = $this->class; + $class = $this->getFullClassName(); $classDef = $this->classDef; } elseif (isset($this->context->objects[$object])) { $class = $this->context->objects[$object]; diff --git a/src/Php/Translator.php b/src/Php/Translator.php index 165a26fb..9bb67887 100644 --- a/src/Php/Translator.php +++ b/src/Php/Translator.php @@ -980,7 +980,7 @@ class Translator extends Preprocessor $code .= $this->parseClass($v2); break; case 'Stmt_Const': - $this->parseConstDef($v2) . PHP_EOL; + $this->parseConstDef($v2); break; case 'Stmt_Function': $code .= $this->parseFunction($v2) . PHP_EOL; diff --git a/tests/aot/ref/007.phpt b/tests/aot/ref/007.phpt index b3f492b2..bc8f182c 100644 --- a/tests/aot/ref/007.phpt +++ b/tests/aot/ref/007.phpt @@ -7,6 +7,12 @@ class WorkerA protected function foo(string $name, string &$value) { $value = 'hello ' . $name; } + + public function baz(string $name) { + $value = ''; + $this->foo($name, $value); + return $value; + } } class WorkerB extends WorkerA @@ -22,7 +28,11 @@ function main() { $o = new WorkerB; var_dump($o->bar('php')); + + $o2 = new WorkerA; + var_dump($o2->baz('swoole')); } ?> --EXPECT-- -string(9) "hello php" \ No newline at end of file +string(9) "hello php" +string(12) "hello swoole" \ No newline at end of file