SONARPHP-1660,SONARPHP-1933 S1172 Fix FP with Laravel implicit route model binding - #1811
Conversation
7f1ce73 to
59392a9
Compare
59392a9 to
cbf8b8b
Compare
Do not report unused model parameters that are likely consumed by Laravel's implicit route model binding, where parameter names can correspond to route placeholders. Use local heuristics instead of collecting route registrations. This avoids extending project-level symbol data and the complexity of resolving dynamic PHP route declarations, while keeping detection consistent between normal (full) analysis and SQ IDE.
cbf8b8b to
c431a82
Compare
Avoid reporting unused model parameters injected through Laravel Actions entry points. Recognize public, non-static `asController` methods and `handle` methods identified through Laravel Actions traits or conventional `Actions` namespaces, including inherited action roles.
Code Review ✅ No issues found 1 closed / 1 findings🟡 Medium risk · Adds Laravel-specific parameter suppression heuristics across PHP analysis paths Fixes false positives in S1172 for Laravel implicit route model binding by using local heuristics to detect parameters consumed by Laravel's magic routing, addressing trait detection to properly recognize inherited traits in addition to declaring classes. ✅ 1 closed✅ Edge Case: Trait detection only looks at the declaring class, not inherited traits
Review coverage🧪 Functional validation No results 📋 Rules No rules evaluated 🤖 Auto-approval Not enabled · Set up OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
|




Several user feedback from the rule-feedback-dashboard state that S1172 is not applicable in some Laravel-specific methods.
In some cases, it is possible for users to rename the parameters to
$_so that we don't raise S1172. This work focuses on cases where this escape hatch is not possible.Do not report unused model parameters that are likely consumed by
Laravel's implicit route model binding, where parameter names have to
correspond to route placeholders for it to work.
Detect also
asControllerandhandlemethods from Laravel Actionsand suppress model-like parameters also there.
Use local heuristics instead of collecting route registrations. This
avoids extending project-level symbol data and the complexity of resolving
dynamic PHP route declarations, while keeping detection consistent
between normal (full) analysis and SQ IDE.
Stack created with GitHub Stacks CLI • Give Feedback 💬