Skip to content

new sniff to remove whitspace from start of functions#2827

Merged
Crabcyborg merged 1 commit into
masterfrom
new_sniff_to_remove_whitespace_from_start_of_function
Jan 16, 2026
Merged

new sniff to remove whitspace from start of functions#2827
Crabcyborg merged 1 commit into
masterfrom
new_sniff_to_remove_whitespace_from_start_of_function

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

@Crabcyborg Crabcyborg commented Jan 16, 2026

I thought I had this already.

Either way, it seems to have been applied in Lite because there are no issues in this repo.

Summary by CodeRabbit

New Features

  • Introduced a new coding standard rule that prevents blank lines from appearing immediately after function and closure opening braces. The rule is now available in the Formidable PHP standards and includes automatic fixing capabilities to help maintain consistent code formatting across your projects.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 16, 2026

📝 Walkthrough

Walkthrough

A new PHP_CodeSniffer sniff is introduced that detects and automatically fixes blank lines immediately after function and closure opening braces. The sniff is registered in the ruleset to enforce this whitespace standard.

Changes

Cohort / File(s) Summary
New Whitespace Sniff
phpcs-sniffs/Formidable/Sniffs/WhiteSpace/NoBlankLineAfterFunctionOpenSniff.php
Adds sniff class with register() method listening for T_FUNCTION and T_CLOSURE tokens, and process() method that detects blank lines after opening braces. Reports fixable violations and normalizes excess whitespace by collapsing multiple newlines or removing extra tokens.
Ruleset Configuration
phpcs-sniffs/Formidable/ruleset.xml
Enables the new Formidable.WhiteSpace.NoBlankLineAfterFunctionOpen rule in the sniffs ruleset.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 After function braces, no spaces remain,
A tidy rule to keep code sane,
No blank lines, just clean aligned flow,
Sniff by sniff, we watch our code grow! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: introducing a new PHP_CodeSniffer sniff that removes blank lines from the start of functions.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@phpcs-sniffs/Formidable/Sniffs/WhiteSpace/NoBlankLineAfterFunctionOpenSniff.php`:
- Around line 91-97: Replace the hardcoded "\n" used in the fixer replacement
with the file's EOL char to preserve CRLF/other line endings: when computing
$newlineCount/$content and calling $phpcsFile->fixer->replaceToken($nextToken,
"\n" . $indent), use $phpcsFile->eolChar instead of "\n" (e.g., build
replacement as $phpcsFile->eolChar . $indent) so the fixer output respects
original line endings.

@Crabcyborg Crabcyborg merged commit c551fb7 into master Jan 16, 2026
36 checks passed
@Crabcyborg Crabcyborg deleted the new_sniff_to_remove_whitespace_from_start_of_function branch January 16, 2026 22:45
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