How to fix «is_file() expects parameter 1 to be a valid path, string given» on `bin/magento setup:di:compile`?

I have solved it by removing the cache:

rm -rf var/cache var/log var/page_cache var/view_preprocessed