phpstan / extension-installer

Composer plugin for automatic installation of PHPStan extensions.
MIT License
388 stars 27 forks source link

Config generation on global installation #65

Open umulmrum opened 1 year ago

umulmrum commented 1 year ago

Hi,

I have the following constellation:

My problem is as follows:

This is because the extension installer re-generates the GeneratedConfig on composer install, and because there are no extensions installed locally, the config is now empty. This leads to some code not being correctly interpreted because the extensions are ignored.

Is there anything I need to do, or do you have other advice? Thanks! :-)

ondrejmirtes commented 1 year ago

Hi, I don't understand this problem, can you list the exact steps that lead to this problem? I don't understand why running composer install locally in the project would lead to executing a plugin from the global installation.

Anyway, your best best is to install PHPStan locally in your project, which will remove your headaches like these, and is the recommended option anyway (https://phpstan.org/user-guide/getting-started).

umulmrum commented 1 year ago

@ondrejmirtes Thanks for your reply. These are the steps (I didn't doublecheck, so there might be mistakes in them, but I think the way in general gets clear):

Example entity (reader, but no setter):

class MyEntity
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column(type: 'integer')]
    private int $id;

    public function getId(): int
    {
        return $this->id;
    }
}

I'd like to avoid installing quality tools as project dependencies, to a) have them completely independent and "un-interfering", and b) only need a single installation in a monorepo to simplify maintenance.

scollovati commented 10 months ago

I had the same issue today: https://github.com/TomasVotruba/type-coverage/issues/10#issuecomment-1711791438

By uninstalling the global "auto-installer" everything goes fine. However, having the possibility of using PHPStan with extensions both locally and globally with the auto-installer would be great.

Until this issue is solved, the only possibility is to include manually the config files.

NB: it seems the same issue referenced here https://github.com/phpstan/extension-installer/issues/76#issuecomment-1657099451

michaellehmkuhl commented 1 month ago

I also ran into this issue. Thanks @scollovati for the hint about uninstalling.

After I removed it with composer global uninstall phpstan/extension-installer, my local project composer install correctly populated the GeneratedConfig.php in my project vendor directory.

umulmrum commented 1 month ago

FYI I ended up adding a call to composer global install to the composer script that runs PHPStan, so the issue is automatically handled on each execution.