dynamics-webapi-toolkit icon indicating copy to clipboard operation
dynamics-webapi-toolkit copied to clipboard

PHP 8.0 compatibility

Open SpartakusMd opened this issue 3 years ago • 6 comments

Last commit was to have compatibility with PSR cache & log versions ^3.0. They require PHP >8.0. They also introduced typed parameters and return types. This PR comes with fixing the crashes due to incompatibility

Fatal error:  Declaration of AlexaCRM\Cache\NullAdapter: :getItem($key) must be compatible with Psr\Cache\CacheItemPoolInterface: :getItem(string $key): Psr\Cache\CacheItemInterface in /srv/app/vendor/alexacrm/dynamics-webapi-toolkit/src/Cache/NullAdapter.php on line 48

SpartakusMd avatar Sep 12 '22 07:09 SpartakusMd

A suggestion I would make is to replace the comments in NullAdapter and NullCacheItem with @inheritDoc in order to use the phpdocs from the interface itself. WDYT?

SpartakusMd avatar Sep 12 '22 07:09 SpartakusMd

Hi @georged, in that case, the PR #82 needs to be reverted as the src/Cache/NullAdapter.php and src/Cache/NullCacheItem.php are not compatible with psr/cache v3 (see the PR description with the error).

I would suggest reverting to psr/cache ^1.0 || ^2.0 for version 2.x and use psr/cache ^2.0 || ^3.0 + PHP ^8.0 for version 3.x.

What do you think on this?

Note: I'm using the library on PHP 8.1 without issues :)

SpartakusMd avatar Sep 20 '22 15:09 SpartakusMd

@SpartakusMd yes, already had people complaining so reverted this one.

I would suggest reverting to psr/cache ^1.0 || ^2.0 for version 2.x and use psr/cache ^2.0 || ^3.0 + PHP ^8.0 for version 3.x.

That's a great idea - can you create a PR for that? I won't be able to get to it for a few days at least.

georged avatar Sep 28 '22 08:09 georged

Hey @georged, I rebased the code on master. This PR contains drops support for PHP 7.4 and requires PHP 8.0. Also drops psr/cache: ^1.0 and psr/log: ^1.0 support.

It can be merged and released as version 3 to not break the code for other users.

SpartakusMd avatar Sep 28 '22 09:09 SpartakusMd

Hey @georged. Did you have time to look at this?

SpartakusMd avatar Oct 11 '22 11:10 SpartakusMd

@SpartakusMd we haven't merged yet but we did decide to create a separate branch min-php8.0 for php 8+ and keep 7.4 as is. The new branch will have all the changes to support psr 3. @wizardist can you take a look how best to merge this pull request into the new branch?

georged avatar Oct 11 '22 12:10 georged

Hey @georged @wizardist any plans on this?

SpartakusMd avatar Nov 18 '22 14:11 SpartakusMd

@SpartakusMd yes there are :)

Did you check if php 80 branch is more suitable for this?

georged avatar Nov 18 '22 23:11 georged

Hi @georged, the branch can run on php 8.0 but not on php 8.1 where return type hints were added. It will crash due to widening the return types in the implementation of cache 3.0.

I would suggest merging this branch into the php 8 one. WDYT?

SpartakusMd avatar Nov 19 '22 09:11 SpartakusMd

Your commit removes 7.4 from what I can see. We can't do that as we need this for backward compatibility. @wizardist do you think we can bring relevant changes to v8 branch?

georged avatar Nov 20 '22 07:11 georged

Hello @georged, @wizardist. I see there was a 4.0.0-alpha version released for which minimum php version is 8. Unfortunately there is no php8 branch anymore as I wanted to move the pr to it. Could you create it back so that I would adjust my PR?

SpartakusMd avatar Dec 29 '22 14:12 SpartakusMd

@SpartakusMd I've [re]-created 4.x branch to support at least 8.0. Support for 7.4 dropped in that branch.

georged avatar Dec 30 '22 02:12 georged

@georged I have updated the PR to target that branch. If the changes are ok, could you merge it and tag it?

SpartakusMd avatar Dec 30 '22 10:12 SpartakusMd

Greetings! Loving the package, but it's broken with PHP8+. Is anyone going to merge these changes or should I just make my own fork?

paclw-cory avatar Jan 20 '23 20:01 paclw-cory

@paclw-cory we've merged now, give it a shot!

georged avatar Jan 21 '23 09:01 georged