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

diffForHumans broken after commit 0f0a245 #2744

Closed
michaelm111 opened this issue Jan 1, 2023 · 2 comments · Fixed by #2745
Closed

diffForHumans broken after commit 0f0a245 #2744

michaelm111 opened this issue Jan 1, 2023 · 2 comments · Fixed by #2745
Assignees
Labels

Comments

@michaelm111
Copy link

Hello,

I encountered an issue with the following code:

\Carbon\Carbon::yesterday()->diffForHumans([
  'syntax' => \Carbon\CarbonInterface::DIFF_ABSOLUTE,
  'parts' => 3,
  'skip' => 's',
]);

Carbon version: 2.64.0

PHP version: 7.4.33

I expected to get:

1 day 16 hours 57 minutes

But I actually get:

Uncaught Exception TypeError: "Argument 3 passed to Carbon\Carbon::diffAsCarbonInterval() must be of the type array, string given, called in /vendor/nesbot/carbon/src/Carbon/Traits/Difference.php on line 847" at /vendor/nesbot/carbon/src/Carbon/Traits/Difference.php line 151

Thanks!

@michaelm111
Copy link
Author

michaelm111 commented Jan 1, 2023

The workaround is to pass 'skip' as array (['s']), however, documentation states that skip can be array of strings or single string. This was working before version 2.64.0.

@kylekatarnls
Copy link
Collaborator

string is indeed intended to be supported. Patch 2.64.1 released with a fix for it

Test also added to make sure it remains supported.

Thanks for the report 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants