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

Carbon ->toPeriod with interval / duration string fails after 3.2.1 version #2985

Closed
olexoliinyk0 opened this issue Mar 28, 2024 · 1 comment · Fixed by #2987
Closed

Carbon ->toPeriod with interval / duration string fails after 3.2.1 version #2985

olexoliinyk0 opened this issue Mar 28, 2024 · 1 comment · Fixed by #2987
Assignees
Labels

Comments

@olexoliinyk0
Copy link

Hello, after upgrading from 3.1.1 to 3.2.1 ->toPediod(.. throws an error.

I encountered an issue with the following code:

$date1 = \Carbon\Carbon::parse('2018-06-01');
$date2 = \Carbon\Carbon::parse('2018-06-10');
$period = $date1->toPeriod($date2, 'P1D');
// before 3.2.1 -> works
// after 3.2.1 --> this error:

DatePeriod::__construct() accepts (DateTimeInterface, DateInterval, int [, int]), or (DateTimeInterface, DateInterval, DateTime [, int]), or (string [, int]) as arguments

  at vendor/nesbot/carbon/src/Carbon/CarbonPeriod.php:702
    698699$raw ??= ['R1/2000-01-01T00:00:00Z/P1D'];
    700701// Dummy construct, as properties are completely overridden702parent::__construct(...$raw);
    703704if (isset($sortedArguments['start'])) {
    705$this->setStartDate($sortedArguments['start']);
    706▕         }

Carbon version: 3.2.1

PHP version: 8.3.4

I expected to get:

a new \Carbon\CarbonPeriod instance.

But I actually get:

DatePeriod::__construct() arguments error.

Thanks!

@kylekatarnls
Copy link
Collaborator

Sorry for this regression, I will publish a patch today.

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