{"id":13607894,"url":"https://github.com/shipmonk-rnd/name-collision-detector","last_synced_at":"2025-04-12T14:31:23.535Z","repository":{"id":65013901,"uuid":"580732689","full_name":"shipmonk-rnd/name-collision-detector","owner":"shipmonk-rnd","description":"Fast \u0026 simple tool to find class duplicates in your projects.","archived":false,"fork":false,"pushed_at":"2025-03-17T11:44:57.000Z","size":273,"stargazers_count":31,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T06:31:28.671Z","etag":null,"topics":["ambiguous","classname","collission","duplicate","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shipmonk-rnd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-21T10:02:36.000Z","updated_at":"2025-03-17T11:44:59.000Z","dependencies_parsed_at":"2024-03-12T10:51:20.651Z","dependency_job_id":"4ef0e0f0-5108-43a3-bcbc-69cd15805c50","html_url":"https://github.com/shipmonk-rnd/name-collision-detector","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"fa14fc86bfbf7d12ba0a58f2603081e669991c03"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shipmonk-rnd%2Fname-collision-detector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shipmonk-rnd%2Fname-collision-detector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shipmonk-rnd%2Fname-collision-detector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shipmonk-rnd%2Fname-collision-detector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shipmonk-rnd","download_url":"https://codeload.github.com/shipmonk-rnd/name-collision-detector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248581149,"owners_count":21128110,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ambiguous","classname","collission","duplicate","php"],"created_at":"2024-08-01T19:01:22.609Z","updated_at":"2025-04-12T14:31:23.526Z","avatar_url":"https://github.com/shipmonk-rnd.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Name collision detector\n\nSimple tool which allows you to detect if there are no types defined multiple times within the same namespace.\nThis means that any ambiguous class, interface, enum, trait, constant or function is reported.\nNon-zero exit code is returned when any duplicate is found.\n\n## Installation:\n\n```sh\ncomposer require --dev shipmonk/name-collision-detector\n```\n\n## Usage:\nCheck duplicate types:\n```sh\nvendor/bin/detect-collisions dir1 dir2 dir3 # relative to cwd\n```\n\nExample error output:\n```\nFoo\\NamespacedClass2 is defined 2 times:\n \u003e /tests/sample-collisions/file2.php:23\n \u003e /tests/sample-collisions/file2.php:45\n\nGlobalInterface1 is defined 2 times:\n \u003e /tests/sample-collisions/file1.php:8\n \u003e /tests/sample-collisions/file2.php:11\n```\n\nExample success output:\n```\nOK (no name collision found)\n * analysed files: 9867\n * excluded files: 0\n * elapsed time: 1.057 s\n```\n\n- Note the performance: **10 000 files takes few seconds**!\n\n## Configuration:\nIf file named `collision-detector.json` is present within current working directory, its contents are taken as configuration options. Possible config options:\n```json5\n{\n    \"scanPaths\": [\"src\", \"tests\"], // files/directories to scan, relative to config file directory, glob not supported\n    \"excludePaths\": [\"tests/collisions\"], // files/directories to exclude, relative to config file directory, glob not supported\n    \"fileExtensions\": [\"php\"], // file extensions to parse\n    \"ignoreParseFailures\": false // skip files with parse errors or not\n}\n```\nPaths provided by CLI arguments have priority over those in `scanDirs`.\n\nYou can provide custom path to config file by `vendor/bin/detect-collisions --configuration path/to/config.json`\n\n## Reasoning\nHaving colliding classes within project can cause crazy headaches while debugging why something works only sometimes.\nTypically, you have PSR-4 autoloading which often solves this problem for you, but there are cases (like [PHPStan rules test files](https://github.com/shipmonk-rnd/phpstan-rules/tree/master/tests/Rule/data)) where you want to write any code (with [classmap](https://getcomposer.org/doc/04-schema.md#classmap) autoloading).\nAnd in such cases, the test may work when executed in standalone run, but fail when running all the tests together (depending on which class was autoloaded first).\nTherefore, having a collision detector in CI might be useful.\n\n## Composer's ambiguous class resolution\nComposer can also detect class duplicates and exit with non-zero, but it runs much slower and lacks function and constant detection. Using composer version `\u003e= 2.8.1`, you can use:\n```sh\ncomposer dump --optimize --strict-ambiguous\n```\n\n## Supported PHP versions\n- PHP 7.2 - PHP 8.4\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshipmonk-rnd%2Fname-collision-detector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshipmonk-rnd%2Fname-collision-detector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshipmonk-rnd%2Fname-collision-detector/lists"}