diff --git a/.docs/README.md b/.docs/README.md deleted file mode 100644 index d44e3fc..0000000 --- a/.docs/README.md +++ /dev/null @@ -1,178 +0,0 @@ -# Contributte / QA - -## Installation - -Install by running `composer require --dev contributte/qa` command. - -## Example - -Take a look at our template repository [contributte/bare](https://github.com/contributte/bare/). - -```xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /tests/tmp - -``` - -## Usage - -- Analyse your codebase with `phpcs` executable e.q. `vendor/bin/phpcs --standard=ruleset.xml app src tests`, as arguments, use your copied config file and directories to be scanned. -- Fix problems effortlessly with `phpcbf` executable e.g. `vendor/bin/phpcbf --standard=codesniffer.xml app src tests`. -- Your code now shines! 🌞 - -### Listing Sniffs - -To list all sniffs included in the ruleset, run: - -```bash -vendor/bin/phpcs --standard=ruleset.xml -e -``` - -Example output: - -``` -The Contributte standard contains 185 sniffs - -Generic (27 sniffs) -------------------- - Generic.Arrays.DisallowLongArraySyntax - Generic.Classes.DuplicateClassName - Generic.CodeAnalysis.EmptyStatement - ... - -SlevomatCodingStandard (101 sniffs) ------------------------------------ - SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation - SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement - SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace - ... -``` - -## Cheatsheet - -For advanced usage of codesniffer you can find all details in their [wiki](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#table-of-contents). However, working with codesniffer on daily basis you will often find your code -to be unable to conform to the coding standard. That is why we highlighted ways how to cope with it for you. - -### Ignoring - -#### Ignoring files - -```php -// phpcs:ignoreFile - -echo 'This whole file is suppressed'; -``` - -#### Ignoring part of a file - -```php -// phpcs:disable -echo 'Everything in between is ignored'; -// phpcs:enable - -// phpcs:disable Sniff.Name -echo 'Only Sniff.Name sniff is ignored'; -// phpcs:enable Sniff.Name -``` - -#### Ignoring specific lines - -```php -// ignores 2 lines: line with comment and following one -// phpcs:ignore -echo 'Ignored line'; - -echo 'Ignored line'; // phpcs:ignore Name.Of.The.Sniff -echo 'Ignored line'; -``` - -```php -/** - * Method is inherited from codebase without typehint so you cannot add typehint. - * - * @param string $key - * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint - */ -protected function($key): void {} -``` - -#### Ignoring all rules in path - -```xml - - - - app/FileToSkip.php - app/*Test\.php - tests/ - -``` - -#### Ignoring specific rules in path - -```xml - - - src/deprecated - -``` - -#### Ignoring rules from ruleset - -```xml - - - - - - -``` - -### Configuring - -#### Configuring your own rule - -```xml - - - - - - - -``` diff --git a/README.md b/README.md index 21bbf37..5af5d1f 100755 --- a/README.md +++ b/README.md @@ -18,7 +18,16 @@ Website 🚀 contributte.org | Contact 👨🏻‍💻 f3l1x.io | Twitter 🐦 @contributte

-## Usage +Tuned & very strict coding standards for PHP projects. Trusted by Contributte, Apitte, Nettrine and many others. + +## Versions + +| State | Branch | Version | PHP | +|--------|--------|---------|---------| +| dev | master | `^0.5` | `>=8.2` | +| stable | master | `^0.4` | `>=8.0` | + +## Installation To install latest version of `contributte/qa` use [Composer](https://getcomposer.org). @@ -26,16 +35,178 @@ To install latest version of `contributte/qa` use [Composer](https://getcomposer composer require --dev contributte/qa ``` -## Documentation +## Example -For details on how to use this package, check out our [documentation](.docs). +Take a look at our template repository [contributte/bare](https://github.com/contributte/bare/). -## Versions +```xml + + -| State | Branch | Version | PHP | -|--------|--------|---------|---------| -| dev | master | `^0.5` | `>=8.2` | -| stable | master | `^0.4` | `>=8.0` | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /tests/tmp + +``` + +## Usage + +- Analyse your codebase with `phpcs` executable e.q. `vendor/bin/phpcs --standard=ruleset.xml app src tests`, as arguments, use your copied config file and directories to be scanned. +- Fix problems effortlessly with `phpcbf` executable e.g. `vendor/bin/phpcbf --standard=codesniffer.xml app src tests`. +- Your code now shines! 🌞 + +### Listing Sniffs + +To list all sniffs included in the ruleset, run: + +```bash +vendor/bin/phpcs --standard=ruleset.xml -e +``` + +Example output: + +``` +The Contributte standard contains 186 sniffs + +Generic (27 sniffs) +------------------- + Generic.Arrays.DisallowLongArraySyntax + Generic.Classes.DuplicateClassName + Generic.CodeAnalysis.EmptyStatement + ... + +SlevomatCodingStandard (101 sniffs) +----------------------------------- + SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation + SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement + SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace + ... +``` + +## Cheatsheet + +For advanced usage of codesniffer you can find all details in their [wiki](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#table-of-contents). However, working with codesniffer on daily basis you will often find your code +to be unable to conform to the coding standard. That is why we highlighted ways how to cope with it for you. + +### Ignoring + +#### Ignoring files + +```php +// phpcs:ignoreFile + +echo 'This whole file is suppressed'; +``` + +#### Ignoring part of a file + +```php +// phpcs:disable +echo 'Everything in between is ignored'; +// phpcs:enable + +// phpcs:disable Sniff.Name +echo 'Only Sniff.Name sniff is ignored'; +// phpcs:enable Sniff.Name +``` + +#### Ignoring specific lines + +```php +// ignores 2 lines: line with comment and following one +// phpcs:ignore +echo 'Ignored line'; + +echo 'Ignored line'; // phpcs:ignore Name.Of.The.Sniff +echo 'Ignored line'; +``` + +```php +/** + * Method is inherited from codebase without typehint so you cannot add typehint. + * + * @param string $key + * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint + */ +protected function($key): void {} +``` + +#### Ignoring all rules in path + +```xml + + + + app/FileToSkip.php + app/*Test\.php + tests/ + +``` + +#### Ignoring specific rules in path + +```xml + + + src/deprecated + +``` + +#### Ignoring rules from ruleset + +```xml + + + + + + +``` + +### Configuring + +#### Configuring your own rule + +```xml + + + + + + + +``` ## Development