shipmonk/name-collision-detector
Fast CLI tool to detect duplicate names in PHP code: classes, interfaces, traits, enums, functions, and constants defined multiple times in the same namespace. Scans thousands of files in seconds, supports config/excludes, exits non-zero on collisions.
Install the package as a development dependency and run it on your source directories:
composer require --dev shipmonk/name-collision-detector
vendor/bin/detect-collisions src
Start with scanning your src/ directory. The tool will recursively scan all .php files and report any duplicate class, interface, trait, enum, function, or constant names within the same namespace — including global scope. A zero exit code means no collisions; non-zero indicates failures (useful in CI).
vendor/bin/detect-collisions src tests --configuration .collision-detector.json to enforce uniqueness before merging.collision-detector.json to define scanPaths, excludePaths, and fileExtensions for granular control (e.g., exclude test fixtures that intentionally duplicate names for isolation).composer dump --optimize --strict-ambiguous catches class duplicates, this tool adds coverage for functions, constants, and enums, and is significantly faster.vendor/bin/detect-collisions dir1) replace scanPaths from config, not augment it — be explicit."excludePaths": ["tests/fixtures"] in .collision-detector.json means ./tests/fixtures, not ./vendor/bin/../tests/fixtures.collision-detector.json is valid JSON5 (supports comments, trailing commas) — tools like jq or online validators help.ignoreParseFailures: false). If you have intentionally malformed test files (e.g., invalid syntax for testing PHPStan), set this to true.src/* or tests/**/Data; list directories explicitly.scanPaths or excluding test assets.How can I help you explore Laravel packages today?