pdt icon indicating copy to clipboard operation
pdt copied to clipboard

The declared namespace Foo does not match src actually never matches with my projects.

Open pounard opened this issue 4 years ago • 5 comments

Since 2020-06 version, the validation warning/notice such as The declared namespace "App\Controller\Gestion" does not match the expected namespace "src\Controller\Gestion" is very annoying.

It's an extremely powerful feature and I would love to use it, yet it seems you cannot tell PDT which namespace to match in which folder (I might be wrong). I don't know how it deduces it, but it actually never matches real PSR-4 or PSR-0 configuration from my composer.json file, so considers that ALL my PHP files are at an invalid location.

Version is:

Eclipse IDE for PHP Developers (includes Incubating components)
Version: 2020-06 (4.16.0)
Build id: 20200615-1200

I have quite a few addons installed, including PDT Extensions, I in that regard, it might be one of them messing up, but I'm not sure.

  • OS: Running ArchLinux, uname output: Linux guinevere 5.7.6-arch1-1 #1 SMP PREEMPT Thu, 25 Jun 2020 00:14:47 +0000 x86_64 GNU/Linux

pounard avatar Jul 03 '20 07:07 pounard

If you enable composer support for your project (right click -> configure -> add composer support) it should read it correctly.

But be careful, by default composer will try to rewrite your buildpath

zulus avatar Jul 10 '20 11:07 zulus

Yes indeed, it works now, thanks ! Still I'd add a few thoughts here:

  • Why isn't the composer support automatically enabled if a composer.json file is found?
  • A lot of projects I'm working on, composer.json file is in a sub-directory (i.e. /app/composer.json for example) will it still work?
  • It should probably be configurable in the project properties when composer.json file is absent or composer support isn't enabled?
  • The feature should probably be in a disabled state until configured.

pounard avatar Jul 10 '20 12:07 pounard

Composer was separate community project that was transferred to us couple years ago. Some auto-discovery works during import/create project but not always. There is a plan to finally build one simple project creation/update wizard but after I finish new model without some DLTK limitations.

As for now composer support have couple limitations:

  1. composer.json have to be in root directory
  2. composer editor always open with name as project, so if you open something from vendor you might be confused
  3. problems with synchronisation between buildpath update / workspace refresh / composer.json / composer.lock
  4. have own php launch implementation that sometimes giving me crazy

As for now I personally use it mostly for correct "new class" , "validation" and buildpath refresh. I personally not use our powerful composer.json editor in my daily work ;)

Any ideas welcome, but for now we have only 2 committers and a lot of work to do.

zulus avatar Jul 10 '20 13:07 zulus

Any ideas welcome, but for now we have only 2 committers and a lot of work to do.

Yeah I can imagine that 2 is often not enough ! Long time I didn't wrote any Java code, 10 years actually, maybe someday I'll try. I'm impressed with PDT quality knowing that you're not much people maintaining it, thanks for all you do.

pounard avatar Jul 11 '20 14:07 pounard

If this still not work and You project has such structure

|- smt
|- code
  |-src
    |-Entity
    |-etc...
  |-composer.json
|- docker

Right click on code folder in project explorer tab and select: Use as source folder

rtwent avatar Nov 26 '23 14:11 rtwent