Skip to content

False positive warning for valid relation injection #2421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Grzyb9k opened this issue Mar 30, 2025 · 0 comments
Open

False positive warning for valid relation injection #2421

Grzyb9k opened this issue Mar 30, 2025 · 0 comments

Comments

@Grzyb9k
Copy link

Grzyb9k commented Mar 30, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant