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

[11.x] Add \DateTimeInterface and \DateInterval to type for Cache::flexible() #52888

Conversation

bram-pkg
Copy link
Contributor

@bram-pkg bram-pkg commented Sep 23, 2024

The \Illuminate\Cache\Repository::flexible also supports being passed the following I believe:

cache()->flexible(
  'key',
  [now()->addHour(), now()->addHours(2)],
  fn () => 'value',
);

This is now reflected in the phpdoc. The purpose of this PR is to add these types to be allowed in the docblock, improving PHPStan understanding of the code.

I have used the same ordering of types as on \Illuminate\Cache\Repository::putMany.

This PR will also eliminate the following PHPStan error:

Parameter $ttl of method Illuminate\Cache\Repository::flexible() expects array{int, int}, array{Illuminate\Support\Carbon, Illuminate\Support\Carbon} given.

@crynobone crynobone marked this pull request as draft September 23, 2024 15:51
@crynobone
Copy link
Member

Marking as draft since tests are failing

@bram-pkg
Copy link
Contributor Author

bram-pkg commented Sep 23, 2024

I'm not sure the tests are actually failing, it seems the CI is just having a fit:
image

@bram-pkg
Copy link
Contributor Author

I do not have permission to re-run the CI, so you'll have to do that or I can push an empty commit.

@bram-pkg bram-pkg force-pushed the bram-pkg/add-date-interface-to-cache-flexible branch from 3a50c5a to 30e2b76 Compare September 23, 2024 15:57
@crynobone crynobone marked this pull request as ready for review September 23, 2024 16:16
@crynobone crynobone changed the title Add \DateTimeInterface and \DateInterval to type for Cache::flexible() [11.x] Add \DateTimeInterface and \DateInterval to type for Cache::flexible() Sep 24, 2024
@taylorotwell taylorotwell merged commit 84540bd into laravel:11.x Sep 24, 2024
30 checks passed
@bram-pkg bram-pkg deleted the bram-pkg/add-date-interface-to-cache-flexible branch September 24, 2024 13:43
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.

3 participants