Skip to content

feat/php cs fixer custom rules#14

Merged
ralflang merged 5 commits intoFRAMEWORK_6_0from
feat/php-cs-fixer-custom-rules
Mar 2, 2026
Merged

feat/php cs fixer custom rules#14
ralflang merged 5 commits intoFRAMEWORK_6_0from
feat/php-cs-fixer-custom-rules

Conversation

@ralflang
Copy link
Member

@ralflang ralflang commented Mar 2, 2026

  • feat(cs-fixer): add custom fixers for PHP version comments and copyright years
  • fix(qc): report correct total file count for PHP CS Fixer task
  • feat(qc): add PHAR support for PHP CS Fixer custom fixers
  • chore(build): include PHP CS Fixer config in PHAR build
  • style: php-cs-fixer removes outdated 'PHP Version 7' comments

ralflang added 5 commits March 2, 2026 17:08
…ght years

Add custom PHP CS Fixer rules to enforce Horde coding standards:

1. RemovePhpVersionCommentFixer - Removes "PHP Version X" lines from
   file-level and class-level docblocks
2. UpdateCopyrightYearFixer - Updates copyright years dynamically to
   include current year (e.g., "2025" → "2025-2026", "2020-2024" → "2020-2026")

Updated .php-cs-fixer.dist.php configuration:
- Exclude lib/ directory (legacy PSR-0 code)
- Only format src/ and test/ directories with PER-1 style
- Register custom fixers
- Update to @PHP84Migration from deprecated @PHP83Migration

Applied fixes to 101 files in src/ and test/ directories:
- Removed all "PHP Version 7" comment lines
- Updated copyright years to 2026
- Applied PER-1 coding style consistently

All tests pass. No syntax errors introduced.
The Phpcsfixer QC task was incorrectly reporting only files that had
issues, not the total number of files checked. This was misleading when
all files were compliant.

Changes:
- Add getTotalFileCount() method that uses 'list-files' command
- Set files_checked statistic before running fixer
- Update parseResults() to only count files with issues
- Files are now correctly counted (267 in components)

Before: "8 files checked" (only files with changes)
After: "267 files checked" (all files scanned by PHP CS Fixer)
When horde-components runs from a PHAR, custom PHP CS Fixer rules need
to be extracted since PHP CS Fixer (external tool) cannot load classes
from inside the PHAR.

Changes:
- Detect PHAR context using \Phar::running()
- Extract .php-cs-fixer.dist.php and custom fixers to temp directory
- Pass extracted config to PHP CS Fixer via --config option
- Cleanup temp directory after execution and in destructor
- Non-PHAR execution unchanged (uses default config discovery)

This allows components to benefit from custom fixers (removing "PHP
Version X" comments, updating copyright years) whether horde-components
is run from source or PHAR.
Add .php-cs-fixer.dist.php to box.json files list so it's included in
the PHAR archive. This is required for the Phpcsfixer QC task to extract
and use custom fixers when running from PHAR.
@ralflang ralflang merged commit c8a9c34 into FRAMEWORK_6_0 Mar 2, 2026
1 check failed
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.

1 participant