Skip to content

feat: HeaderCommentFixer - allow validators#8452

Merged
kubawerlos merged 9 commits intoPHP-CS-Fixer:masterfrom
keradus:header
Feb 21, 2025
Merged

feat: HeaderCommentFixer - allow validators#8452
kubawerlos merged 9 commits intoPHP-CS-Fixer:masterfrom
keradus:header

Conversation

@keradus
Copy link
Copy Markdown
Member

@keradus keradus commented Feb 21, 2025

@keradus keradus marked this pull request as ready for review February 21, 2025 01:42
@coveralls
Copy link
Copy Markdown

coveralls commented Feb 21, 2025

Coverage Status

coverage: 94.932% (-0.006%) from 94.938%
when pulling cf26db2 on keradus:header
into 12424e1 on PHP-CS-Fixer:master.

@kubawerlos kubawerlos changed the title feat: header_comment - allow validators feat: HeaderCommentFixer - allow validators Feb 21, 2025
(new FixerOptionBuilder('validator', 'RegEx validator for header content.'))
->setAllowedTypes(['string', 'null'])
->setNormalizer(static function (Options $options, ?string $value) use ($fixerName): ?string {
if (null !== $value && !str_starts_with($value, '/')) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What about simply:

try {
    Preg::match($value, '');
} catch (PregException $exception) {
    throw new InvalidFixerConfigurationException($fixerName, 'Regex is invalido:' . $exception->getMessage());
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

thanks, done

@kubawerlos kubawerlos merged commit 374142d into PHP-CS-Fixer:master Feb 21, 2025
@keradus keradus deleted the header branch February 22, 2025 10:45
fabpot added a commit to symfony/symfony that referenced this pull request Feb 24, 2025
This PR was squashed before being merged into the 7.3 branch.

Discussion
----------

chore: PHP CS Fixer - allow header validator

| Q             | A
| ------------- | ---
| Branch?       | 7.3
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Issues        | Fixer config
| License       | MIT

~so `php-cs-fixer check --diff src/Symfony/Component/HttpKernel/HttpCache/Store.php` doesn't complain (on header rule)~
so `php-cs-fixer check --diff` doesn't complain (on header rule)

based on PHP-CS-Fixer/PHP-CS-Fixer#8452

**Requires PHP CS Fixer ^3.70**

Commits
-------

20f00d5 chore: PHP CS Fixer - allow header validator
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.

3 participants