mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-09-27 20:02:01 +02:00
PHP-CS-Fixer's `no_unused_imports` is conservative — it treats a class name that merely appears in a PHPDoc *description* as "used", so genuinely-dead imports (e.g. `use ...Request;` next to a "Request IP" doc description) were never flagged. Slevomat's UnusedUses is precise: it parses annotation *types* (@param/@return/@var), so it keeps docblock-typed imports but removes truly unused ones — matching what Intelephense (P1003) reports. - Swap require-dev: friendsofphp/php-cs-fixer -> squizlabs/php_codesniffer + slevomat/coding-standard (+ phpcodesniffer-composer-installer, allow-listed). - New narrow ruleset build/phpcs.xml.dist (import/namespace hygiene only, NOT full PSR-12): UnusedUses (searchAnnotations=true), UseFromSameNamespace, UseDoesNotStartWithBackslash, AlphabeticallySortedUses, UseSpacing, NamespaceSpacing. View templates stay excluded. - Makefile: `make cs` -> phpcs, `make cs-fix` -> phpcbf (same target names). - CI code-style job, CLAUDE.md, CONTRIBUTING.md, docs, .gitignore updated; build/.php-cs-fixer.dist.php removed. Committed vendor stays production-only.
61 lines
2.8 KiB
XML
61 lines
2.8 KiB
XML
<?xml version="1.0"?>
|
|
<ruleset name="XC_VM">
|
|
<description>
|
|
Import / namespace hygiene only (NOT full PSR-12) — a 1:1 replacement for
|
|
the previous narrow PHP-CS-Fixer ruleset, using phpcs + Slevomat. The win
|
|
over PHP-CS-Fixer: UnusedUses is precise — it does not treat a class name
|
|
that merely appears in a PHPDoc description as "used".
|
|
Run via `make cs` (report) / `make cs-fix` (auto-fix, = phpcbf).
|
|
</description>
|
|
|
|
<!-- Analyzed set mirrors the old cs-fixer Finder (paths passed on the CLI by
|
|
the Makefile; these are the exclusions). -->
|
|
<exclude-pattern>*/vendor/*</exclude-pattern>
|
|
<exclude-pattern>*/Infrastructure/Tmdb/lib/*</exclude-pattern>
|
|
<exclude-pattern>*/tmp/*</exclude-pattern>
|
|
<exclude-pattern>*/backups/*</exclude-pattern>
|
|
<exclude-pattern>*/Public/Views/*</exclude-pattern>
|
|
<exclude-pattern>*/Modules/*/views/*</exclude-pattern>
|
|
|
|
<arg name="extensions" value="php"/>
|
|
<arg name="colors"/>
|
|
<arg value="p"/><!-- show progress -->
|
|
|
|
<!-- no_unused_imports (precise): remove `use` that is not referenced. -->
|
|
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
|
|
<properties>
|
|
<!-- true = also treat class names used in PHPDoc TYPE positions
|
|
(@param/@return/@var/@throws) as "used", so imports referenced
|
|
only from a docblock type are NOT removed. (searchAnnotations
|
|
parses annotation types, not free-text descriptions.) -->
|
|
<property name="searchAnnotations" value="true"/>
|
|
</properties>
|
|
</rule>
|
|
<!-- Drop a `use` that points at the file's own namespace. -->
|
|
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
|
|
|
|
<!-- no_leading_import_slash: `use \Foo;` -> `use Foo;` -->
|
|
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
|
|
|
|
<!-- ordered_imports: alphabetically sorted `use` statements. -->
|
|
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
|
|
|
|
<!-- single_line_after_imports + no_extra_blank_lines[use]:
|
|
exactly one blank line before/after the use block, none between. -->
|
|
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
|
|
<properties>
|
|
<property name="linesCountBeforeFirstUse" value="1"/>
|
|
<property name="linesCountBetweenUseTypes" value="0"/>
|
|
<property name="linesCountAfterLastUse" value="1"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- blank_line_after_namespace: exactly one blank line around `namespace`. -->
|
|
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing">
|
|
<properties>
|
|
<property name="linesCountBeforeNamespace" value="1"/>
|
|
<property name="linesCountAfterNamespace" value="1"/>
|
|
</properties>
|
|
</rule>
|
|
</ruleset>
|