diff --git a/.gitattributes b/.gitattributes index 581d6e3..ef4dbb7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -10,3 +10,4 @@ /phpstan-baseline.neon export-ignore /phpunit.xml export-ignore /CLAUDE.md export-ignore +collision-detector.json export-ignore diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5e9d53f..0a8faa4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -317,3 +317,29 @@ jobs: with: path: ./tmp key: "result-cache-v1-${{ matrix.php-version }}-${{ github.run_id }}" + + name-collision: + name: "Name Collision Detector" + + runs-on: "ubuntu-latest" + timeout-minutes: 60 + + steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2 + with: + egress-policy: audit + + - name: "Checkout" + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 + + - name: "Install PHP" + uses: "shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1" # v2 + with: + coverage: "none" + php-version: "8.5" + + - uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # v3 + + - name: "Name Collision Detector" + run: "make name-collision" diff --git a/Makefile b/Makefile index c58ca06..98acaec 100644 --- a/Makefile +++ b/Makefile @@ -31,3 +31,6 @@ phpstan: .PHONY: phpstan-generate-baseline phpstan-generate-baseline: php vendor/bin/phpstan analyse -c phpstan.neon -b phpstan-baseline.neon + +name-collision: + php vendor/bin/detect-collisions --configuration collision-detector.json diff --git a/collision-detector.json b/collision-detector.json new file mode 100644 index 0000000..1d85c2b --- /dev/null +++ b/collision-detector.json @@ -0,0 +1,3 @@ +{ + "scanPaths": ["src", "tests"] +} diff --git a/composer.json b/composer.json index 2562485..308327f 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,8 @@ "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/phpstan-deprecation-rules": "^2.0", "phpstan/phpstan-strict-rules": "^2.0", - "phpunit/phpunit": "^9.6" + "phpunit/phpunit": "^9.6", + "shipmonk/name-collision-detector": "^2.1" }, "config": { "sort-packages": true diff --git a/tests/Rules/PHPUnit/data/assert-same.php b/tests/Rules/PHPUnit/data/assert-same.php index 8ab297b..0e464a0 100644 --- a/tests/Rules/PHPUnit/data/assert-same.php +++ b/tests/Rules/PHPUnit/data/assert-same.php @@ -1,6 +1,6 @@