Issue
After some recent Eclipse updates and workspaces changes I found some problems with validation of my PHP code in PDT. After re-adding all external libraries for my projects every external class was resolvable, but for PHP base classes like "DateTime" or "Exception" I get an error/annotation "DateTime cannot be resolved to a type". PHP Validation Version is set to 7.1, but even lower settings create the error.
How can I fix this validation problem?
Solution
There are many possible situations here; mine was an quite old project having a broken buildpath configuration. However using the GUI I wasn't able to fix it.
Adding the following line to the .buildpath file in the project folder while eclipse was closed and afterwards restarting eclipse solves the problem:
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
However, additionally if the code uses namespaces, one needs to use \DateTime instead of DateTime, or alternatively, add a 'use DateTime' on top;
(Solution found after digging deeper into comments of other problems using Eclipse PDT does not propose all php functions and https://bugs.eclipse.org/bugs/show_bug.cgi?id=502184)
Answered By - NextThursday
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)