From 863282996eeb554f46da046d7063a5007648d397 Mon Sep 17 00:00:00 2001 From: tfrommen Date: Mon, 27 Jan 2025 08:58:47 +0100 Subject: [PATCH] fix and improve docs --- README.md | 32 +++++++++++++++++--------------- docs/Migration.md | 32 ++++++++++++++++---------------- docs/Sniffs.md | 4 ++-- 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index a13d136..e39808d 100644 --- a/README.md +++ b/README.md @@ -39,22 +39,22 @@ The Syde PHP Coding Standards package requires: - PHP 8.1+ - [Composer](https://getcomposer.org/) -- [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer/) 3.11+ -- [PHP_CodeSniffer Standards Composer Installer Plugin](https://github.com/PHPCSStandards/composer-installer/) 1.0+ -- [PHPCompatibility](https://github.com/PHPCompatibility/PHPCompatibility/) 10+ (`dev-develop`) -- [PHPCSExtra](https://github.com/PHPCSStandards/PHPCSExtra/) 1.2+ -- [PHPCSUtils](https://github.com/PHPCSStandards/PHPCSUtils/) 1.0+ -- [Slevomat Coding Standard](https://github.com/slevomat/coding-standard/) 8.15 -- [VariableAnalysis](https://github.com/sirbrillig/phpcs-variable-analysis/) 2.11+ -- [WordPress Coding Standards](https://github.com/WordPress/WordPress-Coding-Standards/) 3.1+ -- [WordPress VIP Coding Standards](https://github.com/Automattic/VIP-Coding-Standards/) 3.0+ +- [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer/) +- [PHP_CodeSniffer Standards Composer Installer Plugin](https://github.com/PHPCSStandards/composer-installer/) +- [PHPCompatibility](https://github.com/PHPCompatibility/PHPCompatibility/) (`dev-develop`) +- [PHPCSExtra](https://github.com/PHPCSStandards/PHPCSExtra/) +- [PHPCSUtils](https://github.com/PHPCSStandards/PHPCSUtils/) +- [Slevomat Coding Standard](https://github.com/slevomat/coding-standard/) +- [VariableAnalysis](https://github.com/sirbrillig/phpcs-variable-analysis/) +- [WordPress Coding Standards](https://github.com/WordPress/WordPress-Coding-Standards/) +- [WordPress VIP Coding Standards](https://github.com/Automattic/VIP-Coding-Standards/) When installed for local development, these packages will be installed as well: -- [PHPStan](https://github.com/phpstan/phpstan/) 2.1+ -- [PHPStan Deprecation Rules Extension](https://github.com/phpstan/phpstan-deprecation-rules) 2.0+ -- [PHPStan No-Private Extension](https://github.com/swissspidy/phpstan-no-private) 1.0+ -- [PHPUnit](https://github.com/sebastianbergmann/phpunit/) 10.5+ +- [PHPStan](https://github.com/phpstan/phpstan/) +- [PHPStan Deprecation Rules Extension](https://github.com/phpstan/phpstan-deprecation-rules) +- [PHPStan No-Private Extension](https://github.com/swissspidy/phpstan-no-private) +- [PHPUnit](https://github.com/sebastianbergmann/phpunit/) ## Installation @@ -128,6 +128,7 @@ A minimum working example could look like so: ```xml + @@ -150,6 +151,7 @@ Here is a real-world example including files and folders to check, as well as so ```xml + @@ -178,7 +180,7 @@ Here is a real-world example including files and folders to check, as well as so - */tests/cases/* + */tests/* @@ -186,8 +188,8 @@ Here is a real-world example including files and folders to check, as well as so - + diff --git a/docs/Migration.md b/docs/Migration.md index fc4efa6..70e3879 100644 --- a/docs/Migration.md +++ b/docs/Migration.md @@ -131,7 +131,7 @@ sed -i -f /path/to/phpcs.sed -- $(grep -nrl -e 'Inpsyde.CodeQuality' -e 'Inpsyde ``` > [!TIP] -> The command mentioned above may result in an error on a Mac. In most cases, the -i flag can be specified as an empty string (e.g. `sed -i ''`) to resolve the issue. +> The above command may result in an error on a Mac. If this is the case for you, try passing an empty string as argument for the `-i` flag to prevent this error from happening (e.g., `sed -i '' ...`). The above command will first retrieve the list of files that include `Inpsyde.CodeQuality` or `InpsydeTemplates.Formatting`, ignoring the `vendor` directory, and then execute all substitution commands in the `phpcs.sed` file for each of the found files. @@ -151,7 +151,7 @@ Wherever you were previously referencing the `Inpsyde` standard, you may want to If you are using `InpsydeTemplates`, this would now be `Syde-Templates`. -### PHP_CodeSniffer Rulesets +### PHP_CodeSniffer Rulesets In addition to the changes to the rule names, there are also changes regarding sniff configuration. @@ -163,12 +163,12 @@ The `Inpsyde.CodeQuality.Psr4` sniff has a public `array` property, `$psr4`, tha ```xml - - - - - - + + + + + + ``` @@ -178,14 +178,14 @@ An example configuration that matches the above behavior looks like so: ```xml - - - - - - - - + + + + + + + + ``` diff --git a/docs/Sniffs.md b/docs/Sniffs.md index b21a90b..d7417f6 100644 --- a/docs/Sniffs.md +++ b/docs/Sniffs.md @@ -206,7 +206,7 @@ There are some exceptions: - PHP native double underscore method; - WordPress hook callbacks; - select PHP methods: `seek`, `unserialize`. - + Via the `allowedMethodNames` property, you can specify method names that are allowed to bypass the argument type checks: ```xml @@ -283,7 +283,7 @@ This is optional, and you may want to move the curly brace up and add a blank li This sniff triggers an error if a function is longer than the maximum allowed length (default: 50 lines). By default, the following is ignored when counting lines: - + - blank lines; - comments; - doc block **inside** function block.