Skip to content

Universal/TypeSeparatorSpacing: add support for PHP 8.2 DNF types #329

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

Merged

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Apr 20, 2025

PHP 8.2 introduced DNF types, which use parenthesis.

This commit adds support to the Universal.Operators.TypeSeparatorSpacing sniff to also check the spacing around the parenthesis for DNF types.

Notes:

  • Allows for a new line before the start of a type for function parameters.
  • Expects one space before the type operator if the type starts with a DNF open parenthesis.
  • Expects one space after the type operator if the type ends on a DNF close parenthesis.
  • Includes protection against throwing two errors for the same issue, like when a DNF close parenthesis if followed by a union type operator and there is whitespace between these.

Includes tests.
Includes updated documentation.

@jrfnl jrfnl added this to the 1.3.0 milestone Apr 20, 2025
@jrfnl jrfnl force-pushed the feature/universal-typeoperatorspacing-support-dnf-types branch from f2c15de to a282adb Compare April 20, 2025 22:22
PHP 8.2 introduced DNF types, which use parenthesis.

This commit adds support to the `Universal.Operators.TypeSeparatorSpacing` sniff to also check the spacing around the parenthesis for DNF types.

Notes:
* Allows for a new line before the start of a type for function parameters.
* Expects one space before the type operator if the type starts with a DNF open parenthesis.
* Expects one space after the type operator if the type ends on a DNF close parenthesis.
* Includes protection against throwing two errors for the same issue, like when a DNF close parenthesis if followed by a union type operator and there is whitespace between these.

Includes tests.
Includes updated documentation.
@jrfnl jrfnl force-pushed the feature/universal-typeoperatorspacing-support-dnf-types branch from a282adb to b031559 Compare April 20, 2025 22:56
@jrfnl jrfnl merged commit 359ed4d into develop Apr 20, 2025
47 checks passed
@jrfnl jrfnl deleted the feature/universal-typeoperatorspacing-support-dnf-types branch April 20, 2025 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant