I have run into this error while running a setup:di:compile in Magento 2.
The error was caused by empty php files in my extension. I created a bunch of files to get the structure in place, but hadn’t filled out all of the files yet.
Adding even an opening php tag and nothing else allowed the setup:di:compile to complete.