PHPackages                             kilahm/hack-class-scanner - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. kilahm/hack-class-scanner

Abandoned → [hackpack/hack-class-scanner](/?search=hackpack%2Fhack-class-scanner)Library[Utility &amp; Helpers](/categories/utility)

kilahm/hack-class-scanner
=========================

Recursively scan a directory for hack classes and/or interfaces

v1.3.2(11y ago)1118MITHack

Since Nov 19Pushed 11y agoCompare

[ Source](https://github.com/kilahm/HackClassScanner)[ Packagist](https://packagist.org/packages/kilahm/hack-class-scanner)[ RSS](/packages/kilahm-hack-class-scanner/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (11)Used By (0)

HackClassScanner
================

[](#hackclassscanner)

[![Build Status](https://camo.githubusercontent.com/19560aced99ef48ddae69a399bd6d0b6307d98049657c3376dfef998fd3cdc01/68747470733a2f2f7472617669732d63692e6f72672f6b696c61686d2f4861636b436c6173735363616e6e65722e737667)](https://travis-ci.org/kilahm/HackClassScanner) [![HHVM Status](https://camo.githubusercontent.com/efec4d91c92c4c68807ee7b84597f32ad4eccb493543073ac46460dd02d4cbc0/687474703a2f2f6868766d2e683463632e64652f62616467652f6b696c61686d2f6861636b2d636c6173732d7363616e6e65722e737667)](http://hhvm.h4cc.de/package/kilahm/hack-class-scanner)

A class that recursively scans a directory for hack classes.

Installation
============

[](#installation)

Add the following line to your `composer.json` file in the `require` section.

```
“kilahm/hack-class-scanner”: “dev-master”

```

Then run `composer update`.

Use
===

[](#use)

To use the class, simply instantiate it with a set of base directories to scan and a set of directories to ignore.

```
use kilahm\Scanner\ClassScanner;

$scanner = new ClassScanner(
  Set{‘directory/to/scan’, ‘other/directory’},
  Set{‘other/directory/to/ignore’}
);
$classMap = $scanner->mapClassToFile();
$classAndInterfaceMap = $scanner->mapClassOrInterfaceToFile();
```

The `$classMap` variable will then hold a `Map` object that maps class names (with full namespace) to the files in which the class is defined. The `$classAndInterfaceMap` will be the same as `$classMap` except it will include interfaces as well as classes.

Filters
-------

[](#filters)

You can filter the result files based on the name of the class or the name of the file. A filter must be a closure with a signature of `function(string) : bool`. The input for a class filter is the name of the class including the namespace. The input for a file filter is the name of the file including the full path (via `realpath`). If all registered filter functions return `true` for a particular file or class name, the file will be scanned for a class and the class name will appear in the output, respectively.

```
$includes = Set{...};
$excludes = Set{...};
$scanner = new ClassScanner($includes, $excludes);
$classFilter = $className ==> preg_match(‘/pattern/’, $className);
$fileFilter = $fileName ==> preg_match(‘/pattern/’, $fileName);
$scanner->addClassNameFilter($classFilter);
$scanner->addFileNameFilter($fileFilter);
$classMap = $scanner->mapClassToFile();
```

Assumptions
-----------

[](#assumptions)

This class assumes you are following the practice of one class per file. The scanner will stop searching once it has found the first class name in a file.

Thanks
======

[](#thanks)

The file parsing algorithm was heavily influenced by the one used in [HackPack/HackUnit](https://github.com/HackPack/HackUnit).

###  Health Score

30

—

LowBetter than 65% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity69

Established project with proven stability

 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 ~11 days

Recently: every ~22 days

Total

10

Last Release

4092d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/78bcca38df593ddb1cf9c1ff715a433b3a2f991e95b73362e44b397e9ee01b80?d=identicon)[kilahm](/maintainers/kilahm)

---

Top Contributors

[![kilahm](https://avatars.githubusercontent.com/u/3050967?v=4)](https://github.com/kilahm "kilahm (6 commits)")

---

Tags

autoloadhhvmhackscanClassScanner

### Embed Badge

![Health badge](/badges/kilahm-hack-class-scanner/health.svg)

```
[![Health](https://phpackages.com/badges/kilahm-hack-class-scanner/health.svg)](https://phpackages.com/packages/kilahm-hack-class-scanner)
```

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.4k187.2M2.6k](/packages/composer-composer)[nette/robot-loader

🍀 Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.

89152.7M321](/packages/nette-robot-loader)[classpreloader/classpreloader

Helps class loading performance by generating a single PHP file containing all of the autoloaded files for a specific use case

37642.4M32](/packages/classpreloader-classpreloader)[funkjedi/composer-include-files

Include files at a higher priority than autoload files.

1263.2M19](/packages/funkjedi-composer-include-files)[automattic/jetpack-autoloader

Creates a custom autoloader for a plugin or theme.

525.5M67](/packages/automattic-jetpack-autoloader)[shipmonk/name-collision-detector

Simple tool to find ambiguous classes or any other name duplicates within your project.

362.1M35](/packages/shipmonk-name-collision-detector)

PHPackages © 2026

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