psalm / psalm-plugin-laravel

A Psalm plugin for Laravel
MIT License
307 stars 72 forks source link

Multiple suppress don't work #347

Closed keizah7 closed 1 year ago

keizah7 commented 1 year ago

Multiple suppress don't work

ERROR: UnusedClass - database/factories/AttributeGroupFactory.php:12:7 - Class Database\Factories\AttributeGroupFactory is never used (see https://psalm.dev/075)
class AttributeGroupFactory extends Factory
<?php

namespace Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @psalm-suppress UnusedClass, MissingTemplateParam
 */
class AttributeGroupFactory extends Factory
{
    /**
     * Define the model's default state.
     */
    public function definition(): array
    {
        $title = faker_translation('lastName');

        return [
            'title' => $title,
        ];
    }
}
alies-dev commented 1 year ago

Hey @keizah7 This is psalm-related issue (not the plugin one), can you please report about it on https://github.com/vimeo/psalm repository?

keizah7 commented 1 year ago

Hey @keizah7 This is psalm-related issue (not the plugin one), can you please report about it on https://github.com/vimeo/psalm repository?

https://github.com/vimeo/psalm/issues/10144

keizah7 commented 1 year ago

Hey @keizah7 This is psalm-related issue (not the plugin one), can you please report about it on https://github.com/vimeo/psalm repository?

I think it's related to this package, because after installing core package, problem dissapears

alies-dev commented 1 year ago

@keizah7

it's failed with this package/plugin because this package adds TemplateParam checks. But Psalm itself checks for suppressed issues, plugin does not do anything with @psalm-suppress annotations - it just delegates it to psalm.

The best you can do is to specify template type:


<?php

namespace Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @psalm-suppress UnusedClass, MissingTemplateParam
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\AttributeGroup> 
 */
class AttributeGroupFactory extends Factory
{
    /**
     * Define the model's default state.
     */
    public function definition(): array
    {
        $title = faker_translation('lastName');

        return [
            'title' => $title,
        ];
    }
}