Release Notes - Version 1.6.0
π New Features
β¨ Enhanced Max Line Length Rule
Enhancement: Flexible Line Type Ignoring
-
Class:
Phauthentic\PHPStanRules\CleanCode\MaxLineLengthRule -
Purpose: Extended to support ignoring multiple types of lines beyond just use statements, providing more granular control over line length checking
-
Key Features:
- New Array-Based API: Introduced
ignoreLineTypesparameter for flexible configuration - Multiple Line Types: Support for ignoring use statements, namespace declarations, and docblocks
- Backward Compatible: Existing
ignoreUseStatementsparameter continues to work unchanged - Selective Control: Choose which line types to ignore independently
- New Array-Based API: Introduced
-
Supported Line Types:
useStatements- Ignore lines containingusestatements (e.g.,use Some\Very\Long\Namespace\Path\ClassName;)namespaceDeclaration- Ignore lines containingnamespacedeclarations (e.g.,namespace App\Some\Very\Long\Namespace\Path;)docBlocks- Ignore lines that are part of docblock comments (e.g.,/** This is a very long docblock comment that exceeds the line length limit */)
-
Configuration: Supports new optional parameter:
ignoreLineTypes(array, default:[]) - Array of line types to ignore with boolean valuesignoreUseStatements(boolean, default:false) - Maintained for backward compatibility, takes precedence when set
-
Backward Compatibility:
- The existing
ignoreUseStatementsparameter remains fully functional - When both
ignoreUseStatementsandignoreLineTypes['useStatements']are set,ignoreUseStatementstakes precedence - All existing configurations continue to work without modification
- The existing
π Documentation Improvements
π Enhanced Max Line Length Rule Documentation
-
Comprehensive Examples: Added detailed configuration examples for:
- New array-based API (recommended approach)
- Legacy parameter usage (backward compatible)
- Selective line type ignoring
- Combined configurations
-
Parameter Documentation: Complete documentation of all parameters including:
maxLineLength- Maximum allowed line lengthexcludePatterns- File exclusion patternsignoreUseStatements- Legacy parameter for backward compatibilityignoreLineTypes- New array-based configuration option
-
Use Cases Section: Examples showing:
- Ignoring only use statements
- Ignoring namespace declarations and docblocks
- Ignoring all supported line types
- Combining with file exclusions
π Migration Guide
For Existing Users
No Action Required! All existing configurations continue to work without any changes. The new ignoreLineTypes parameter is optional and disabled by default, so your current setup will behave exactly as before.
For New Configurations
Recommended: Use the new array-based API for better flexibility:
ignoreLineTypes:
useStatements: true
namespaceDeclaration: true
docBlocks: trueLegacy: The ignoreUseStatements parameter still works and is fully supported:
ignoreUseStatements: trueπ‘ Why This Matters
The previous version only supported ignoring use statements. Many codebases have long namespace declarations or detailed docblocks that exceed line length limits but are acceptable for readability. This release provides the flexibility to ignore these line types while still enforcing line length limits for actual code logic.
Before (1.5.1): Only use statements could be ignored
After (1.6.0): You can now ignore:
- Use statements
- Namespace declarations
- Docblock comments
- Any combination of the above
This significantly improves the rule's usability in real-world scenarios where certain types of long lines are acceptable or even preferred for code clarity.
This release represents a major enhancement to the Max Line Length Rule while maintaining 100% backward compatibility with existing configurations. We recommend gradually adopting the new array-based API for better flexibility and future-proofing your configuration.
Full Changelog: 1.5.1...1.6.0