为什么BING API ReportingClasses.php抛出错误:“命名空间声明语句必须是第一个语句”

I'm working on a Symfony project and we need to integrate the BING api from Microsoft. They supply the following classes to help with the soap calls:

https://code.msdn.microsoft.com/bing/PHP-Classes-for-Bing-Ads-c9762281/sourcecode?fileId=134005&pathId=147923406

When those classes are copied to my vendor folder and then ReportingClasses.php included in my project class, I get the error that the Namespace declaration statement has to be the very first statement in the script.

Looking at the script in my editor, I can clearly see that this condition is met. What gives?

After beating my head against this for a few hours, the only lead I had left was that it was a file encoding issue.

My solution was very simple:

  1. Copy the contents of the file to my clipboard.
  2. Delete the file completely.
  3. Create a new file with the same name in the same location.
  4. Paste the contents into the new file.
  5. Save the file.

Et Voila! Error gone.