Search code examples
phpeclipse-pdt

Eclipse for PHP IDE adds some "use const False\MyClass\true;" when organizing import


When using the shortcut Ctrl+Shift+O on my Eclipse for PHP IDE (Version: 2022-09 4.25.0), I have a use line which appears at the top of my class:

use const False\MyClass\true;

The logs show the error Undefined constant 'False\MyClass\true'

It only appears when using true boolean value in the class code. Here is an example of code triggering the import use statement :

public function addBreadcrumb(string $label, string $route, array $parameters = [ ]) {
    $this->breadcrumb[] = [ 
        'label' => $label,
        'url' => AppContext::url($route, $parameters)
    ];
    $this->showBreadcrumb(true);
}

public function showBreadcrumb(bool $showBreadcrumb) {
    $this->showBreadcrumb = $showBreadcrumb;
}

Can someone help on this, please ?

Just googled the error but did not found anything.


Solution

  • I have found the issue. I was related to my IDE which was unable to perform Validation of the code at the launch of the workspace. Since I have fixed this Validation error, I was able to correctly load the workspace and the shortcut is now working perfectly. The Validation error occured because I was using 2 different autoloaders on my project : one from Composer (vendor) and the other one was a custom one for my internal librairies.