Repository: bmitch/churn-php (php)

Issue:
Fix PSR violations
Since [Composer 2.4.0](https://github.com/composer/composer/releases/tag/2.4.0), a new `--strict-psr` flag has been added to `dump-autoload` to check for PSR violations.

Here the result for churn-php:
```sh
# composer dump-autoload --optimize --strict-psr

Generating optimized autoload files
Class Churn\Tests\Integration\Command\Assets\TestAfterAnalysisHook located in ./tests/Integration/Command/Assets/hooks.php does not comply with psr-4 autoloading standard. Skipping.
Class Churn\Tests\Integration\Command\Assets\TestAfterFileAnalysisHook located in ./tests/Integration/Command/Assets/hooks.php does not comply with psr-4 autoloading standard. Skipping.
Class Churn\Tests\Integration\Command\Assets\TestBeforeAnalysisHook located in ./tests/Integration/Command/Assets/hooks.php does not comply with psr-4 autoloading standard. Skipping.
Class Churn\Tests\Unit\Assessors\CyclomaticComplexity\CyclomaticComplexityAssessorTest located in ./tests/Unit/Assessor/CyclomaticComplexityAssessorTest.php does not comply with psr-4 autoloading standard. Skipping.
Class Churn\Tests\Event\Event\AfterAnalysisEventTest located in ./tests/Unit/Event/Event/AfterAnalysisEventTest.php does not comply with psr-4 autoloading standard. Skipping.
Class Churn\Tests\Event\Event\AfterFileAnalysisEventTest located in ./tests/Unit/Event/Event/AfterFileAnalysisEventTest.php does not comply with psr-4 autoloading standard. Skipping.
Class Churn\Tests\Result\HighestScoresTest located in ./tests/Unit/Result/HighestScoresTest.php does not comply with psr-4 autoloading standard. Skipping.
Class Churn\Tests\Result\ResultAccumulatorTest located in ./tests/Unit/Result/ResultAccumulatorTest.php does not comply with psr-4 autoloading standard. Skipping.
Class Churn\Tests\Result\ResultTest located in ./tests/Unit/Result/ResultTest.php does not comply with psr-4 autoloading standard. Skipping.
```

Once these violations will be fixed, it'd be great to run this command in the CI to prevent new violations to appear.


Discussion:

Patch:
diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml
--- a/.github/workflows/continuous-integration.yml
+++ b/.github/workflows/continuous-integration.yml
@@ -183,6 +183,9 @@ jobs:
         with:
           dependency-versions: "highest"
 
+      - name: "Check for PSR-4 violations"
+        run: "composer dump-autoload --optimize --strict-psr --no-scripts"
+
       - name: "Run PHP Mess Detector"
         run: "vendor/bin/phpmd src text phpmd.xml"
 
diff --git a/composer.json b/composer.json
--- a/composer.json
+++ b/composer.json
@@ -69,6 +69,7 @@
         "test": [
             "@composer validate --strict",
             "parallel-lint src tests",
+            "@composer dump-autoload --optimize --strict-psr",
             "phpmd src text phpmd.xml",
             "phploc src",
             "phpcpd src",


Test patch:
diff --git a/tests/Integration/Command/Assets/hooks.php b/tests/Integration/Command/Assets/hooks
similarity index 100%
rename from tests/Integration/Command/Assets/hooks.php
rename to tests/Integration/Command/Assets/hooks
diff --git a/tests/Integration/Command/config/hook-by-path.yml b/tests/Integration/Command/config/hook-by-path.yml
--- a/tests/Integration/Command/config/hook-by-path.yml
+++ b/tests/Integration/Command/config/hook-by-path.yml
@@ -1,2 +1,2 @@
 hooks:
-  - ../Assets/hooks.php
\ No newline at end of file
+  - ../Assets/hooks
\ No newline at end of file
diff --git a/tests/Unit/Assessor/CyclomaticComplexityAssessorTest.php b/tests/Unit/Assessor/CyclomaticComplexityAssessorTest.php
--- a/tests/Unit/Assessor/CyclomaticComplexityAssessorTest.php
+++ b/tests/Unit/Assessor/CyclomaticComplexityAssessorTest.php
@@ -2,7 +2,7 @@
 
 declare(strict_types=1);
 
-namespace Churn\Tests\Unit\Assessors\CyclomaticComplexity;
+namespace Churn\Tests\Unit\Assessor;
 
 use Churn\Tests\BaseTestCase;
 use Churn\Assessor\CyclomaticComplexityAssessor;
diff --git a/tests/Unit/Event/Event/AfterAnalysisEventTest.php b/tests/Unit/Event/Event/AfterAnalysisEventTest.php
--- a/tests/Unit/Event/Event/AfterAnalysisEventTest.php
+++ b/tests/Unit/Event/Event/AfterAnalysisEventTest.php
@@ -2,7 +2,7 @@
 
 declare(strict_types=1);
 
-namespace Churn\Tests\Event\Event;
+namespace Churn\Tests\Unit\Event\Event;
 
 use Churn\Event\Event\AfterAnalysisEvent;
 use Churn\Result\ResultReporter;
diff --git a/tests/Unit/Event/Event/AfterFileAnalysisEventTest.php b/tests/Unit/Event/Event/AfterFileAnalysisEventTest.php
--- a/tests/Unit/Event/Event/AfterFileAnalysisEventTest.php
+++ b/tests/Unit/Event/Event/AfterFileAnalysisEventTest.php
@@ -2,7 +2,7 @@
 
 declare(strict_types=1);
 
-namespace Churn\Tests\Event\Event;
+namespace Churn\Tests\Unit\Event\Event;
 
 use Churn\Event\Event\AfterFileAnalysisEvent;
 use Churn\File\File;
diff --git a/tests/Unit/Result/HighestScoresTest.php b/tests/Unit/Result/HighestScoresTest.php
--- a/tests/Unit/Result/HighestScoresTest.php
+++ b/tests/Unit/Result/HighestScoresTest.php
@@ -2,7 +2,7 @@
 
 declare(strict_types=1);
 
-namespace Churn\Tests\Result;
+namespace Churn\Tests\Unit\Result;
 
 use Churn\Result\ResultInterface;
 use Churn\Result\HighestScores;
diff --git a/tests/Unit/Result/ResultAccumulatorTest.php b/tests/Unit/Result/ResultAccumulatorTest.php
--- a/tests/Unit/Result/ResultAccumulatorTest.php
+++ b/tests/Unit/Result/ResultAccumulatorTest.php
@@ -2,7 +2,7 @@
 
 declare(strict_types=1);
 
-namespace Churn\Tests\Result;
+namespace Churn\Tests\Unit\Result;
 
 use Churn\File\File;
 use Churn\Result\ResultInterface;
diff --git a/tests/Unit/Result/ResultTest.php b/tests/Unit/Result/ResultTest.php
--- a/tests/Unit/Result/ResultTest.php
+++ b/tests/Unit/Result/ResultTest.php
@@ -2,7 +2,7 @@
 
 declare(strict_types=1);
 
-namespace Churn\Tests\Result;
+namespace Churn\Tests\Unit\Result;
 
 use Churn\File\File;
 use Churn\Result\Result;