fix: skip more scope methods that aren't scopes based on types#409
fix: skip more scope methods that aren't scopes based on types#409mnastalski wants to merge 1 commit into
Conversation
|
Not everyone types the param and return types. Are you running into an actual issue or is this a premature optimization?
Why would you have a method like this on a model if it's not a scope?
I suppose this is valid, we could update the regex to |
|
This is an actual issue - I have methods with names similar to the examples I gave and in my case they are relationships. I would say that |
|
@mnastalski there's not much we can do for the case of For the other one though, |
|
@GeniJaho thoughts on making the types optional? I updated the PR with following:
I can update the regex on top of that but I noticed declaring |
* Feat: Update local scope analyzing rules to check the scope is not a relationship/other method * Update fixtures * Simplify ScopeAnalyzer * Cover edge cases from #409 * Feedback: directly call scopeAnalyzer service from MakeModelAttributesAndScopesProtectedRector * Feedback: Simplify named scope check to suggested regex, ditch return type checks * Update tests per feedback cases * Fix PHPStan notice
Hey,
Expanding on #380, I would like to add more checks to
MakeModelAttributesAndScopesProtectedRectorto avoid some methodsthat aren't scopes being picked up as ones. Right now if you have a method like
scopeItemorscopedItemit's going to get picked up and erroneously have its visibility changed.I propose adding the following checks:
Illuminate\Database\Eloquent\BuilderIlluminate\Database\Eloquent\BuilderorvoidThese are in line with the docs. Additionally, if a method has the
#[Scope]attribute then it will be considered a scope unconditionally.