NotionCommotion Posted January 16, 2022 Share Posted January 16, 2022 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 Quote Link to comment https://forums.phpfreaks.com/topic/314420-case-of-deprecated-warning-with-php-81-and-apcuiterator/ Share on other sites More sharing options...
requinix Posted January 17, 2022 Share Posted January 17, 2022 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. Quote Link to comment https://forums.phpfreaks.com/topic/314420-case-of-deprecated-warning-with-php-81-and-apcuiterator/#findComment-1593383 Share on other sites More sharing options...
NotionCommotion Posted January 17, 2022 Author Share Posted January 17, 2022 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 Quote Link to comment https://forums.phpfreaks.com/topic/314420-case-of-deprecated-warning-with-php-81-and-apcuiterator/#findComment-1593394 Share on other sites More sharing options...
requinix Posted January 17, 2022 Share Posted January 17, 2022 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. Quote Link to comment https://forums.phpfreaks.com/topic/314420-case-of-deprecated-warning-with-php-81-and-apcuiterator/#findComment-1593395 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.