Skip to content

Fixed Max Line Length Rule - Use Statement Ignoring

Choose a tag to compare

@floriankraemer floriankraemer released this 04 Dec 19:03
· 5 commits to master since this release
2e57a65

Release Notes - Version 1.5.1

🐛 Bug Fixes

🔧 Fixed Max Line Length Rule - Use Statement Ignoring

Bug Fix: Use Statement Ignoring Not Working Correctly

  • Class: Phauthentic\PHPStanRules\CleanCode\MaxLineLengthRule

  • Issue: When ignoreUseStatements was set to true, the rule was not properly ignoring long use statement lines. The check only examined the node type during initial processing, but didn't account for cases where the same line could be processed multiple times or where use statements appeared on lines that exceeded the maximum length.

  • Solution:

    • Implemented a caching mechanism to track which lines contain use statements per file
    • Added proper line-level checking to ensure use statements are consistently ignored regardless of processing order
    • Enhanced the rule to check both the node type and the cached line information
  • Impact:

    • Use statements that exceed the maximum line length are now correctly ignored when ignoreUseStatements: true is configured
    • Other long lines in the same file continue to be detected as expected
    • No breaking changes - existing configurations continue to work as intended
  • Testing:

    • Added comprehensive test cases to verify use statements are properly ignored
    • Added test cases to ensure non-use statement lines are still detected when use statements are ignored
    • Ensures the fix doesn't break the default behavior of detecting long use statements

💡 Why This Matters

Previously, developers who configured the rule to ignore use statements might have still received false positives for long use statement lines. This fix ensures that when you configure the rule to ignore use statements, those lines are consistently and reliably ignored, allowing you to focus on enforcing line length limits for actual code logic rather than import statements.

Before (1.5.0): Long use statements could still trigger errors even when ignoreUseStatements: true
After (1.5.1): Long use statements are properly ignored when configured, while other long lines are still detected


This is a bug fix release that improves the reliability of the Max Line Length Rule's use statement ignoring feature. All existing configurations continue to work without any changes required.

Full Changelog: 1.5.0...1.5.1