PHPackages                             s-mcdonald/phpcolliderscope - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. s-mcdonald/phpcolliderscope

ActiveLibrary

s-mcdonald/phpcolliderscope
===========================

Check for php file, class and function namespace collisions.

0.0.2(1mo ago)06MITPHPPHP &gt;=8.3

Since Jul 17Pushed 1mo agoCompare

[ Source](https://github.com/s-mcdonald/PHPColliderScope)[ Packagist](https://packagist.org/packages/s-mcdonald/phpcolliderscope)[ Docs](https://github.com/s-mcdonald/PHPColliderScope)[ RSS](/packages/s-mcdonald-phpcolliderscope/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (12)Versions (5)Used By (0)

PHPColliderScope
================

[](#phpcolliderscope)

PHP namespace collision detection utility. Scans a directory tree of `.php`files and reports classes, interfaces, traits, enums, and functions that are declared more than once under the same fully-qualified name — the kind of thing that silently breaks autoloading when two packages (or two copies of the same package) define the same class.

Install
-------

[](#install)

```
composer require --dev s-mcdonald/phpcolliderscope
```

CLI usage
---------

[](#cli-usage)

```
# No path given -> scans the current working directory
/bin/collider

# Scan a directory and display summary
/bin/collider /path/to/dir

# List every occurrence of each colliding symbol
/bin/collider /path/to/dir --full
```

Files that fail to parse are reported as warnings and skipped, rather than aborting the scan.

Programmatic usage
------------------

[](#programmatic-usage)

```
use FsKit\Directory;
use PHPColliderScope\PHPDocumentParser\DeclarationExtractor;
use PHPColliderScope\PHPDocumentParser\Parser;
use PHPColliderScope\PHPDocumentParser\Tokenizers\PhpBuiltinTokenizer;
use PHPColliderScope\PHPDocumentParser\Tokenizers\Tokenizer;

$parser = new Parser(new DeclarationExtractor(new Tokenizer(new PhpBuiltinTokenizer())));

$report = $parser->inspectForCollisions(Directory::createByFullPathString(__DIR__ . '/src'));

if ($report->hasCollisions()) {
    foreach ($report->collisions() as $collision) {
        printf("%s\n", $collision->symbolName);
    }
}
```

### Building a file list with `FileSet`

[](#building-a-file-list-with-fileset)

Scanning "a directory" isn't always what you want — real projects need to skip `vendor/`, test fixtures, generated code, etc. `FsKit\FileSet` builds an explicit, de-duplicated file list from multiple directories/files with exclusions, which you hand to `inspectFileSetForCollisions()` instead of a single `Directory`:

```
use FsKit\FileSet;

$fileSet = FileSet::createFromDir(__DIR__ . '/src')
    ->addDir(__DIR__ . '/modules')
    ->addFile(__DIR__ . '/legacy/bootstrap.php')
    ->excludeDirectoryFile(__DIR__ . '/src/Generated')
    ->excludeFile(__DIR__ . '/src/DoNotCheck.php');

$report = $parser->inspectFileSetForCollisions($fileSet);
```

Each `add*`/`exclude*` call returns a new `FileSet` (they're immutable).

### Scanning additional file extensions

[](#scanning-additional-file-extensions)

By default only `.php` files are inspected — everything else in a `Directory` or `FileSet` is ignored automatically. If your project keeps PHP in files like `.phpt` or `.phtml`, pass a `CollisionConfig` with the extra extensions to either `inspectForCollisions()` or `inspectFileSetForCollisions()`:

```
use PHPColliderScope\CollisionConfig;

$config = new CollisionConfig(
    findClassNamespaceCollision: true,
    findFunctionNamespaceCollision: true,
    additionalFileExtensions: ['phpt', 'phtml'],
);

$report = $parser->inspectForCollisions($directory, $config);
```

`CollisionConfig::default()` gives you the standard "find everything, `.php` only" config to build on, and `withFileExtension()` adds one more extension to an existing config without needing to reconstruct it from scratch:

```
$config = CollisionConfig::default()->withFileExtension('phtml');
```

Extensions are matched case-insensitively and a leading `.` is optional — `'phtml'`, `'.phtml'`, and `'PHTML'` are all equivalent.

CI/CD
-----

[](#cicd)

The `check` command exits with a non-zero status when it finds collisions (or is given a bad path), so you can drop it straight into a pipeline as a gate — no extra scripting needed:

Exit codeMeaning`0`No collisions found`1`Given path does not exist`2`Collisions found### GitHub Actions

[](#github-actions)

```
name: Collision check

on: [push, pull_request]

jobs:
  collider:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: shivammathur/setup-php@v2
        with:
          php-version: '8.3'
      - run: composer install --no-progress
      - run: vendor/bin/collider src --full
```

### GitLab CI

[](#gitlab-ci)

```
collider:
  image: php:8.3-cli
  script:
    - composer install --no-progress
    - vendor/bin/collider src --full
```

Any CI system that fails a job on a non-zero exit code will work the same way — just run `vendor/bin/collider  --full` as a step.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.3

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance94

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~15 days

Total

2

Last Release

30d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1759b23f11dcfe1753788c7d3fe306af5bfcb11d1e199ccee0b8ad04b70bc00a?d=identicon)[S-McDonald](/maintainers/S-McDonald)

---

Top Contributors

[![s-mcdonald](https://avatars.githubusercontent.com/u/1879824?v=4)](https://github.com/s-mcdonald "s-mcdonald (15 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/s-mcdonald-phpcolliderscope/health.svg)

```
[![Health](https://phpackages.com/badges/s-mcdonald-phpcolliderscope/health.svg)](https://phpackages.com/packages/s-mcdonald-phpcolliderscope)
```

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.8k40.0k](/packages/matomo-matomo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
