Skip to content

Conversation

@jaymcp
Copy link
Contributor

@jaymcp jaymcp commented Apr 7, 2025

Description

Introduces linting for declare statements.

It will ensure that there is:

  • a lower case keyword
  • no space between the keyword and opening parenthesis
  • one space after the opening parenthesis
  • a lower case declaration type
  • no unsupported declaration type (i.e. only ticks, strict_types, or encoding)
  • one space before the equals sign
  • one space after the equals sign
  • one space before the closing parenthesis
  • no space between the closing parenthesis and terminating semi-colon
  • one space between the closing parenthesis and opening curly brace in a block declaration
  • no content after the opening curly brace in a block declaration
  • a newline before the closing curly brace in a block declaration
  • same-column alignment between the declare keyword and closing curly brace

Most of these also come with fixers.

Our expectations:

declare( strict_types = 1 );

declare( encoding = 'utf8' );

declare( ticks = 1 ) {
    // stuff here
}

Changelog

  • Add declare statement Sniff

Types of changes:

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Checklist:

  • All checks pass when running `composer run all-checks.

@jaymcp jaymcp marked this pull request as ready for review April 30, 2025 14:46
@jaymcp jaymcp merged commit 5e988dd into main Sep 1, 2025
6 checks passed
@jaymcp jaymcp deleted the feat/declare branch September 1, 2025 16:25
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

Successfully merging this pull request may close these issues.

2 participants