Skip to content

Add 5 Doctrine + Symfony-config rules - #291

Merged
TomasVotruba merged 2 commits into
mainfrom
tv/doctrine-and-config-rules
Sep 21, 2026
Merged

TomasVotruba merged 2 commits into
mainfrom
tv/doctrine-and-config-rules

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Adds 5 rules extracted from a real Symfony/Doctrine app.

Doctrine

  • NoStringTargetEntityRule — a #[ManyToOne/OneToMany/OneToOne/ManyToMany] association must use Target::class, not a string targetEntity.
  • NoReadonlyEntityClassRule — a Doctrine entity (recognized by #[ORM\Entity] or a public static loadMetadata()) must not be a readonly class, since Doctrine hydrates via reflection without the constructor.

Symfony / config closures

  • PreferClassInDefinitionFetchRule$container->getDefinition('Foo\Bar') should use getDefinition(Foo\Bar::class) when the string is a real class (compiler passes); a plain service id is left alone.
  • NoServiceSetterCallRule — a config-closure ->call('setX', [service(...)]) should be a #[Required] setter; only a setXxx() fed a service() is reported (a container parameter or non-setter call stays).
  • NoAutoconfiguredServiceTagRule — when the closure's defaults() uses autoconfigure(), a ->tag() that autoconfiguration already adds by interface (console.command, form.type, kernel.event_subscriber, security.voter, twig.extension, validator.constraint_validator) is redundant; only a tag with no attributes of its own is reported.

Each rule is registered in the matching set (doctrine-rules.neon, symfony-config-rules.neon, symfony-rules.neon), documented in the README, and covered by a RuleTestCase with report + skip fixtures.

Green locally: ECS, PHPStan, Rector, composer-dependency-analyser, neon-lint, full PHPUnit (378 tests).

@TomasVotruba
TomasVotruba enabled auto-merge (squash) September 21, 2026 11:17
@TomasVotruba
TomasVotruba merged commit 52e76bb into main Sep 21, 2026
7 of 8 checks passed
@TomasVotruba
TomasVotruba deleted the tv/doctrine-and-config-rules branch September 21, 2026 11:17
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

Successfully merging this pull request may close these issues.

1 participant