From f095afad6ed617aed75f6f3d24a70ed3d3331f89 Mon Sep 17 00:00:00 2001
From: Daniel Speicher <daniel.speicher@lakedrops.com>
Date: Thu, 30 May 2024 15:53:25 +0200
Subject: [PATCH] Document Drupal Development Env:
 composer/plugin/drupal-development-environment#1

---
 .../plugin/drupal-dev-environment/index.md    |  2 +-
 docs/dev_tools/test.md                        | 91 +++++++++++++++++--
 2 files changed, 82 insertions(+), 11 deletions(-)

diff --git a/docs/composer/plugin/drupal-dev-environment/index.md b/docs/composer/plugin/drupal-dev-environment/index.md
index d70d140..ad1ff7f 100644
--- a/docs/composer/plugin/drupal-dev-environment/index.md
+++ b/docs/composer/plugin/drupal-dev-environment/index.md
@@ -15,7 +15,7 @@ It provides a massive amount of testing tools, which can be executed out of the
 - [Dependency Analysis](../../../dev_tools/test.md#drupal-dependency-analysis)
 - [PHP Unit](../../../dev_tools/test.md#unitkernelfunctional-testing)
 - [PHP Code Sniffer](../../../dev_tools/test.md#php-code-sniffer)
-- [PHP PHPStan](../../../dev_tools/test.md#php-code-sniffer)
+- [PHP PHPStan](../../../dev_tools/test.md#php-stan)
 - [PHP Lint](../../../dev_tools/test.md#php-code-sniffer)
 - [PHP LOC](../../../dev_tools/test.md#php-loc)
 - [PHP Mess Detection](../../../dev_tools/test.md#php-mess-detection)
diff --git a/docs/dev_tools/test.md b/docs/dev_tools/test.md
index 5ed81a7..6f521c1 100644
--- a/docs/dev_tools/test.md
+++ b/docs/dev_tools/test.md
@@ -42,24 +42,95 @@ drupal/blazy                  2.16.0             2.27.0       Provides..
 
 We have several tools to perform static code analysis.
 
-* Code Sniffer
-* PHP LOC
-* Mess Detection
+- [PHP Code Sniffer](#php-code-sniffer)
+- [PHP PHPStan](#php-stan)
+- [PHP Lint](#php-code-sniffer)
+- [PHP LOC](#php-loc)
+- [PHP Mess Detection](../../../dev_tools/test.md#php-mess-detection)
+- [PHP Copy and Paste Detector](../../../dev_tools/test.md#php-code-sniffer)
+- [PHP Metrics](../../../dev_tools/test.md#php-code-sniffer)
+- [PHP Stylelint](../../../dev_tools/test.md#php-code-sniffer)
+- [Eslint](../../../dev_tools/test.md#php-code-sniffer)
 
 ### PHP Code Sniffer
 
 PHP Code Sniffer performs a static code analysis with a specific Drupal profile. It detects
 code smells like static calls.
 
-To execute PHP Code Sniffer on the console:
+You can execute PHP CS for a specific Drupal contrib module:
 
-```l3d
+```phpcs
+a test phpcsmodule <contrib_module>
+```
+
+Now the entire code in that module will be analysed.
+
+If you want to analyse a custom module, just do the following:
+
+```phpcs
+a test phpcsmodule ../custom/<custom_module>
+```
+
+To execute PHP Code Sniffer for a file or directory:
+
+```phpcs
 a test phpcs <file_ordirectory>
 ```
 
 Whether it is a directory, it runs the analysis for everything under this directory
 recursively.
 
+Note: **There are many errors, which can be fixed automatically.** If you see something like this:
+
+```phpcs
+FILE: /var/www/html/web/modules/contrib/eca/src/Entity/Model.php
+----------------------------------------------------------------------
+FOUND 1 ERROR AFFECTING 1 LINE
+----------------------------------------------------------------------
+ 37 | ERROR | [x] Additional blank lines found at end of doc comment
+----------------------------------------------------------------------
+PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
+----------------------------------------------------------------------
+```
+You can just execute:
+
+```phpcs
+a test phpcs-fix <contrib_module>
+```
+
+Now th errors are gone, which saves a lot of time and effort.
+
+### PHP Stan
+
+We use level 6 as default, which is pretty good and strict and provides a very clean code. You can adjust this in the
+`phpstan.neon` file. It looks like this:
+
+```phpstan
+parameters:
+  level: 6
+```
+It is recommended to have such a file in every module located in its root path.
+
+You can execute PHP Stan for a specific Drupal contrib module:
+
+```phpstan
+a test phpstanmodule <contrib_module>
+```
+
+Now the entire code in that module will be analysed.
+
+If you want to analyse a custom module, just do the following:
+
+```phpstan
+a test phpstanmodule ../custom/<custom_module>
+```
+
+To execute PHP Stan for a file or directory:
+
+```phpstan
+a test phpstan <file_ordirectory>
+```
+
 Whether it is a directory, it runs the analysis for everything under this directory
 recursively.
 
@@ -69,7 +140,7 @@ PHP LOC prints several metrics about your code, like the average size of a class
 
 To execute PHP LOC on the console:
 
-```l3d
+```phploc
 a test phploc <file_ordirectory>
 ```
 
@@ -84,9 +155,9 @@ uses several profiles like:
 This analysis detects also code smells like the complexity (e.g. number of
 dependencies) of classes.
 
-To execute PHP Code Sniffer on the console:
+To execute PHP Mess Detection on the console:
 
-```l3d
+```phpmd
 a test phpmd <file_ordirectory> json <profile>
 ```
 
@@ -97,7 +168,7 @@ recursively.
 
 To execute the tests, you can use a single command:
 
-```l3d
+```phpunit
 a test phpunit <file_ordirectory>
 ```
 
@@ -144,7 +215,7 @@ You can also use the execution with the debugger.
 
 First, activate the coverage option:
 
-```l3d
+```debug
 a debug coverage
 ```
 
-- 
GitLab