-
Notifications
You must be signed in to change notification settings - Fork 391
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
Add larastan analyse #811
Add larastan analyse #811
Conversation
fa071db
to
0dd56b5
Compare
src/Drivers/Database.php
Outdated
->get() | ||
->slice($threshold) | ||
->pluck('id'); | ||
->offset($threshold)->limit((int) '18446744073709551615') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, larastan says that we are bringing unnecessary data to memory.
Example, if we have $threshold = 1000
and audits are 1001, we brings to memory 1001 colection and slice just last one for delete, even if it is less than a 1000, the data is always brought to memory
maybe it would be better to open another PR to discuss this change, i can revert this and set an exception for phpstan
I imagine this goes for V14
Maybe changing to ->limit(PHP_INT_MAX)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another better way is just delete, getting no data, nir checking for empty
return $model->audits()
->latest()
->offset($threshold)->limit(PHP_INT_MAX)
->delete() > 0;
still passes the test itWillRemoveOlderAuditsAboveTheThreshold
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change was added here (12ded01), any reason to do it like this?
Right. Lets get it in the branch and look at it. |
Complement of #810
Closes #808
seems like this make phpstan happy