Skip to content

Conversation

@jackd248
Copy link
Owner

@jackd248 jackd248 commented Sep 4, 2025

Summary by CodeRabbit

  • Documentation

    • Clarified compatibility with standard PHP-CS-Fixer rules and phpdoc_separation; examples no longer show @Package.
  • Tests

    • Updated tests to reflect exclusion of @Package from generated/validated docblocks.
  • Bug Fixes

    • Adjusted docblock separation behavior to avoid extra blank lines and conflicts with related rules.
  • Chores

    • Added /coverage-report to .gitignore and improved package description.

@coderabbitai
Copy link

coderabbitai bot commented Sep 4, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Added /coverage-report to .gitignore, removed @package usage from README and tests, set a descriptive composer description, and adjusted DocBlockHeaderFixer defaults and insertion logic to avoid adding bottom separation when not appropriate.

Changes

Cohort / File(s) Summary
Version control ignores
/.gitignore
Added /coverage-report to ignored paths.
Documentation
/README.md
Removed @package examples and config entries; added note about PHP-CS-Fixer compatibility and phpdoc_no_package/phpdoc_separation behavior.
Package metadata
/composer.json
Updated description from empty string to a descriptive sentence.
Rule implementation
/src/Rules/DocBlockHeaderFixer.php
Changed default separate option from both to none; adjusted insertNewDocBlock() to default to none; only insert bottom separation when separate is bottom or both and when trailing whitespace does not already exist.
Tests: Generators
tests/src/Generators/DocBlockHeaderTest.php
Removed package from validAnnotations in annotation validation test.
Tests: Rules
tests/src/Rules/DocBlockHeaderFixerTest.php
Updated test expectations for testBuildDocBlockWithMultipleAnnotations to exclude @package in generated docblocks.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Test as Tests / Caller
  participant Fixer as DocBlockHeaderFixer
  participant Config as Configuration
  participant Tokens as TokenStream

  Note over Test,Fixer: Request to build/insert docblock
  Test->>Fixer: buildDocBlock()/insertNewDocBlock()
  Fixer->>Config: read `separate` option (default: none)
  alt separate == none
    Fixer->>Tokens: build docblock without extra bottom separation
  else separate == bottom or both
    Fixer->>Tokens: check for existing trailing whitespace after class declaration
    alt trailing whitespace exists
      Fixer->>Tokens: do not insert extra newline (avoid conflict)
    else trailing whitespace absent
      Fixer->>Tokens: insert bottom separation newline
    end
  end
  Fixer-->>Test: return updated tokens/docblock
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

I hopped through headers with a careful tap,
Removed a package line from the map.
I nudged defaults gently, left whitespace kind,
Composer now speaks, and tests aligned.
A rabbit's small fix — tidy, neat, and spry. 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 62c1647 and a745d5e.

📒 Files selected for processing (2)
  • composer.json (1 hunks)
  • src/Rules/DocBlockHeaderFixer.php (4 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch align-rule

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
README.md (1)

12-12: Fix grammar in intro sentence

Singular “package”.

-This packages contains a [PHP-CS-Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer) rule to automatically fix the class header regarding PHP DocBlocks.
+This package contains a [PHP-CS-Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer) rule to automatically fix the class header regarding PHP DocBlocks.
🧹 Nitpick comments (2)
.gitignore (1)

6-6: Optionally ignore other common coverage outputs

If you generate Clover/XML or default HTML outputs, consider ignoring these too.

 /.build
+/coverage
 /coverage-report
+clover.xml
 /php-cs-fixer.xml
tests/src/Rules/DocBlockHeaderFixerTest.php (1)

92-104: Add a negative test to ensure @package is not emitted

To lock behavior, add a test that passes a package key and asserts it’s omitted from the output (or rejected, depending on intended validation).

public function testBuildDocBlockDoesNotIncludePackage(): void
{
    $method = new ReflectionMethod($this->fixer, 'buildDocBlock');
    $method->setAccessible(true);

    $result = $method->invoke(
        $this->fixer,
        ['author' => 'John', 'package' => 'Foo'], // should be ignored or invalid
        ''
    );

    // If ignored:
    $this->assertSame("/**\n * @author John\n */", $result);
    // If invalid, assert exception instead:
    // $this->expectException(\InvalidArgumentException::class);
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ba41a5a and 62c1647.

📒 Files selected for processing (5)
  • .gitignore (1 hunks)
  • README.md (1 hunks)
  • composer.json (1 hunks)
  • tests/src/Generators/DocBlockHeaderTest.php (0 hunks)
  • tests/src/Rules/DocBlockHeaderFixerTest.php (1 hunks)
💤 Files with no reviewable changes (1)
  • tests/src/Generators/DocBlockHeaderTest.php
🧰 Additional context used
🪛 LanguageTool
README.md

[style] ~60-~60: Using many exclamation marks might seem excessive (in this case: 4 exclamation marks for a text that’s 1384 characters long)
Context: ...e in your .php-cs-fixer.php file: > [!NOTE] > This fixer is compatible with st...

(EN_EXCESSIVE_EXCLAMATION)

🔇 Additional comments (3)
.gitignore (1)

6-6: LGTM: ignore coverage artifacts

Adding /coverage-report at repo root is fine.

tests/src/Rules/DocBlockHeaderFixerTest.php (1)

92-104: Updated expectation without @Package looks correct

The multiple-annotations case now aligns with the decision to drop @package from examples.

README.md (1)

60-62: Good note about compatibility with phpdoc_no_package

Nice clarification on rule compatibility and spacing conventions.

@coveralls
Copy link

coveralls commented Sep 4, 2025

Pull Request Test Coverage Report for Build 17473287021

Details

  • 5 of 5 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 16825471676: 0.0%
Covered Lines: 163
Relevant Lines: 163

💛 - Coveralls

@jackd248 jackd248 merged commit 1b062d8 into main Sep 4, 2025
11 of 12 checks passed
@jackd248 jackd248 deleted the align-rule branch October 13, 2025 11:15
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.

3 participants