Skip to content
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

Merged
merged 2 commits into from
Mar 28, 2023

Conversation

erikn69
Copy link
Contributor

@erikn69 erikn69 commented Mar 24, 2023

Complement of #810
Closes #808
seems like this make phpstan happy

@erikn69 erikn69 requested a review from MortenDHansen March 24, 2023 16:27
@erikn69 erikn69 changed the title fix phpstan analyse Add larastan analyse Mar 24, 2023
@erikn69 erikn69 force-pushed the patch-4 branch 4 times, most recently from fa071db to 0dd56b5 Compare March 27, 2023 15:46
->get()
->slice($threshold)
->pluck('id');
->offset($threshold)->limit((int) '18446744073709551615')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this? :)

Copy link
Contributor Author

@erikn69 erikn69 Mar 27, 2023

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)?

Copy link
Contributor Author

@erikn69 erikn69 Mar 27, 2023

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

Copy link
Contributor Author

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?

@MortenDHansen
Copy link
Contributor

Right. Lets get it in the branch and look at it.

@MortenDHansen MortenDHansen merged commit 0a77639 into owen-it:adding-phpstan-to-deployflow Mar 28, 2023
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.

2 participants