diff --git a/.github/script.sh b/.github/script.sh index a14b641..27bc7f1 100755 --- a/.github/script.sh +++ b/.github/script.sh @@ -32,9 +32,10 @@ cd ~/fixture || exit 1 # Test that all standards were installed. INSTALLED=$(./vendor/bin/phpcs -i) EXPECTED=( + AcquiaDrupalMinimal AcquiaDrupalStrict - AcquiaDrupalTransitional - AcquiaPHP + AcquiaPHPMinimal + AcquiaPHPStrict Drupal DrupalPractice PHPCompatibility @@ -54,13 +55,14 @@ if [[ "$FAILURES" ]]; then fi # Place a good test file. -printf " good.php +printf " good.php # Test that the SUT's standards can be run. EXPECTED=( + AcquiaDrupalMinimal AcquiaDrupalStrict - AcquiaDrupalTransitional - AcquiaPHP + AcquiaPHPMinimal + AcquiaPHPStrict ) for STANDARD in "${EXPECTED[@]}"; do ./vendor/bin/phpcs -v --standard="$STANDARD" good.php diff --git a/README.md b/README.md index d59b7ff..197ed62 100644 --- a/README.md +++ b/README.md @@ -19,12 +19,17 @@ Acquia Coding Standards for PHP includes a selection of sniffs from the followin ## Rulesets -Rules are split into rulesets according to the project language and framework: +Rules are split into rulesets according to the project *framework* and *audience*: -* [AcquiaPHP](src/Standards/AcquiaPHP/ruleset.xml) contains sniffs applicable to all PHP projects. -* [AcquiaDrupalStrict](src/Standards/AcquiaDrupalStrict/ruleset.xml) incorporates AcquiaPHP and adds all Drupal coding standards and best practices sniffs. Recommended for new Drupal projects and teams familiar with Drupal coding standards. -* [AcquiaDrupalTransitional](src/Standards/AcquiaDrupalTransitional/ruleset.xml) incorporates AcquiaPHP and adds Drupal core's own phpcs configuration, which is less strict than the official standards. Recommended for legacy Drupal codebases or teams new to Drupal coding standards. -* [AcquiaEdge](src/Standards/AcquiaEdge/ruleset.xml) incorporates AcquiaPHP and adds backwards-incompatible sniffs that will be included in AcquiaPHP with the next major release of this package. +* Projects targeting the Drupal community, e.g., Drupal modules, should adopt a *Drupal* ruleset. All others should adopt a (more generalized) *PHP* ruleset. +* Public projects, e.g., open-source Drupal modules, should adopt a *non-strict* ruleset to facilitate external collaboration. All others should adopt a more opinionated *internal* ruleset. + +There are four permutations of these guidelines, leading to four rulesets to choose from: + +* [AcquiaDrupalMinimal](src/Standards/AcquiaDrupalMinimal/ruleset.xml) is based on the Drupal coding standard and is intended for use on all public Drupal projects. +* [AcquiaDrupalStrict](src/Standards/AcquiaDrupalStrict/ruleset.xml) is based on AcquiaDrupal and adds the more opinionated DrupalPractice standard. It is intended for use on all internal Drupal projects. +* [AcquiaPHPMinimal](src/Standards/AcquiaPHPMinimal/ruleset.xml) is based on PSR-12 and is intended for use on all public non-Drupal projects. +* [AcquiaPHPStrict](src/Standards/AcquiaPHPStrict/ruleset.xml) is based on AcquiaPHP and adds additional, more opinionated standards. It is intended for use on all internal, non-Drupal projects. ## Installation & usage diff --git a/composer.json b/composer.json index fe40fab..a731391 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ }, "extra": { "branch-alias": { - "dev-develop": "2.x-dev" + "dev-develop": "3.x-dev" } }, "autoload": { diff --git a/composer.lock b/composer.lock index be055c2..3358b4f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "85e531ea146b4097f8d2564b24854784", + "content-hash": "377928302778414a51f9799bfcc24742", "packages": [ { "name": "dealerdirect/phpcodesniffer-composer-installer", @@ -370,12 +370,12 @@ "version": "3.7.2", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879", "shasum": "" }, @@ -587,5 +587,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/example/phpcs.xml.dist b/example/phpcs.xml.dist index 216045c..d5f6565 100644 --- a/example/phpcs.xml.dist +++ b/example/phpcs.xml.dist @@ -7,10 +7,10 @@ + - - - + + diff --git a/src/Standards/AcquiaDrupalMinimal/ruleset.xml b/src/Standards/AcquiaDrupalMinimal/ruleset.xml new file mode 100644 index 0000000..1237efc --- /dev/null +++ b/src/Standards/AcquiaDrupalMinimal/ruleset.xml @@ -0,0 +1,44 @@ + + + + + + Acquia's Drupal coding standards. + + + + + + + + + + + + + + + + tests/* + + + tests/* + + + tests/* + + + tests/* + + + tests/* + + + diff --git a/src/Standards/AcquiaDrupalStrict/ruleset.xml b/src/Standards/AcquiaDrupalStrict/ruleset.xml index 4fac5fe..5957fcf 100644 --- a/src/Standards/AcquiaDrupalStrict/ruleset.xml +++ b/src/Standards/AcquiaDrupalStrict/ruleset.xml @@ -9,45 +9,9 @@ Acquia's strict Drupal coding standards. - - - - - - tests/* - - - tests/* - - - tests/* - - - tests/* - - - tests/* - + - - - - - - - */modules/custom/*/*\.(module|install)$ - - - */modules/custom/*/*\.(module|install)$ - - - */modules/custom/*/*\.(module|install)$ - - - */modules/custom/*/*\.(module|install)$ - - diff --git a/src/Standards/AcquiaDrupalTransitional/ruleset.xml b/src/Standards/AcquiaDrupalTransitional/ruleset.xml deleted file mode 100644 index 0159dc0..0000000 --- a/src/Standards/AcquiaDrupalTransitional/ruleset.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - Acquia's transitional Drupal coding standards. - - - - - - - - tests/* - - - tests/* - - - tests/* - - - tests/* - - - tests/* - - - - - - - - - - - - */modules/custom/*/*\.(module|install)$ - - - */modules/custom/*/*\.(module|install)$ - - - */modules/custom/*/*\.(module|install)$ - - - */modules/custom/*/*\.(module|install)$ - - - diff --git a/src/Standards/AcquiaEdge/ruleset.xml b/src/Standards/AcquiaEdge/ruleset.xml deleted file mode 100644 index a848912..0000000 --- a/src/Standards/AcquiaEdge/ruleset.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - Acquia's Edge (backwards-incompatible) coding standards. - - - - - - - - - diff --git a/src/Standards/AcquiaPHP/ruleset.xml b/src/Standards/AcquiaPHP/ruleset.xml deleted file mode 100644 index 3041e70..0000000 --- a/src/Standards/AcquiaPHP/ruleset.xml +++ /dev/null @@ -1,232 +0,0 @@ - - - - - - Acquia's PHP coding standards. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *.(md|txt|yml) - - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - 0 - - - 0 - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 0 - - - 0 - - - 0 - - - - - 0 - - - 0 - - - - 0 - - - 0 - - - - 0 - - - 0 - - - 0 - - - - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Standards/AcquiaPHPMinimal/ruleset.xml b/src/Standards/AcquiaPHPMinimal/ruleset.xml new file mode 100644 index 0000000..f1fdd79 --- /dev/null +++ b/src/Standards/AcquiaPHPMinimal/ruleset.xml @@ -0,0 +1,38 @@ + + + + + + Acquia's PHP coding standards. + + + + + + + *.(md|txt|yml) + + + + + + + + + + + + + + + + + + diff --git a/src/Standards/AcquiaPHPStrict/ruleset.xml b/src/Standards/AcquiaPHPStrict/ruleset.xml new file mode 100644 index 0000000..2eb2a86 --- /dev/null +++ b/src/Standards/AcquiaPHPStrict/ruleset.xml @@ -0,0 +1,61 @@ + + + + + + Acquia's strict PHP coding standards. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +