diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 6a34b1c6..db71194b 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -599,8 +599,9 @@ class CompilerBase extends \PhpAot\Core\Translator protected function resetNamespace(): void { $this->useNamespaces = []; - $this->useFunctions = []; - $this->namespace = ''; + $this->useAliases = []; + $this->useFunctions = []; + $this->namespace = ''; } protected function getFunctionName(FunctionLike $v): string @@ -654,7 +655,7 @@ class CompilerBase extends \PhpAot\Core\Translator foreach ($this->useNamespaces as $useNamespace) { $ns1 = explode('\\', trim($useNamespace, '\\')); - if ($ns1[array_key_last($ns1)] === $ns2[0]) { + if (strcasecmp($ns1[array_key_last($ns1)], $ns2[0]) === 0) { $ns = '\\' . implode('\\', $ns1); goto _return; } diff --git a/src/Php/Preprocessor.php b/src/Php/Preprocessor.php index d3dfd0cd..6beffb06 100644 --- a/src/Php/Preprocessor.php +++ b/src/Php/Preprocessor.php @@ -85,6 +85,10 @@ class Preprocessor extends CompilerBase $phpCode = $this->loadFile($file); $this->symbolCallInFile[$this->file] = []; + $this->resetFile(); + $this->resetFunction(); + $this->resetClass(); + $this->resetNamespace(); $this->climate->info('prepare: ' . $this->file); try { @@ -194,7 +198,7 @@ class Preprocessor extends CompilerBase protected function prepareClass(Node\Stmt\Class_|Node\Stmt\Trait_|Node\Stmt\Enum_ $class): string { $this->class = $this->parseIdentifier($class->name); - $fullClassName = $this->getNamespacedClassName($this->class); + $fullClassName = $this->getFullClassName(); $fullClassNameLower = strtolower($fullClassName); if (!empty($class->extends)) { diff --git a/src/Php/Translator.php b/src/Php/Translator.php index 62ba54ab..ac41a099 100644 --- a/src/Php/Translator.php +++ b/src/Php/Translator.php @@ -475,7 +475,7 @@ class Translator extends Preprocessor public function getArgInfoHeaderFile(string $stubFilenameWithoutExtension, bool $relative = false): string { foreach ($this->sourceDirs as $srcDir) { - if (str_starts_with($stubFilenameWithoutExtension, $srcDir)) { + if (!is_dir($srcDir) or str_starts_with($stubFilenameWithoutExtension, $srcDir)) { $filePath = ltrim($this->removeCommonPrefix($srcDir, $stubFilenameWithoutExtension), '/'); break; }