timber icon indicating copy to clipboard operation
timber copied to clipboard

PHP8.1 | Deprecated: Return type compatibility

Open rubas opened this issue 3 years ago • 11 comments

With PHP 8.1...

Deprecated: Return type of Timber\QueryIterator::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in vendor/timber/timber/lib/QueryIterator.php on line 137

Deprecated: Return type of Timber\QueryIterator::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in vendor/timber/timber/lib/QueryIterator.php on line 150

Deprecated: Return type of Timber\QueryIterator::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in vendor/timber/timber/lib/QueryIterator.php on line 156

Deprecated: Return type of Timber\QueryIterator::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in / vendor/timber/timber/lib/QueryIterator.php on line 133

Deprecated: Return type of Timber\QueryIterator::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in vendor/timber/timber/lib/QueryIterator.php on line 152

Deprecated: Return type of Timber\QueryIterator::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in vendor/timber/timber/lib/QueryIterator.php on line 202

Deprecated: Return type of Timber\PostsIterator::current() should either be compatible with ArrayIterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in vendor/timber/timber/lib/PostsIterator.php on line 12

What version of WordPress, PHP and Timber are you using?

PHP 8.1, Timber 1.19.1

How did you install Timber?

Composer

rubas avatar Feb 22 '22 09:02 rubas

composer.json php version also needs to be bumped to allow php8

trsteel88 avatar Mar 17 '22 05:03 trsteel88

@jarednova is there any existing PR's to allow php8.1? This is blocking us from upgrading a few projects via composer.

trsteel88 avatar Mar 23 '22 04:03 trsteel88

Not sure there's some plan to support PHP 8.1 in Timber 1.x and I'm pretty sure there won't be any. It will require extra work/time we will preferably put in 2.x that is around the corner.

I'm already using 2.x on some production sites. Depending on the features you use, It's pretty stable enough and has support for PHP 8.0 (and 8.1 even there are still discussions over this).

nlemoine avatar Mar 28 '22 21:03 nlemoine

Issue is we have quite a few sites using 1 and there is quiet a lot of work involved to upgrade all of them.

As far as I can see Timber isn't having any issues in php8. Are there bugs you are aware of @nlemoine

trsteel88 avatar Mar 28 '22 23:03 trsteel88

I'm already using 2.x on some production sites. Depending on the features you use, It's pretty stable enough and has support for PHP 8.0 (and 8.1 even there are still discussions over this).

hey @nlemoine, which release / branch / tag are you getting v2 from? is it advised to use the official alpha release or can we stay updated directly from the latest branch commit?

thank you for the advice!

yesh avatar Apr 12 '22 08:04 yesh

@nlemoine how far is v2 coming out of alpha? We can't use v2 while it's in alpha and we're stuck on php7 if Timber v1 doesn't support php 8.

trsteel88 avatar May 13 '22 02:05 trsteel88

@trsteel88 I have no view on the release schedule or what's left to do. Maybe @gchtr or @jarednova could provide you more details.

nlemoine avatar May 19 '22 19:05 nlemoine

@trsteel88 we continue to move through as quickly as possible. Unfortunately, life, kids, work and everything else can get in the way of the open source time I (wish!) I had. Based on the progress this week though, you can expect at least a fresh alpha release so we can keep making progress!

jarednova avatar Jun 21 '22 15:06 jarednova

A new alpha release is now published:

https://github.com/timber/timber/releases/tag/2.0.0-alpha.5

Expect another one soon once we merge #2592

jarednova avatar Jun 22 '22 20:06 jarednova

@jarednova there really needs to be updates to the 1.x release for PHP 8.0 at the very least. PHP 7.4 is EOL as of this coming November. If there can't be a release of 2.x well in advance of the EOL then we are putting all of our sites at risk as PHP 7.4 will receive no security updates.

timnolte avatar Aug 20 '22 03:08 timnolte

@jarednova there really needs to be updates to the 1.x release for PHP 8.0 at the very least. PHP 7.4 is EOL as of this coming November. If there can't be a release of 2.x well in advance of the EOL then we are putting all of our sites at risk as PHP 7.4 will receive no security updates.

I agree, at this stage we will be looking to fork v1 and upgrade it. There doesn't seem to be an appetite for it to be completed within this repository.

trsteel88 avatar Aug 20 '22 07:08 trsteel88

There is now a pull request to add php 8.1 compatibility to Timber 1: https://github.com/timber/timber/pull/2640

@jarednova and @nlemoine is there anything we can do to help with this merge request?

idflood avatar Oct 11 '22 12:10 idflood

It will be there soon: https://github.com/timber/timber/pull/2638

Timber 1.x will be supporting PHP 8.0/8.1 almost as soon as the PR above is merged. We're just missing some final approval from @jarednova or @palmiak

nlemoine avatar Oct 11 '22 12:10 nlemoine

We just released a new version 1.21.0 that adds support for PHP 8.0 and 8.1: https://github.com/timber/timber/releases/tag/1.21.0.

It will soon be published to the WordPress plugin repository as well.

gchtr avatar Oct 12 '22 06:10 gchtr

hi @gchtr, do we have any information when the new version will be available on Wordpress plugin repository?

antymoro avatar Oct 20 '22 14:10 antymoro

Please be reticent with releasing to the Wordpress repo. This will trigger a lot of auto updates, and breaking sites while these two bugs are open:

https://github.com/timber/timber/issues/2655 https://github.com/timber/timber/issues/2654

rmens avatar Oct 20 '22 14:10 rmens

Using the latest 1.22.1 version of Timber (in plugin version) + PHP 8.2, I'm still experiencing: Deprecated: Return type of Twig\Node\Node::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/plugins/timber-library/vendor/twig/twig/src/Node/Node.php

It seems related to the bundled Twig 1.x inside vendor/.

Using composer, it works as expected.

drzraf avatar Apr 12 '23 14:04 drzraf

Timber 1.x only officially supports PHP 8.0, not 8.1 or newer. I hope 2.x is out by the time PHP 8.0 is no longer supported.

rmens avatar Apr 12 '23 15:04 rmens