Jump to content

Recommended Posts

I upgraded a docker-compose package to use PHP 8.1, and the application still works but I get the following warnings.
 

$ docker-compose exec php     php -v
PHP Deprecated:  Return type of APCUIterator::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0

Deprecated: Return type of APCUIterator::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0
PHP Deprecated:  Return type of APCUIterator::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0

Deprecated: Return type of APCUIterator::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0
PHP Deprecated:  Return type of APCUIterator::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0

Deprecated: Return type of APCUIterator::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0
PHP Deprecated:  Return type of APCUIterator::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0

Deprecated: Return type of APCUIterator::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0
PHP Deprecated:  Return type of APCUIterator::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0

Deprecated: Return type of APCUIterator::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0
PHP 8.1.1 (cli) (built: Dec 18 2021 01:38:53) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.1, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.1, Copyright (c), by Zend Technologies

Looking for the cause, I searched for "APCUIterator" and found very few occurrences.   No return declaration on APCUIterator in the two PHP files and I don't think they are the cause.   The binary files I think might be the issue as I do see "class APCUIterator implements Iterator{...}" but hard to tell as they are binary files and I don't really know what they do.  Maybe that PHP says "Unknown on line 0"?  Any suggestions?

If the warning is caused by script maintained by others and I just want to wait for them to update it, is it possible to silence just this specific warning and ideally just for the specific files?

$ grep -inr . -eAPCUIterator
./api/vendor/symfony/cache/Adapter/ApcuAdapter.php:97:        return isset($namespace[0]) && class_exists(\APCuIterator::class, false) && ('cli' !== \PHP_SAPI || filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN))
./api/vendor/symfony/cache/Adapter/ApcuAdapter.php:98:            ? apcu_delete(new \APCuIterator(sprintf('/^%s/', preg_quote($namespace, '/')), \APC_ITER_KEY))
Binary file ./api/vendor/phpstan/phpstan/phpstan.phar matches
Binary file ./api/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar matches

 

9 hours ago, requinix said:

APCUIterator is part of the apcu PECL extension. According to the changelog, you need to have version 5.1.21+ for PHP 8.1 support.

Thanks requinix.  I was previously using 5.1.19 and after upgrading to 5..1.21, no errors.

Just curious but do you know why PHP reported "Unknown on line 0"?

PHP Deprecated:  Return type of APCUIterator::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0

 

6 minutes ago, NotionCommotion said:

Just curious but do you know why PHP reported "Unknown on line 0"?

That would be a PHP source code file and line number, but the error happened on APCUIterator::current which is internal code so there is no file or line number. But errors do need to report some location, thus that.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.