psalm-plugin-symfony icon indicating copy to clipboard operation
psalm-plugin-symfony copied to clipboard

Kernel.stubphp is creating a PropertyNotSetInConstructor error

Open VincentLanglet opened this issue 4 years ago • 6 comments
trafficstars

Ref https://github.com/psalm/psalm-plugin-symfony/pull/220#issuecomment-945447558

The following code

class AppKernel extends Kernel
{
    use MicroKernelTrait;

    public function __construct()
    {
        parent::__construct('test', true);
    }
}

is giving a PropertyNotSetInConstructor error.

@enumag @seferov do you see a workaround ?

VincentLanglet avatar Nov 02 '21 07:11 VincentLanglet

That's odd. It's a protected property so the responsibility of setting it lies in the parent Kernel class. Perhaps it might help adding the constructor which sets it into the stub? If that doesn't help then I think it's psalm bug.

enumag avatar Nov 02 '21 08:11 enumag

I tried to add

    public function __construct(string $environment, bool $debug)
    {
        $this->environment = $environment;
        $this->debug = $debug;
    }

inside the stub without success.

It's even worst because I end with the same error for the debug property.

Seems like a psalm bug. cc @weirdan @orklah

VincentLanglet avatar Dec 05 '21 19:12 VincentLanglet

@VincentLanglet mind creating a reproducer in a separate repo?

weirdan avatar Dec 05 '21 20:12 weirdan

Sure, https://github.com/VincentLanglet/SonataDoctrineORMAdminBundle/tree/reproducerPsalm can be used.

VincentLanglet avatar Dec 05 '21 20:12 VincentLanglet

Can anyone help with provide steps to fix this issue? Should it be fixed in vimeo/psalm or psalm-plugin-symfony?

andrew-demb avatar Jun 22 '22 10:06 andrew-demb

There is a reproducer here: https://github.com/vimeo/psalm/pull/7075, so I assume it should be fixed in vimeo/psalm

VincentLanglet avatar Jun 22 '22 10:06 VincentLanglet