idea-php-symfony2-plugin icon indicating copy to clipboard operation
idea-php-symfony2-plugin copied to clipboard

False positive warning for valid relation injection

Open Grzyb9k opened this issue 9 months ago • 1 comments

Hi, I'm encountering a false positive warning in PHPStorm when using a standard Symfony Doctrine relation in an entity constructor. The plugin displays:

Symfony: You probably don't want to inject a "AdvertiserReportMappingProcess" here

This happens even though the injection is fully valid and recommended in Symfony's documentation. Here's a simplified snippet:

public function __construct(
    #[ORM\ManyToOne(targetEntity: AdvertiserReportMappingProcess::class)]
    #[ORM\JoinColumn(name: 'mapping_process_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')]
    private AdvertiserReportMappingProcess $mappingProcess,
    // other arguments...
) {}

The target class is another Doctrine entity. It is a ManyToOne relation, but the same is true for any other relationship. No warning should be shown in this context.

Symfony Support 2024.1.276 PHPStorm 2024.3.5 Symfony 7.2.4 PHP 8.3

Grzyb9k avatar Mar 30 '25 11:03 Grzyb9k

I'm getting the same. This inspection should not be able to the constructor of non-service classes.

stof avatar Oct 27 '25 09:10 stof