Skip to content

Commit

Permalink
Update standards for PHP8
Browse files Browse the repository at this point in the history
  • Loading branch information
defunctl committed Sep 2, 2022
1 parent 75bce86 commit e053917
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 40 deletions.
65 changes: 35 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ rules for use primarily with the [SquareOne](https://github.com/moderntribe/squa

## Requirements

- PHP7.4+
- PHP ^8.0

## Install

Expand Down Expand Up @@ -34,40 +34,45 @@ And `require-dev`:

## Project ruleset

> Ensure you're running PHP 8.0 locally!
To use this ruleset, create a `phpcs.xml.dist` in the root of the project and add the following content:
```xml
<?xml version="1.0"?>
<ruleset>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="severity" value="4"/>
<arg name="tab-width" value="4"/>
<arg name="parallel" value="80"/>
<arg name="colors"/>
<!-- Update to the PHP version your production/local docker container runs on -->
<config name="testVersion" value="7.4"/>
<!-- php -r 'echo PHP_VERSION_ID;' -->
<config name="php_version" value="70407"/>
<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>
<!-- Directories to be checked -->
<file>./wp-content/plugins/core</file>
<file>./wp-content/themes/core</file>
<file>./wp-content/mu-plugins</file>
<!-- Exclude files -->
<exclude-pattern>*-config.php</exclude-pattern>
<exclude-pattern>*vendor/</exclude-pattern>
<exclude-pattern>*tests/*</exclude-pattern>
<exclude-pattern>*.twig</exclude-pattern>
<exclude-pattern>*webpack/</exclude-pattern>
<!-- Include the Modern Tribe coding standard -->
<rule ref="ModernTribe"/>
<arg name="basepath" value="." />
<arg name="extensions" value="php" />
<arg name="severity" value="4" />
<arg name="tab-width" value="4" />
<arg name="parallel" value="80" />
<arg name="colors" />
<!-- Update to the PHP version your production/local docker container runs on -->
<config name="testVersion" value="8.0" />
<!-- php -r 'echo PHP_VERSION_ID;' -->
<config name="php_version" value="80022" />
<!-- Fix WordPress's terrible typing breaking PHPCS -->
<config name="minimum_supported_wp_version" value="5.6.0" />

<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps" />

<!-- Directories to be checked -->
<file>./wp-content/plugins/core</file>
<file>./wp-content/themes/core</file>
<file>./wp-content/mu-plugins</file>

<!-- Exclude files -->
<exclude-pattern>*-config.php</exclude-pattern>
<exclude-pattern>*vendor/</exclude-pattern>
<exclude-pattern>*tests/*</exclude-pattern>
<exclude-pattern>*.twig</exclude-pattern>
<exclude-pattern>*webpack/</exclude-pattern>

<!-- Include the Modern Tribe coding standard -->
<rule ref="ModernTribe" />
</ruleset>
```

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"license": "MIT",
"require": {
"php": ">=7.4",
"php": "^8.0",
"automattic/vipwpcs": "^2.3",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
"cweagans/composer-patches": "^1.7",
Expand Down
17 changes: 9 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion lib/ModernTribe/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@
</properties>
</rule>
<!-- Checks for missing return typehints in case they can be declared natively -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint" />
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification" />
</rule>

<!-- Require space around colon in return types -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
Expand Down

0 comments on commit e053917

Please sign in to comment.