Browse Source

feat(dev-tools): Mise en place phpcs+phpstan (#4777)

Co-authored-by: JamesRezo <james@rezo.net>
Reviewed-on: #4777
Co-authored-by: JamesRezo <jamesrezo@noreply.git.spip.net>
Co-committed-by: JamesRezo <jamesrezo@noreply.git.spip.net>
pull/4779/head
JamesRezo 1 year ago
parent
commit
46f3977b67
  1. 7
      .gitignore
  2. 7
      composer.json
  3. 11
      inc/safehtml.php
  4. 16
      phpcs.xml.dist
  5. 17
      phpstan-baseline.neon
  6. 14
      phpstan.neon.dist

7
.gitignore vendored

@ -0,0 +1,7 @@
/vendor/
/composer.phar
/composer.lock
/phpcs.xml
/phpstan.neon
/.php_cs.cache
/.php_cs.txt

7
composer.json

@ -0,0 +1,7 @@
{
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
"spip/coding-standards": "^1.2",
"phpstan/phpstan": "^0.12.98"
}
}

11
inc/safehtml.php

@ -10,7 +10,6 @@
* Pour plus de détails voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
@ -40,12 +39,12 @@ function inc_safehtml_dist($t) {
if ($test > 0) {
# reset ($process->clear() ne vide que _xhtml...),
# on doit pouvoir programmer ca plus propremement
$process->_counter = array();
$process->_stack = array();
$process->_dcCounter = array();
$process->_dcStack = array();
$process->_counter = [];
$process->_stack = [];
$process->_dcCounter = [];
$process->_dcStack = [];
$process->_listScope = 0;
$process->_liStack = array();
$process->_liStack = [];
# $process->parse(''); # cas particulier ?
$process->clear();
$t = $process->parse($t);

16
phpcs.xml.dist

@ -0,0 +1,16 @@
<?xml version="1.0"?>
<ruleset>
<file>.</file>
<exclude-pattern>vendor/*</exclude-pattern>
<exclude-pattern>lang/*</exclude-pattern>
<exclude-pattern>lib/*</exclude-pattern>
<exclude-pattern>tests/*</exclude-pattern>
<rule ref="SPIP41"/>
<config name="ignore_warnings_on_exit" value="1"/>
<arg name="cache" value=".php_cs.cache"/>
<arg name="report-full" value=".php_cs.txt"/>
<arg name="report-summary"/>
<arg value="s"/>
</ruleset>

17
phpstan-baseline.neon

@ -0,0 +1,17 @@
parameters:
ignoreErrors:
-
message: "#^Class SafeHTML referenced with incorrect case\\: safehtml\\.$#"
count: 1
path: inc/safehtml.php
-
message: "#^Function entites_html not found\\.$#"
count: 1
path: inc/safehtml.php
-
message: "#^Function find_in_path not found\\.$#"
count: 1
path: inc/safehtml.php

14
phpstan.neon.dist

@ -0,0 +1,14 @@
includes:
- phpstan-baseline.neon
parameters:
paths:
- .
excludePaths:
analyseAndScan:
- vendor
- lang
- tests
analyse:
- lib
level: 0
Loading…
Cancel
Save