← Back to Blog
Magento

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

Sean Breeden September 9, 2022 14 min read
Fatal error: During inheritance of Countable: Uncaught Exception: Deprecated Functionality when upgrading to Magento 2.4.5

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.


About the Author

Sean Breeden is a Full Stack Developer specializing in Mage-OS, Shopify, Magento, PHP, Python, and AI/ML. With years of experience in e-commerce development, he helps businesses leverage technology to create exceptional digital experiences.