Browse Source

Test phpstan

Laurent Destailleur 1 year ago
parent
commit
23b35492fd
3 changed files with 17 additions and 9 deletions
  1. 10 2
      build/phpstan/README
  2. 0 5
      build/phpstan/bootstrap.php
  3. 7 2
      phpstan.neon

+ 10 - 2
build/phpstan/README

@@ -4,6 +4,14 @@ https://phpstan.org
 
 PHPStan requires PHP >= 7.1
 
-Install:  composer require --dev phpstan/phpstan
-
 Config File:  phpstan.neon
+
+Install:  
+cd git
+mkdir phpstan
+cd phpstan
+composer require --dev phpstan/phpstan
+
+Execute:
+cd git/dolibarr
+php8.2 ../phpstan/htdocs/includes/bin/phpstan -v analyze -a build/phpstan/bootstrap.php htdocs/commande/class -l0 --memory-limit 2G

+ 0 - 5
build/phpstan/bootstrap.php

@@ -1,9 +1,4 @@
 <?php
-// Example to use PHPStan
-// cd git/dolibarr
-// /usr/bin/php7.2 /pathtophpstan/phpstan.phar -l1 analyze htdocs/societe/website.php --memory-limit 2G
-// /usr/bin/php7.2 /pathtophpstan/phpstan analyze htdocs/societe/website.php --memory-limit 2G
-
 // Defined some constants and load Dolibarr env to reduce PHPStan bootstrap that fails to load a lot of things.
 define('DOL_DOCUMENT_ROOT', __DIR__ . '/../../htdocs');
 define('DOL_DATA_ROOT', __DIR__ . '/../../documents');

+ 7 - 2
phpstan.neon

@@ -2,6 +2,13 @@ parameters:
 	customRulesetUsed: true
 	fileExtensions:
 		- php
+	excludePaths:
+		- 'htdocs/build/*'
+		- 'htdocs/dev/*'
+		- 'htdocs/includes/*'
+		- 'htdocs/install/doctemplates/*'
+		- 'htdocs/langs/*'
+		- 'htdocs/test/*'
 	checkAlwaysTrueCheckTypeFunctionCall: false
 	checkAlwaysTrueInstanceof: false
 	checkAlwaysTrueStrictComparison: false
@@ -37,12 +44,10 @@ parameters:
 	    nodesByFileCountMax: 512
 	    nodesByStringCountMax: 512
 	reportUnmatchedIgnoredErrors: true
-	scopeClass: PHPStan\Analyser\Scope
 	universalObjectCratesClasses:
 		- stdClass
 		- SimpleXMLElement
 	earlyTerminatingMethodCalls: []
-	memoryLimitFile: %tmpDir%/.memory_limit
 	dynamicConstantNames:
 		- ICONV_IMPL
 		- PHP_VERSION