2017 © Pedro Peláez
 

library hack-class-scanner

Recursively scan a directory for hack classes and/or interfaces

image

kilahm/hack-class-scanner

Recursively scan a directory for hack classes and/or interfaces

  • Wednesday, February 25, 2015
  • by kilahm
  • Repository
  • 0 Watchers
  • 0 Stars
  • 107 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

HackClassScanner

Build Status HHVM Status, (*1)

A class that recursively scans a directory for hack classes., (*2)

Installation

Add the following line to your composer.json file in the require section., (*3)

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

Then run composer update., (*4)

Use

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

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<string,string> 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., (*6)

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., (*7)

$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

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., (*8)

Thanks

The file parsing algorithm was heavily influenced by the one used in HackPack/HackUnit., (*9)

The Versions

25/02 2015

dev-master

9999999-dev

Recursively scan a directory for hack classes and/or interfaces

  Sources   Download

MIT

The Development Requires

by Isaac Leinweber

hack hhvm autoload scan classscanner

25/02 2015

v1.3.2

1.3.2.0

Recursively scan a directory for hack classes and/or interfaces

  Sources   Download

MIT

The Development Requires

by Isaac Leinweber

hack hhvm autoload scan classscanner

25/02 2015

v1.3.1

1.3.1.0

Recursively scan a directory for hack classes and/or interfaces

  Sources   Download

MIT

The Development Requires

by Isaac Leinweber

hack hhvm autoload scan classscanner

12/12 2014

v1.3.0

1.3.0.0

Recursively scan a directory for hack classes and/or interfaces

  Sources   Download

MIT

The Development Requires

by Isaac Leinweber

hack hhvm autoload scan classscanner

06/12 2014

v1.2.2

1.2.2.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Isaac Leinweber

hack hhvm autoload scan classscanner

28/11 2014

v1.2.1

1.2.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Isaac Leinweber

hack hhvm autoload scan classscanner

22/11 2014

v1.2.0

1.2.0.0

  Sources   Download

MIT

The Development Requires

by Isaac Leinweber

hack hhvm autoload scan classscanner

21/11 2014

v1.1.0

1.1.0.0

  Sources   Download

MIT

The Development Requires

by Isaac Leinweber

hack hhvm autoload scan classscanner

19/11 2014

v1.0.2

1.0.2.0

  Sources   Download

MIT

The Development Requires

by Isaac Leinweber

hack hhvm autoload scan classscanner

19/11 2014

v1.0.1

1.0.1.0

  Sources   Download

MIT

The Development Requires

by Isaac Leinweber

hack hhvm autoload scan classscanner

19/11 2014

v1.0.0

1.0.0.0

  Sources   Download

MIT

The Development Requires

by Isaac Leinweber