Skip to content

Commit 37252d9

Browse files
Added PHP validators.
Added the PHPCS/WPCS validators to validate the project is compliant to the coding standards. Added shortcut scripts to composer for both Mac and Windows.
1 parent b295ffc commit 37252d9

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

composer.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,27 @@
2525
"php": "^5.6|^7",
2626
"brain/monkey": "^2.2",
2727
"composer/installers": "^1.4",
28-
"phpunit/phpunit": "~5.7.9"
28+
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4",
29+
"phpunit/phpunit": "~5.7.9",
30+
"roave/security-advisories": "dev-master",
31+
"sirbrillig/phpcs-variable-analysis": "^2.0",
32+
"squizlabs/php_codesniffer": "^3.2",
33+
"wimg/php-compatibility": "^8.0",
34+
"wp-coding-standards/wpcs": "^0.14.1"
2935
},
3036
"config": {
3137
"sort-order": true
3238
},
3339
"scripts": {
40+
"install-codestandards": [
41+
"Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run"
42+
],
43+
"phpcs-src": "\"vendor/bin/phpcs\"",
44+
"phpcs-tests": "\"vendor/bin/phpcs\" --runtime-set testVersion 5.6 tests/php/",
45+
"run-phpcs": [
46+
"@phpcs-src",
47+
"@phpcs-tests"
48+
],
3449
"test-unit": "\"vendor/bin/phpunit\" --testsuite unit --color=always",
3550
"test-integration": "\"vendor/bin/phpunit\" --testsuite integration --configuration tests/php/integration/phpunit.xml.dist --color=always",
3651
"run-tests": [

phpcs.xml.dist

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="GitContributing">
3+
<description>The code standard for your plugin.</description>
4+
5+
<file>.</file>
6+
7+
<!-- Ignore these directories -->
8+
<exclude-pattern>*/dist/*</exclude-pattern>
9+
<exclude-pattern>node_modules/*</exclude-pattern>
10+
<exclude-pattern>*/vendor/*</exclude-pattern>
11+
<exclude-pattern>*/vendors/*</exclude-pattern>
12+
<exclude-pattern>*/index.php</exclude-pattern>
13+
14+
<!-- PHP only. We'll use other validators for JS, CSS, etc. -->
15+
<arg name="extensions" value="php"/>
16+
17+
<!-- Reporting Configuration -->
18+
<arg name="colors" />
19+
<arg value="sp"/>
20+
<arg name="report" value="full"/>
21+
<arg name="report" value="summary"/>
22+
<arg name="report" value="source"/>
23+
24+
<!-- PHP Rules -->
25+
<config name="testVersion" value="5.6-"/>
26+
27+
<!-- WordPress Rules -->
28+
<rule ref="WordPress">
29+
<exclude name="WordPress.VIP"/>
30+
</rule>
31+
32+
<rule ref="WordPress.Files.FileName">
33+
<properties>
34+
<property name="strict_class_file_names" value="false"/>
35+
</properties>
36+
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase"/>
37+
</rule>
38+
39+
<rule ref="WordPress.WhiteSpace.ControlStructureSpacing">
40+
<properties>
41+
<property name="blank_line_check" value="true" />
42+
</properties>
43+
</rule>
44+
45+
<rule ref="WordPress.WP.DeprecatedFunctions">
46+
<properties>
47+
<property name="minimum_supported_version" value="4.8" />
48+
</properties>
49+
</rule>
50+
51+
<rule ref="WordPress.WP.I18n">
52+
<properties>
53+
<property name="text_domain" type="array" value="git-contributing" />
54+
</properties>
55+
</rule>
56+
</ruleset>

0 commit comments

Comments
 (0)