"Saruman believes it is only great power that can hold evil in check, but that is not what I have found. I found it is the small everyday deeds of ordinary folk that keep the darkness at bay. Small acts of kindness and love." --Gandalf

Fatal error: During inheritance of Countable: Uncaught Exception: Deprecated Functionality when upgrading to Magento 2.4.5

Saturday, September 10th, 2022

If you get the following error:

Fatal error: During inheritance of Countable: Uncaught Exception: Deprecated Functionality: Return type of Composer\Repository\ArrayRepository::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in vendor/composer/composer/src/Composer/Repository/ArrayRepository.php on line 277 in vendor/magento/framework/App/ErrorHandler.php:62

Then you will need to make a couple of core edits in vendor to proceed after running composer install.

There needs to be two edits inside the /vendor/ folder to add #[\ReturnTypeWillChange] that fixes sites that are upgraded from 2.3.x and <=2.4.3.

The first file vendor/composer/composer/src/Composer/Repository/ArrayRepository.php on line 180.

The second is vendor/composer/composer/src/Composer/Repository/CompositeRepository.php on line 277.

Your files and line numbers may vary, so I recommend creating .patch files that can be run after each composer install.

After the return type will change directive is set, everything can proceed as normal.

Views: 1072