Uncaught TypeError: Argument 1 passed to [...] must be an instance of

I found that in the LN module 2 different namespace declarations was used: Layerednavigation and LayeredNavigation. When code is compiled all di class arguments was stored in the array where the class name with namespace was used as key (string).

log config

The problem is in the autoloader: it can not find the files because array keys are case sensitive in the php and Layerednavigation is different from LayeredNavigation. I don't know why, but Theme developers used 2 different words. Possibly they just do not test it with compiled version.

I have renamed all namespaces and filenames to the LayeredNavigation (camel-case) and all works fine.

Step-by-step actions:

  1. Change filenames and class names (including namespaces, block names in the layout, etc.) from the Layerednavigation to the LayeredNavigation
  2. Reinstall module
  3. Recompile code

PS: This question is not off-topic (third party module) because you can change the Layerednavigation to another name.


The following sequence of actions usually help me to resolve such errors:

  • bin/magento cache:flush
  • remove var/generation and var/di
  • bin/magento setup:di:compile