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

Fix fatal error on PHP 8.4 #467

Closed
wants to merge 1 commit into from
Closed

Fix fatal error on PHP 8.4 #467

wants to merge 1 commit into from

Conversation

gersonfs
Copy link

I'm trying to use cakephp 4.x with php 8.4 and but this signature is causing problems.
https://php.watch/versions/8.4/datetime-createFromTimestamp
Fatal error: Declaration of Cake\Chronos\Traits\FactoryTrait::createFromTimestamp(int $timestamp, $tz = null): Cake\Chronos\ChronosInterface must be compatible with DateTimeImmutable::createFromTimestamp(int|float $timestamp): static

I'm trying to use cakephp 4.x with php 8.4 and but this signature is causing problems.
`Fatal error: Declaration of Cake\Chronos\Traits\FactoryTrait::createFromTimestamp(int $timestamp, $tz = null): Cake\Chronos\ChronosInterface must be compatible with DateTimeImmutable::createFromTimestamp(int|float $timestamp): static`
@@ -336,7 +336,8 @@ public static function createFromArray(array $values): ChronosInterface
* @param \DateTimeZone|string|null $tz The DateTimeZone object or timezone name the new instance should use.
* @return static
*/
public static function createFromTimestamp(int $timestamp, $tz = null): ChronosInterface
#[ReturnTypeWillChange]
public static function createFromTimestamp(int|float $timestamp, $tz = null): ChronosInterface
Copy link
Author

Choose a reason for hiding this comment

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

Oops, we have tests for php 7.4, any suggestions on how to maintain compatibility?

@LordSimal
Copy link
Contributor

LordSimal commented Nov 18, 2024

This was only fixed in Chronos v3 as you can see here:
#454

I'd recommend upgrading to CakePHP 5 before trying to get CakePHP 4 running with PHP 8.4

With that you will get Chronos v3 and therefore the fix for PHP 8.4

@gersonfs
Copy link
Author

Ok, I'll have more work but that's it. Thanks

@gersonfs gersonfs closed this Nov 18, 2024
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