-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from geerteltink/feat/slevomat7
feat: upgrade to slevomat/coding-standard 7 with enhanced PHP 8 support
- Loading branch information
Showing
8 changed files
with
76 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,8 @@ | |
|
||
The coding standard ruleset for Laminas components. | ||
|
||
This specification extends and expands [PSR-12](https://github.com/php-fig/fig-standards/blob/master/proposed/extended-coding-style-guide.md), | ||
the extended coding style guide and requires adherence to [PSR-1](https://www.php-fig.org/psr/psr-1), | ||
This specification extends and expands [PSR-12](https://github.com/php-fig/fig-standards/blob/master/proposed/extended-coding-style-guide.md), | ||
the extended coding style guide and requires adherence to [PSR-1](https://www.php-fig.org/psr/psr-1), | ||
the basic coding standard. These are minimal specifications and don't address all factors, including things like: | ||
|
||
- whitespace around operators | ||
|
@@ -15,16 +15,16 @@ the basic coding standard. These are minimal specifications and don't address al | |
- what and what not to import, and how | ||
- etc. | ||
|
||
Contributors have different coding styles and so do the maintainers. During code reviews there are regularly | ||
discussions about spaces and alignments, where and when was said that a function needs to be imported. And | ||
Contributors have different coding styles and so do the maintainers. During code reviews there are regularly | ||
discussions about spaces and alignments, where and when was said that a function needs to be imported. And | ||
that's where this coding standard comes in: To have internal consistency in a component and between components. | ||
|
||
## Installation | ||
|
||
1. Install the module via composer by running: | ||
|
||
```bash | ||
$ composer require --dev laminas/laminas-coding-standard | ||
composer require --dev laminas/laminas-coding-standard | ||
``` | ||
|
||
2. Add composer scripts into your `composer.json`: | ||
|
@@ -42,21 +42,21 @@ that's where this coding standard comes in: To have internal consistency in a co | |
<?xml version="1.0"?> | ||
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"> | ||
|
||
<arg name="basepath" value="."/> | ||
<arg name="cache" value=".phpcs-cache"/> | ||
<arg name="colors"/> | ||
<arg name="extensions" value="php"/> | ||
<arg name="parallel" value="80"/> | ||
|
||
<!-- Show progress --> | ||
<arg value="p"/> | ||
|
||
<!-- Paths to check --> | ||
<file>config</file> | ||
<file>src</file> | ||
<file>test</file> | ||
|
||
<!-- Include all rules from the Laminas Coding Standard --> | ||
<rule ref="LaminasCodingStandard"/> | ||
</ruleset> | ||
|
@@ -67,16 +67,16 @@ For a reference please see: https://github.com/squizlabs/PHP_CodeSniffer/wiki/An | |
|
||
## Usage | ||
|
||
* To run checks only: | ||
- To run checks only: | ||
|
||
```bash | ||
$ composer cs-check | ||
composer cs-check | ||
``` | ||
|
||
* To automatically fix many CS issues: | ||
- To automatically fix many CS issues: | ||
|
||
```bash | ||
$ composer cs-fix | ||
composer cs-fix | ||
``` | ||
|
||
## Ignoring parts of a File | ||
|
@@ -85,6 +85,7 @@ For a reference please see: https://github.com/squizlabs/PHP_CodeSniffer/wiki/An | |
> used. These are deprecated and will be removed in PHP_CodeSniffer version 4.0. | ||
Disable parts of a file: | ||
|
||
```php | ||
$xmlPackage = new XMLPackage; | ||
// phpcs:disable | ||
|
@@ -94,6 +95,7 @@ $xmlPackage->send(); | |
``` | ||
|
||
Disable a specific rule: | ||
|
||
```php | ||
// phpcs:disable Generic.Commenting.Todo.Found | ||
$xmlPackage = new XMLPackage; | ||
|
@@ -104,6 +106,7 @@ $xmlPackage->send(); | |
``` | ||
|
||
Ignore a specific violation: | ||
|
||
```php | ||
$xmlPackage = new XMLPackage; | ||
$xmlPackage['error_code'] = get_default_error_code_value(); | ||
|
@@ -114,11 +117,12 @@ $xmlPackage->send(); | |
|
||
## Development | ||
|
||
> **New rules or Sniffs may not be introduced in minor or bugfix releases and should always be based on the develop | ||
> **New rules or Sniffs may not be introduced in minor or bugfix releases and should always be based on the develop | ||
branch and queued for the next major release, unless considered a bugfix for existing rules.** | ||
|
||
If you want to test changes against Laminas components or your own projects, install your forked | ||
laminas-coding-standard globally with composer: | ||
If you want to test changes against Laminas components or your own projects, install your forked | ||
laminas-coding-standard globally with composer: | ||
|
||
```bash | ||
$ composer global config repositories.laminas-coding-standard vcs [email protected]:<FORK_NAMESPACE>/laminas-coding-standard.git | ||
$ composer global require --dev laminas/laminas-coding-standard:dev-<FORKED_BRANCH> | ||
|
@@ -127,9 +131,10 @@ $ composer global require --dev laminas/laminas-coding-standard:dev-<FORKED_BRAN | |
# Using `-s` prints the rules that triggered the errors so they can be reviewed easily. `-p` is for progress display. | ||
$ phpcs -sp --standard=LaminasCodingStandard src test | ||
``` | ||
|
||
Make sure you remove the global installation after testing from your global composer.json file!!! | ||
|
||
Documentation can be previewed locally by installing [MkDocs](https://www.mkdocs.org/#installation) and run | ||
Documentation can be previewed locally by installing [MkDocs](https://www.mkdocs.org/#installation) and run | ||
`mkdocs serve`. This will start a server where you can read the docs. | ||
|
||
## Reference | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters