Skip to content

Commit

Permalink
introduces new linter for PHP-CS-Fixer (see feature report #3550)
Browse files Browse the repository at this point in the history
  • Loading branch information
llaville committed May 31, 2024
1 parent 9094ce0 commit ff15cd3
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .automation/test/php/php_good_3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

array_push($x, $y);
12 changes: 12 additions & 0 deletions TEMPLATES/.php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

$finder = (new PhpCsFixer\Finder())
->in('.')
;

return (new PhpCsFixer\Config())
->setRules([
'@PER-CS' => true,
])
->setFinder($finder)
;
1 change: 1 addition & 0 deletions flavors/php/flavor.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"MARKDOWN_MARKDOWN_TABLE_FORMATTER",
"OPENAPI_SPECTRAL",
"PHP_PHPCS",
"PHP_PHPCSFIXER",
"PHP_PHPSTAN",
"PHP_PSALM",
"PHP_PHPLINT",
Expand Down
2 changes: 2 additions & 0 deletions megalinter/descriptors/all_flavors.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
"MARKDOWN_MARKDOWN_LINK_CHECK",
"MARKDOWN_MARKDOWN_TABLE_FORMATTER",
"PHP_PHPCS",
"PHP_PHPCSFIXER",
"PHP_PHPSTAN",
"PHP_PSALM",
"PHP_PHPLINT",
Expand Down Expand Up @@ -665,6 +666,7 @@
"MARKDOWN_MARKDOWN_TABLE_FORMATTER",
"OPENAPI_SPECTRAL",
"PHP_PHPCS",
"PHP_PHPCSFIXER",
"PHP_PHPSTAN",
"PHP_PSALM",
"PHP_PHPLINT",
Expand Down
39 changes: 39 additions & 0 deletions megalinter/descriptors/php.megalinter-descriptor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,42 @@ linters:
dockerfile:
- |
RUN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install overtrue/phplint --force-accept-unsigned -g
# PHP-CS-Fixer
- linter_name: php-cs-fixer
name: PHP_PHPCSFIXER
linter_url: https://cs.symfony.com/
linter_repo: https://github.com/PHP-CS-Fixer/PHP-CS-Fixer
config_file_name: .php-cs-fixer.dist.php
cli_lint_mode: project
cli_lint_extra_args:
- "fix"
- "--dry-run"
- "--verbose"
- "--show-progress=none"
cli_config_arg_name: "--config"
cli_lint_fix_remove_args:
- "--dry-run"
examples:
- "php-cs-fixer check myfile.php"
- "php-cs-fixer check mydir"
- "php-cs-fixer check --config .php-cs-fixer.php"
install:
dockerfile:
- |
RUN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && composer global require friendsofphp/php-cs-fixer
ide:
netbeans:
- name: PHP-CS-Fixer
url: https://plugins.netbeans.apache.org/catalogue/?id=36
idea:
- name: php-cs-fixer
url: https://www.jetbrains.com/help/phpstorm/using-php-cs-fixer.html
sublime:
- name: sublime-phpcs
url: https://github.com/benmatselby/sublime-phpcs
vim:
- name: vim-php-cs-fixer
url: https://github.com/stephpy/vim-php-cs-fixer
vscode:
- name: vscode-php-cs-fixer
url: https://github.com/junstyle/vscode-php-cs-fixer

0 comments on commit ff15cd3

Please sign in to comment.