Magento 2 Upgrade Error: ltrim() Expects String – Solution

magento-2.1.9magento2

Getting following error while compilation using this command : php bin/magento setup:di:compile after upgrade Magento 2.1.7 to 2.1.9 check below error for more information :

Warning: ltrim() expects parameter 1 to be string, array given in
/MagentoRoot/setup/src/Magento/Setup/Module/Di/Compiler/Config/Chain/BackslashTrim.php
on line 61

Best Answer

I came across this and turned out to be an issue when you run integration tests at some point before running bin/magento setup:di:compile.

Integration tests generate some test modules in app/code/Magento which are then picked up by the setup:di:compile command. enter image description here I fixed this by removing the Magento folder from app/code.

Related Topic