PHPSocialNetwork / phpfastcache

A high-performance backend cache system. It is intended for use in speeding up dynamic web applications by alleviating database load. Well implemented, it can drops the database load to almost nothing, yielding faster page load times for users, better resource utilization. It is simple yet powerful.
https://www.phpfastcache.com
MIT License
2.38k stars 451 forks source link

Issue with PHP 8.1 and PhpFastCache 8 - Fatal error: During inheritance of ArrayAccess #846

Closed Awilum closed 2 years ago

Awilum commented 2 years ago

Configuration

PhpFastCache version: 8.0.8 PhpFastCache API version: 3.0.0 PHP version: 8.1 Operating system: macOS (but it is affect any)

Сan't run PhpFastCache on PHP 8.1

Fatal error: During inheritance of ArrayAccess: Uncaught Whoops\Exception\ErrorException: Return type of Phpfastcache\Util\ArrayObject::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/runner/work/flextype/flextype/vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Util/ArrayObject.php:110

possible solution is to add #[\ReturnTypeWillChange] see example: https://github.com/glowyphp/arrays/blob/dev/src/Arrays.php#L1446

Geolim4 commented 2 years ago

Hello,

thanks for the report, can you confirm that the attribute fix the problem ?

The V8 is only PHP >=7.3 compatible so I can't used mixed type.

Please note that the V8 has not been tested with PHP 8.1 .

Geolim4 commented 2 years ago

Please also note that the V9 is fully compatible with PHP 8.1 and the ArrayAccess implementation has been replaced by lighter mechanism.

Awilum commented 2 years ago

@Geolim4 I can't check it on my local machine because I don't have PHP 8.1, but GitHub Actions failed for PHP 8.1 https://github.com/flextype/flextype/runs/4694968427?check_suite_focus=true because of

Fatal error: During inheritance of ArrayAccess: Uncaught Whoops\Exception\ErrorException: Return type of Phpfastcache\Util\ArrayObject::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/runner/work/flextype/flextype/vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Util/ArrayObject.php:110

Previously I had fixed this issue for another package like this https://github.com/glowyphp/arrays/blob/dev/src/Arrays.php#L1446 as it says in the recommendation

Geolim4 commented 2 years ago

Ok, I'll push a fix asap on the V8.1.

Can you tell me if the V9 is working well with PHP 8.1 ? Travis build does not yet offers PHP 8.1.

Awilum commented 2 years ago

@Geolim4, at the moment, I'm not able to test my project with V9 on PHP 8.1 because some part of the project depends on V8 and just updating the engine from V8 to V9 isn't simple. But it would be great if V8 would work on PHP 8.1

Geolim4 commented 2 years ago

Hello

Thank for your report, I pushed a fix and released 8.1.0 which contains some other fixes as well.

Cheers, Georges