Verified on latest main
PHPantom version / commit
9092234
Installation method
Built from source
Operating system
Linux x86_64
Editor
VS Code
Bug description
Class resolution checks global namespace before current namespace for sibling classes.
According to:
https://www.php.net/manual/en/language.namespaces.fallback.php
Inside a namespace, an unqualified Name resolves to the current namespace, un-namespaced classes must be accessed with \ specifically
Steps to reproduce
mkdir -p tmp/{src,legacy}
cat <<'EOD' >> tmp/src/A.php
<?php
namespace Src;
class A {
public static function y(): void {
B::x();
}
}
EOD
cat <<'EOD' >> tmp/src/B.php
<?
namespace Src;
class B {
public static function x(): void {
echo "x\n";
}
}
EOD
cat <<'EOD' >> tmp/legacy/B.php
<?php
class B {
}
EOD
### Error output or panic trace
```text
./target/release/phpantom_lsp analyze tmp/
3/3 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
------ -----------------------------------
Line tmp/src/A.php
------ -----------------------------------
7 Method 'x' not found on class 'B'
🪪 unknown_member
------ -----------------------------------
[ERROR] Found 1 error
.phpantom.toml
Additional context
workaround is to add explicit use Src/B;
Verified on latest main
mainbranch.PHPantom version / commit
9092234
Installation method
Built from source
Operating system
Linux x86_64
Editor
VS Code
Bug description
Class resolution checks global namespace before current namespace for sibling classes.
According to:
https://www.php.net/manual/en/language.namespaces.fallback.php
Inside a namespace, an unqualified Name resolves to the current namespace, un-namespaced classes must be accessed with
\specificallySteps to reproduce
.phpantom.toml
Additional context
workaround is to add explicit
use Src/B;