Magento 2 Compile Issue "No tokens were provided"
This blog post was published more than one year ago and might be outdated!
· One min read
If you run the command:
bin/magento setup:di:compile
and run into this error:
No tokens were provided
this may be your solution:
Seems you have an empty file somewhere which gets parsed by the \Magento\Setup\Module\Di\Code\Reader\ClassesScanner. The class uses the PHP token_get_all() method (in some Zend components). The exception is thrown, if the method does not return any value, which is the case of an empty file. Check your own code or your third party modules for emtpy files with this command:
find /path/to/dest -type f -empty
Remove the files, and the compilation should succeed.