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

Twig: don't autocomplete short forms for object properties/methods #2024

Open
drjayvee opened this issue Oct 26, 2022 · 1 comment
Open

Twig: don't autocomplete short forms for object properties/methods #2024

drjayvee opened this issue Oct 26, 2022 · 1 comment

Comments

@drjayvee
Copy link

Twig supports convenience short forms for properties and methods (see "Implementation" box in docs).

For example,

{# @var user \User #}
{{ user.admin }}

can refer to a property $admin or any of the methods admin(), getAdmin(), isAdmin(), hasAdmin().

The plugin always autocompletes using the short form:
image

This makes it so much harder to refactor properties and methods because

  • the IDE doesn't "know" about calls in templates, so tool-assisted refactoring doesn't cover them
    (this could perhaps be added?)
  • even a manual search across twig templates for "isAdmin" won't find this call

The end result is that unless developers spend significant time diligently checking all templates, bugs will occur after refactoring.

Therefore, I propose that the plugin should autocomplete using the full property or method name, or at the least make this behavior configurable.

@drjayvee
Copy link
Author

drjayvee commented Apr 2, 2024

@Haehnchen did you change this behavior in the latest release? I didn't spot any such change in the plugin's "What's New" tab, but it does work pretty much exactly as proposed here!

Danke sehr.

Nevermind, I was mistaken! The plugin still completes to short-hand.

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

No branches or pull requests

1 participant