givewp
givewp copied to clipboard
GiveWP should support PHP 8.1 internal method return types
Details
Using PHP 8.1 with GiveWP will notify of internal method return type deprecation notices defined here:
https://php.watch/versions/8.1/internal-method-return-types#ReturnTypeWillChange
The official workaround for still support php 5.6 is to add the #[\ReturnTypeWillChange]
attribute mentioned here.
Once we're able to require at least 7.1 we can simply update the existing child classes and interface implementations to be compatible with the parent method's return type.
The doc also mentions that php 9 will throw a fatal error:
Note that this is merely a temporary workaround; From PHP 9.0, all of such instances will result in a fatal error.
Additional Context
[22-Feb-2022 22:00:03 UTC] PHP Deprecated: Return type of Give\Container\Container::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jonwaldstein/Sites/givewp/wp-content/plugins/givewp/src/Container/Container.php on line 1164
[22-Feb-2022 22:00:03 UTC] PHP Deprecated: Return type of Give\Container\Container::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jonwaldstein/Sites/givewp/wp-content/plugins/givewp/src/Container/Container.php on line 1176
[22-Feb-2022 22:00:03 UTC] PHP Deprecated: Return type of Give\Container\Container::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jonwaldstein/Sites/givewp/wp-content/plugins/givewp/src/Container/Container.php on line 1189
[22-Feb-2022 22:00:03 UTC] PHP Deprecated: Return type of Give\Container\Container::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jonwaldstein/Sites/givewp/wp-content/plugins/givewp/src/Container/Container.php on line 1206
[22-Feb-2022 22:00:03 UTC] PHP Deprecated: Return type of Give\Framework\PaymentGateways\Contracts\PaymentGatewaysIterator::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jonwaldstein/Sites/givewp/wp-content/plugins/givewp/src/Framework/PaymentGateways/Contracts/PaymentGatewaysIterator.php on line 15
[22-Feb-2022 22:00:03 UTC] PHP Deprecated: Return type of Give\Framework\PaymentGateways\Contracts\PaymentGatewaysIterator::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jonwaldstein/Sites/givewp/wp-content/plugins/givewp/src/Framework/PaymentGateways/Contracts/PaymentGatewaysIterator.php on line 23
[22-Feb-2022 22:00:03 UTC] PHP Deprecated: Return type of Give\Framework\PaymentGateways\Contracts\PaymentGatewaysIterator::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jonwaldstein/Sites/givewp/wp-content/plugins/givewp/src/Framework/PaymentGateways/Contracts/PaymentGatewaysIterator.php on line 32
[22-Feb-2022 22:00:03 UTC] PHP Deprecated: Return type of Give\Framework\PaymentGateways\Contracts\PaymentGatewaysIterator::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jonwaldstein/Sites/givewp/wp-content/plugins/givewp/src/Framework/PaymentGateways/Contracts/PaymentGatewaysIterator.php on line 41
[22-Feb-2022 22:00:03 UTC] PHP Deprecated: Return type of Give\Framework\PaymentGateways\Contracts\PaymentGatewaysIterator::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jonwaldstein/Sites/givewp/wp-content/plugins/givewp/src/Framework/PaymentGateways/Contracts/PaymentGatewaysIterator.php on line 49
[22-Feb-2022 22:00:03 UTC] PHP Deprecated: Return type of Give\Framework\FieldsAPI\Contracts\Node::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jonwaldstein/Sites/givewp/wp-content/plugins/givewp/src/Framework/FieldsAPI/Contracts/Node.php on line 27
Acceptance Criteria
- [ ] When using PHP 8.1, Internal PHP method return type deprecation notices are suppressed.
Good notes, Jon. Thanks! PHP 9 is what makes me nervous. There are a number of deprecations that will be removed in 9. I think WordPress is going to start getting stuck in old versions of PHP.
This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 14 additional days.
This is still worth a revisit.
@jonwaldstein @JoshuaHungDinh I'm getting this with the latest version of give-form-field-manager
on 8.1 - since that plugin isn't open-source, what's the best way to report that?
@G-Rath thank you, you can submit this to https://feedback.givewp.com/