Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds falsy use const False\MyClass\true; statements when using phpcs #256

Open
cracksalad opened this issue Oct 16, 2023 · 2 comments
Open
Labels

Comments

@cracksalad
Copy link

cracksalad commented Oct 16, 2023

Describe the bug

When the setting PHP > Editor > Save Actions > Organize use statements is on and you use true in a namespaced class, eclipse/PDT will add a use statement use const False\MyClass\true; on save. This use statement can not be resolved and thereby effectivly kills the class.

Describe the eclipse environment

Tested in eclipse 2023-06 and 2023-09. PDT 8.0 and 8.1. My project uses squizlabs/php_codesniffer as a composer dependency. If I uninstall it, the falsy use statements are gone!

Describe your system

  • OS Windows
  • Version 10
  • PHP Version 8.2

To Reproduce

  1. Use PHP_CodeSniffer as a composer dependency in your project
  2. Switch the setting "PHP > Editor > Save Actions > Organize use statements" on
  3. Create a namespaced class and use the constant true in it
  4. Hit save and observe the (namespace) use statements

Expected behavior

use statements should generally be added, but not if they are not needed and can not be resolved.

Workaround

  1. Disable this setting (I do not want to, I like it)
  2. Use the global search (magnifier icon) to replace those statements (using regex) use const False\\MyClass\\true;\n with empty string - everytime you change a file.
@cracksalad cracksalad added the bug label Oct 16, 2023
@cracksalad cracksalad changed the title Adds falsy use const False\MyClass\true; statements Adds falsy use const False\MyClass\true; statements when using phpcs Oct 16, 2023
@pounard
Copy link

pounard commented Oct 16, 2023

It happens a lot to me, but it's very hard to reproduce. Mostly it happens when I hit Ctrl+S then Ctrl+Shift+O while save is unfinished, or when the file is being validated after some change. It's quite random, arbitrary, it happens in many files.

@zulus
Copy link
Member

zulus commented Oct 17, 2023

yeah, not only here. Auto generated getter/setter completely ignore FQN's . Probably due same reason

I'll take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants