After nearly two hours of debugging I have concluded that the best solution to this is to give the file name a different name to the class that it contains. For Example:
Before example.php contains:
<?php
class example {
}
Solution: rename the file to example.class.php (or something like that), or rename the class to example_class (or something like that)
Hope this helps.