Mastodon
"The secret of getting ahead is getting started." --Mark Twain

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: 1821