Eclipse PDT namespace cannot be resolved to a type

755 Views Asked by At

I worked on my PHP Project for a long time in eclipse oxygen with PDT6.0 and I had no problems. Recently I updated to eclipse 2020-06 and PDT7.2 and now it marks all my namespace-occurences with "cannot be resolved to a type". I use namespaces to declare some constants that will be used elsewhere in the code.

My Folder-Structure looks similar to that:

Project/index.php (requires constants/Namespace.php and uses constants declared in namespace)

Project/constants/Namespace.php (contains namespace declaration)

Example:

constants/Namespace.php:

<?php
namespace Test;
const TEST_CONSTANT = "test";
?>

index.php:

<?php
require "constants/Namespace.php";
echo Test\TEST_CONSTANT;    // This will be marked as error
?>

Code execution works fine as expected.

At declaration of the namespace, eclipse also shows me a warning that the namespace-name does not match the expected name similar to the folder structure. But, as I also already read in other threads, it shouldn't be a problem to not completely match that namespace-convention.

My .buildpath:

<?xml version="1.0" encoding="UTF-8"?>
<buildpath>
    <buildpathentry kind="src" path=""/>
    <buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
</buildpath>

Any suggestions on how to fix or at least hide that specific error in eclipse? Or do I have to use php namespaces in a completely different way (Im relatively new to namespaces)? Thanks in advance!

0

There are 0 best solutions below