Skip to content

Commit

Permalink
Merge pull request #12 from inpsyde/docs
Browse files Browse the repository at this point in the history
Fix and improve docs
  • Loading branch information
tfrommen authored Jan 27, 2025
2 parents 01df6cf + 8632829 commit 5eef494
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 33 deletions.
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -128,6 +128,7 @@ A minimum working example could look like so:
```xml
<?xml version="1.0"?>
<ruleset>

<!-- Minimum required Syde PHP Coding Standard rules. -->
<rule ref="Syde-Core" />

Expand All @@ -150,6 +151,7 @@ Here is a real-world example including files and folders to check, as well as so
```xml
<?xml version="1.0"?>
<ruleset>

<!-- Check for cross-version support for PHP 8.1 and higher. -->
<config name="testVersion" value="8.1-" />

Expand Down Expand Up @@ -178,16 +180,16 @@ Here is a real-world example including files and folders to check, as well as so

<!-- Do not report on function length for tests. -->
<rule ref="Syde.Functions.FunctionLength">
<exclude-pattern>*/tests/cases/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>

<!-- PSR-4 namespace configuration. -->
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<properties>
<property name="rootNamespaces" type="array">
<element key="src" value="MyCompany\MyProject" />
<element key="tests/cases" value="MyCompany\MyProject\Tests" />
<element key="tests/src" value="MyCompany\MyProject\Tests" />
<element key="tests/unit" value="MyCompany\MyProject\Tests" />
</property>
</properties>
</rule>
Expand Down
32 changes: 16 additions & 16 deletions docs/Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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.

Expand All @@ -163,12 +163,12 @@ The `Inpsyde.CodeQuality.Psr4` sniff has a public `array` property, `$psr4`, tha

```xml
<rule ref="Inpsyde.CodeQuality.Psr4">
<properties>
<property name="psr4" type="array">
<element key="MyCompany\MyProject" value="src"/>
<element key="MyCompany\MyProject\Tests" value="tests/src|tests/e2e|tests/unit"/>
</property>
</properties>
<properties>
<property name="psr4" type="array">
<element key="MyCompany\MyProject" value="src"/>
<element key="MyCompany\MyProject\Tests" value="tests/src|tests/e2e|tests/unit"/>
</property>
</properties>
</rule>
```

Expand All @@ -178,14 +178,14 @@ An example configuration that matches the above behavior looks like so:

```xml
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<properties>
<property name="rootNamespaces" type="array">
<element key="src" value="MyCompany\MyProject" />
<element key="tests/src" value="MyCompany\MyProject\Tests" />
<element key="tests/e2e" value="MyCompany\MyProject\Tests" />
<element key="tests/unit" value="MyCompany\MyProject\Tests" />
</property>
</properties>
<properties>
<property name="rootNamespaces" type="array">
<element key="src" value="MyCompany\MyProject" />
<element key="tests/src" value="MyCompany\MyProject\Tests" />
<element key="tests/e2e" value="MyCompany\MyProject\Tests" />
<element key="tests/unit" value="MyCompany\MyProject\Tests" />
</property>
</properties>
</rule>
```

Expand Down
4 changes: 2 additions & 2 deletions docs/Sniffs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 5eef494

Please sign in to comment.