Community
Participate
Working Groups
Consider the following example, consisting of an interface, a trait and a class: +-- Interface ----------------------------+ | interface I | | { | | public function makeStuff(): void; | | } | +-----------------------------------------+ +-- Trait --------------------------------+ | namespace Traits; | | | | trait StuffMaker | | { | | public function makeStuff(): void | | { | | //code | | } | | } | +-----------------------------------------+ +-- Class --------------------------------+ | use stdClass as StuffMaker; | | | | class A implements I | | { | | use Traits\StuffMaker; | | } | +-----------------------------------------+ The above is syntactically correct, without any reference conflicts of any kind, and executes without a problem, however the PDT validator reports a problem in class A claiming: "The type A must implement the inherited abstract method I::makeStuff()" This error disappears if I either comment out the "use stdClass as StuffMaker" line, or if I change the alias itself, such as to "use stdClass as FooMaker". It seems that for some reason the validator gets confused by the name of the trait being the same as the name given in the alias, although "StuffMaker" and "Traits\StuffMaker" reference completely different things. This seems to happen at least since the Oxygen version of Eclipse(the oldest version I tested, and where I first noticed the problem), as well in the newest nightly version, both in Linux (Ubuntu) and Windows 10.
New Gerrit change created: https://git.eclipse.org/r/146105
Gerrit change https://git.eclipse.org/r/146105 was merged to [master]. Commit: http://git.eclipse.org/c/pdt/org.eclipse.pdt.git/commit/?id=cb53496d0067e723284c16ec015a09d2527ad8f0
Fixed. Claudio, could you give a try to upcoming PDT nightly version to confirm me that your problems are solved? Thank you! Thierry.
Yes, just updated, it's been fixed. :) Although, now there seems to be another problem: when using the PHP 7.2 validator, it seems to not detect the existence of some global namespace interfaces and classes, such as Countable, JsonSerializable and ReflectionClass, with the "The import ReflectionClass cannot be resolved" error, although in the Core API directory set up by PDT all the files and declarations are there, none of them are missing, which is strange. However other global interfaces such as ArrayAccess and classes such as Exception are detected without issues. Changing to the PHP 7.3 validator however, works flawlessly. Changing back to the PHP 7.2, the issues appear again, and changing back to PHP 7.3, the issues disappear, so it's always reproducible on my end at least, even across different projects. Unfortunately, I cannot remember at 100% if it was already this way before or only after this specific update, so I cannot accurately pinpoint when this started to happen, so I may try to reproduce the problem in more detail later, and create another separate bug report for it. Thank you very much! :)
Hi Claudio, yes, it's better to create a separate bug report, so we can continue our discussion there. For me it's another unrelated problem, it would be nice if you could create a little demo project to reproduce the problem. For me, validation problems can often be solved by doing Project -> Clean... and rebuilding the problematic project. Have you tried that? Is your "Project -> Build Automatically" option also checked? Thierry.
And please make also some tests with your older eclipse oxygen version (so without this patch applied), to confirm that your "php version switching bug" was already present.
Yes, Project -> Clean is actually something I always do after any major change, from updates in Eclipse to after installing or updating PHP dependencies (through Composer), and in a few other situations, which solves most problems from the get-go. Sometimes I also press F5 before a Clean so that everything is refreshed and synced up with what's actually saved on disk. And yes, my projects are set to build automatically as well. In the Oxygen version I am sure it's OK, but the PDT version itself is quite outdated I believe, which after confirming I can update to the latest nightly corresponding to Oxygen to check if the problem appears. Since it also sits in a different machine with a different OS, I will attempt to download and test the newer Eclipse version there, but without the nightly at first to check if the problem was already present before the nightly at least. Either way, I will indeed investigate the problem in more detail to try to provide more specific information in a different bug report, that is, if this doesn't end up being simply a problem on my own end. :) Thank you. :)