When using the PHP Namespace Resolver extension in VSCode, importing a class via Ctrl+Alt+I or the context‑menu option causes incorrect behavior inside a Livewire 4 anonymous component.
Example:
new #[Layout('layouts.admin')] class extends Component {
use WithPagination;
}
Problems encountered:
- The imported class is inserted inside the anonymous class, e.g.:
new class extends Component {
use WithPagination;
use Maatwebsite\Excel\Facades\Excel; // should be placed at the top of the file
}
- In some cases, the entire
new #[Layout(...)] class extends Component { block is removed or corrupted after triggering an import.
It seems the extension does not correctly detect or parse PHP anonymous classes, especially when attributes are present. This makes it unsafe to use the import feature in Livewire single‑file components.
Could support for anonymous classes be improved so imports are added at the file level without modifying or breaking the class expression?
When using the PHP Namespace Resolver extension in VSCode, importing a class via Ctrl+Alt+I or the context‑menu option causes incorrect behavior inside a Livewire 4 anonymous component.
Example:
Problems encountered:
new #[Layout(...)] class extends Component {block is removed or corrupted after triggering an import.It seems the extension does not correctly detect or parse PHP anonymous classes, especially when attributes are present. This makes it unsafe to use the import feature in Livewire single‑file components.
Could support for anonymous classes be improved so imports are added at the file level without modifying or breaking the class expression?