Windows 11: 24h2 VS Code: 1.102.1 (WSL: Ubuntu 24.04.2 LTS) Intelephense: 1.14.4 Symfony: v6.4.23 PHP: 8.2.28
<?php
namespace App\Command;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
#[AsCommand(
name: 'app:fixtures:load-one',
description: 'Load a single Doctrine fixture by class name',
)]
All of the symfony classes are highlighted with a red line by Intelephense.
The above snippet shows that the AsCommand
has been included but the line #[AsCommand(
shows an error of:
Undefined type 'Symfony\Component\Console\Attribute\AsCommand'.intelephense(P1009)
class Symfony\Component\Console\Attribute\AsCommand
function AsCommand::__construct(
string $name,
string|null $description = null,
array $aliases = [],
bool $hidden = false
)
Service tag to autoconfigure commands
I am seeing the exact same error from:
class ClassName extends Command
- Undefined type 'Symfony\Component\Console\Command\Command'.intelephense(P1009)
parent::__construct();
- Undefined type 'Symfony\Component\Console\Command\Command'.intelephense(P1009)
$this->addArgument(...);
- Undefined method 'addArgument'.intelephense(P1013)
protected function execute(InputInterface $input, OutputInterface $output): int
- Undefined type 'Symfony\Component\Console\Input\InputInterface'.intelephense(P1009)
- Undefined type 'Symfony\Component\Console\Output\OutputInterface'.intelephense(P1009)
I have tried:
- Restarting
- laptop
- PHP
- Symfony:server
- VS Code
- Force Intelephense to reindex
- Regenerate autoloader (composer dump-autoload --optimize)
I only have two options left that I can think of that include removing intelephense or specifically applying a setting that stops this (which seems pointless as then its not doing its job) "intelephense.diagnostics.undefinedTypes": false,