You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NoPublicNonActionMethodInControllerRule treats a public controller method as a route action only if its name ends in Action or it is __invoke(). Methods that carry a #[Route] attribute are not recognised, so every attribute-routed controller with conventional method names gets reported:
Controller method "submit()" is not a route action, so it cannot be public. Make it protected or private
🪪 symfony.noPublicNonActionMethodInController
Making the method private breaks the route, and the *Action suffix has not been the Symfony convention since attribute routing became the default. In our project the upgrade from 14.17.0 produced 63 errors, all of them on #[Route] methods.
Expected: methods with a Symfony\Component\Routing\Attribute\Route (or the legacy Symfony\Component\Routing\Annotation\Route) attribute are skipped, the same way #[Required] setters already are.
Suggested fix: extend hasRequiredAttribute() (or add a sibling check) to also return early for the two Route attribute classes. I can open a PR with a fixture if that helps.
Activity
TomasVotruba commentedon Oct 14, 2026
Can you send a failing PR with test fixture here?
M-arcus commentedon Oct 14, 2026
https://github.com/symplify/phpstan-rules/actions/runs/38586276001/job/115929415148?pr=370#step:5:1
TomasVotruba commentedon Oct 14, 2026
Thank you 👍
Fixed in #371