Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ For details, take a look at the following workflow configuration files:

## Coding Standards

We are using [`squizlabs/php_codesniffer`](https://github.com/squizlabs/PHP_CodeSniffer) to enforce coding standards in PHP files.
We are using [`friendsofphp/php-cs-fixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer) to enforce coding standards in PHP files.

Run

Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,17 @@ jobs:
with:
dependencies: "${{ matrix.dependencies }}"

- name: "Run squizlabs/php_codesniffer"
run: "vendor/bin/phpcbf"
- name: "Create cache directory for friendsofphp/php-cs-fixer"
run: "mkdir -p .build/php-cs-fixer"

- name: "Cache cache directory for friendsofphp/php-cs-fixer"
uses: "actions/cache@v3.3.1"
with:
path: ".build/php-cs-fixer"
key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ github.ref_name }}"
restore-keys: |
php-${{ matrix.php-version }}-php-cs-fixer-main
php-${{ matrix.php-version }}-php-cs-fixer-

- name: "Run friendsofphp/php-cs-fixer"
run: "vendor/bin/php-cs-fixer fix --ansi --config=.php-cs-fixer.php --diff --dry-run --verbose"
51 changes: 51 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

declare(strict_types=1);

/**
* Copyright (c) 2017-2023 Andreas Möller.
*
* For the full copyright and license information, please view
* the LICENSE.md file that was distributed with this source code.
*
* @see https://github.com/ergebnis/php-package-template
*/

use Ergebnis\PhpCsFixer;

$config = PhpCsFixer\Config\Factory::fromRuleSet(new PhpCsFixer\Config\RuleSet\Php80(), [
'align_multiline_comment' => false,
'binary_operator_spaces' => false,
'class_attributes_separation' => false,
'declare_strict_types' => false,
'final_class' => false,
'header_comment' => false,
'no_blank_lines_after_class_opening' => false,
'no_blank_lines_after_phpdoc' => false,
'no_extra_blank_lines' => false,
'ordered_interfaces' => false,
'phpdoc_align' => false,
'phpdoc_indent' => false,
'phpdoc_no_alias_tag' => false,
'phpdoc_no_package' => false,
'phpdoc_separation' => false,
'phpdoc_summary' => false,
'phpdoc_trim_consecutive_blank_line_separation' => false,
'single_blank_line_before_namespace' => false,
'statement_indentation' => false,
'visibility_required' => false,
]);

$config->getFinder()
->exclude([
'.build/',
'.github/',
'.note/',
])
->ignoreDotFiles(false)
->in(__DIR__)
->name('.php-cs-fixer.php');

$config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/.php-cs-fixer.cache');

return $config;
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
it: coding-standards ## Runs the coding-standards target

.PHONY: coding-standards
coding-standards: vendor ## Fixes code style issues with squizlabs/php_codesniffer
vendor/bin/phpcs
vendor/bin/phpcbf
coding-standards: vendor ## Fixes code style issues with friendsofphp/php-cs-fixer
mkdir -p .build/php-cs-fixer/
vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --verbose

.PHONY: help
help: ## Displays this list of targets with descriptions
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"php": "~8.0.0 || ~8.1.0 || ~8.2.0"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.7.2"
"ergebnis/php-cs-fixer-config": "^5.5.2"
},
"config": {
"platform": {
Expand Down
Loading