diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 0d0ea582..d847126e 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -1046,14 +1046,17 @@ class CompilerBase extends \PhpAot\Core\Translator $this->fatalError($param, 'Variadic parameters cannot be passed by reference'); } } - $name = $this->parseIdentifier($param->var); - $type = $this->parseParameterType($param, $name); + $name = $this->parseIdentifier($param->var); + if ($this->method and $name == 'this_') { + $this->fatalError($param, 'Cannot use `$this` as parameter of class method'); + } + $type = $this->parseParameterType($param, $name); if ($param->variadic) { - $list[] = self::TYPE_ARRAY . ' ' . $name; + $list[] = self::TYPE_ARRAY . ' ' . $name; } else { - $list[] = $type . ' ' . $name; + $list[] = $type . ' ' . $name; } - $argInfo = new ArgInfo(); + $argInfo = new ArgInfo(); $argInfo->name = $name; $argInfo->type = $type; $argInfo->byRef = $param->byRef; @@ -4005,6 +4008,10 @@ class CompilerBase extends \PhpAot\Core\Translator $classDef = $this->getClass($findClass); if ($classDef->hasProperty($property)) { $propertyDef = $classDef->getProperty($property); + // 属性是静态的,但作为动态属性访问,只能动态获取 + if ($propertyDef->isStatic()) { + return null; + } if ($propertyDef->isPublic()) { return $this->getPropertyOffset($classDef->getNamespacedName(false), $property); } diff --git a/src/Php/Constants.php b/src/Php/Constants.php index f199ca77..5e7fd3ca 100644 --- a/src/Php/Constants.php +++ b/src/Php/Constants.php @@ -54,6 +54,7 @@ class Constants 'template', 'namespace', 'errno', // Linux error code + 'this_', // phpx keywords ]; public const UNSUPPORTED_FUNCTIONS = [