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

Add more coding standard rules #4474

Merged
merged 1 commit into from
Nov 30, 2024
Merged

Conversation

fabpot
Copy link
Contributor

@fabpot fabpot commented Nov 25, 2024

No description provided.

@stof
Copy link
Member

stof commented Nov 25, 2024

IIRC, there was a discussion on the Symfony repo reporting that Twig coding standards don't define the spacing rule around the = operator in macro argument declarations and around the = or : separators for named arguments.
Maybe those could be defined as well.

@VincentLanglet
Copy link
Contributor

IIRC, there was a discussion on the Symfony repo reporting that Twig coding standards don't define the spacing rule around the = operator in macro argument declarations and around the = or : separators for named arguments. Maybe those could be defined as well.

For the record, currently Twig-CS-Fixer consider it should be

foo(name_arg=42) // no space at all

and

foo(name_args: 42) // one space after

cf
https://github.com/VincentLanglet/Twig-CS-Fixer/blob/main/src/Rules/Function/NamedArgumentSpacingRule.php

@fabpot
Copy link
Contributor Author

fabpot commented Nov 29, 2024

Updated

Copy link
Contributor

@VincentLanglet VincentLanglet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll work on implementing the missing rule in Twig-CS-Fixer :)

@fabpot fabpot merged commit f0066c8 into twigphp:3.x Nov 30, 2024
49 of 50 checks passed
@fabpot fabpot deleted the snake-case-cs-doc branch November 30, 2024 08:31

* Use snake case for all function/filter/test names:
* Put exactly one space after the ``:`` sign in macro argument declarations:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabpot It works too for named arguments

{{ html_input(class_name: 'pwd') }}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I just noticed, but I don't think this macro definition is a valid one.

{% macro html_input(class: "input") %}

@@ -88,21 +88,34 @@ standards:
[1, 2, 3]
{'name': 'Fabien'}

* Use snake case for all variable names (provided by the application and
created in templates):
* Do not put any spaces before and after ``=`` in macro argument declarations:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works too for named arguments

{{ html_input(class_name='pwd') }}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wrong for macro, seems like it should be = cf https://twig.symfony.com/doc/3.x/tags/macro.html

@VincentLanglet
Copy link
Contributor

I opened #4488

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

Successfully merging this pull request may close these issues.

3 participants