Commit 87af36f7 authored by Fabrice Gangler's avatar Fabrice Gangler 🎨
Browse files

CHORE(QA): add PHP_CodeSniffer (phpcs) dependency

documentation:
https://phpqa.io/projects/phpcs.html
https://github.com/squizlabs/PHP_CodeSniffer/wiki

# install
composer require --dev "squizlabs/php_codesniffer"

# Show rules and coding standards
vendor/bin/phpcs -i  #  list of installed coding standards
vendor/bin/phpcs -e  #  list of rules used by .phpcs.xml config

# Check files based on .phpcs.xml config
vendor/bin/phpcs

Refs: #27
parent 2c3b68fe
......@@ -14,3 +14,8 @@
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###
###> squizlabs/php_codesniffer ###
/.phpcs-cache
/phpcs.xml
###< squizlabs/php_codesniffer ###
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"
name="Custom Standard"
namespace="MyProject\CS\Standard">
<!--
If no files or directories are specified on the command line
your custom standard can specify what files should be checked
instead.
Note that file and directory paths specified in a ruleset are
relative to the ruleset's location, and that specifying any file or
directory path on the command line will ignore all file tags.
-->
<file>config/</file>
<file>src/</file>
<file>tests/</file>
<file>templates/</file>
<file>public/</file>
<!-- <file>bin/</file> -->
<!--
Include all sniffs in the x standard. Note that the
path to the standard does not have to be specified as the
x standard exists inside the PHP_CodeSniffer install directory.
-->
<rule ref="PSR12">
<!-- <exclude-pattern>bin/.phpunit/</exclude-pattern> -->
</rule>
<!-- <rule ref="PHPCompatibility"/>-->
<!--
You can hard-code command line values into your custom standard.
Note that this does not work for the command line values:
-v[v][v], -l, -d, -·-sniffs and -·-standard
-->
<arg value="s"/> <!-- Show sniff codes in all reports -->
<arg name="colors"/>
<arg name="basepath" value="."/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="extensions" value="php"/>
<!-- Summary report: each filename with number of errors + warnings -->
<!-- <arg name="report" value="summary"/> -->
<!-- Source report: each sniff with numbers of failed files -->
<!-- <arg name="report" value="source"/> -->
</ruleset>
......@@ -43,6 +43,7 @@
"phpmd/phpmd": "^2.8",
"phpro/grumphp": "^0.18.0",
"sensiolabs/security-checker": "^6.0",
"squizlabs/php_codesniffer": "^3.5",
"symfony/browser-kit": "5.0.*",
"symfony/css-selector": "5.0.*",
"symfony/debug-pack": "*",
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "5fa612fd13e35b76af8b03c02f72ad1a",
"content-hash": "7191ed98ff676fe9d8e6b9b356b95d59",
"packages": [
{
"name": "doctrine/annotations",
......@@ -6934,6 +6934,57 @@
"description": "A security checker for your composer.lock",
"time": "2019-11-01T13:20:14+00:00"
},
{
"name": "squizlabs/php_codesniffer",
"version": "3.5.4",
"source": {
"type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "dceec07328401de6211037abbb18bda423677e26"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dceec07328401de6211037abbb18bda423677e26",
"reference": "dceec07328401de6211037abbb18bda423677e26",
"shasum": ""
},
"require": {
"ext-simplexml": "*",
"ext-tokenizer": "*",
"ext-xmlwriter": "*",
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
},
"bin": [
"bin/phpcs",
"bin/phpcbf"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.x-dev"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Greg Sherwood",
"role": "lead"
}
],
"description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
"homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
"keywords": [
"phpcs",
"standards"
],
"time": "2020-01-30T22:20:29+00:00"
},
{
"name": "symfony/browser-kit",
"version": "v5.0.4",
......
......@@ -116,20 +116,20 @@ parameters:
# triggered_by: ['composer.json', 'composer.lock', '*.php']
##
## PHP CodeSniffer: https://github.com/phpro/grumphp/blob/master/doc/tasks/phpcs.md
# phpcs:
# standard: []
# severity: ~
# error_severity: ~
# warning_severity: ~
# tab_width: ~
# report: full
# report_width: ~
# whitelist_patterns: []
# encoding: ~
# ignore_patterns: []
# sniffs: []
# triggered_by: [php]
# exclude: []
phpcs:
standard: []
severity: ~
error_severity: ~
warning_severity: ~
tab_width: ~
report: full
report_width: ~
whitelist_patterns: []
encoding: ~
ignore_patterns: []
sniffs: []
triggered_by: [php]
exclude: []
##
## PHP Copy/Paste Detector: https://github.com/phpro/grumphp/blob/master/doc/tasks/phpcpd.md
## -----> scan every file, everytime!
......
......@@ -186,6 +186,18 @@
"config/packages/sensio_framework_extra.yaml"
]
},
"squizlabs/php_codesniffer": {
"version": "3.0",
"recipe": {
"repo": "github.com/symfony/recipes-contrib",
"branch": "master",
"version": "3.0",
"ref": "0dc9cceda799fd3a08b96987e176a261028a3709"
},
"files": [
"phpcs.xml.dist"
]
},
"symfony/asset": {
"version": "v5.0.4"
},
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment