Commit 1ed7239
authored
Add lint check for class autoloading PSR compliance (#845)
Fixes #844.
Running `composer dump-autoload --optimize --strict-psr
--strict-ambiguous` in current `master` branch yields:
```
~ composer dump-autoload --optimize --strict-psr --strict-ambiguous
Generating optimized autoload files
Warning: Ambiguous class resolution, "Stringable" was found in both "<path-to-repo>/json-schema/vendor/marc-mabe/php-enum/stubs/Stringable.php" and "<path-to-repo>/json-schema/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php", the first will be used.
To resolve ambiguity in classes not under your control you can ignore them by path using exclude-files-from-classmap
Class Tool\Validator\UriValidatorTest located in ./tests/Tool/Validator/UriValidatorTest.php does not comply with psr-4 autoloading standard (rule: JsonSchema\Tests\ => ./tests). Skipping.
Class Tool\Validator\RelativeReferenceValidatorTest located in ./tests/Tool/Validator/RelativeReferenceValidatorTest.php does not comply with psr-4 autoloading standard (rule: JsonSchema\Tests\ => ./tests). Skipping.
Generated optimized autoload files containing 1845 classes
```
The namespace of the two test files is addressed as part of this PR.
The `\Stringable` ambiguity is more problematic. `symfony/polyfill-80`
is a transitive dev dependency only, so it can be solved by excluding
the dev dependencies. Is linting with `--no-dev` enough? Otherwise using
`exclude-files-from-classmap` is an option.1 parent ac0d369 commit 1ed7239
File tree
4 files changed
+8
-2
lines changed- .github/workflows
- tests/Tool/Validator
4 files changed
+8
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
0 commit comments