hhpack / package
Package utility library for vendor
Installs: 174
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 2
Language:Shell
Requires
- hhvm: >=3.21.0
- facebook/definition-finder: ^2.12
- hhvm/hhvm-autoload: ^2.0
- hhvm/hsl: ^4.7
Requires (Dev)
- facebook/fbexpect: ^2.6
- hhvm/hacktest: ^1.6
- dev-master
- 1.5.0
- 1.4.0
- 1.3.0
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.12.0
- 0.11.1
- 0.11.0
- 0.10.0
- 0.9.0
- 0.8.1
- 0.8.0
- 0.7.0
- 0.6.0
- 0.5.0
- 0.4.1
- 0.4.0
- 0.3.0
- 0.2.0
- 0.1.0
- dev-feature/hhvm
- dev-feature/hhvm4.1
- dev-feature/hackunit
- dev-feature/format
- dev-feature/fix_build_settings
This package is auto-updated.
Last update: 2024-12-20 14:25:29 UTC
README
Package utility library for vendor.
Easily and quickly, and you can find a class or interface.
Basic usage
Find the source file from the package.
use HHPack\Package\VendorPackage; $sources = VendorPackage::fromItems([ Pair { 'package\\examples\\classes\\', realpath(__DIR__ . '/src') } ])->sources(); foreach ($sources as $source) { var_dump($source->name()); // /path/to/example.hh var_dump($source->directory()); // /path/to }
Selection of elements
You can select the elements in the following function.
- HHPack\Package\implementsInterface
- HHPack\Package\subclassOf
- HHPack\Package\classes
- HHPack\Package\abstractClasses
- HHPack\Package\traits
- HHPack\Package\interfaces
- HHPack\Package\instantiable
- HHPack\Package\startsWith
- HHPack\Package\endsWith
In the following we are looking for a interface and traits.
use HHPack\Package as package; use HHPack\Package\VendorPackage; $interfaces = VendorPackage::fromItems([ Pair { 'Package\\Examples\\Classes\\', realpath(__DIR__ . '/src') } ])->classes(package\interfaces()); foreach ($interfaces as $interface) { var_dump($interface->name()); // interface } $traits = VendorPackage::fromItems([ Pair { 'Package\\Examples\\Classes\\', realpath(__DIR__ . '/src') } ])->classes(package\traits()); foreach ($traits as $trait) { var_dump($trait->getName()); // trait }
Instantiation of class
Get an instance from the source files
use HHPack\Package\VendorPackage; $instances = VendorPackage::fromItems([ Pair { 'Package\\Examples\\Classes\\', realpath(__DIR__ . '/src') } ])->classes()->map(($class) ==> $class->instantiate()); foreach ($instances as $instance) { var_dump($instance); }
Pipeline of stream
You can build a pipeline.
You can achieve when implement the interface Middleware and Stream.
Please look at the example/pipeline.hh for details.
use HHPack\Package\VendorPackage; use HHPack\Package\Examples\Classes\FileStatTransformer; use HHPack\Package\Examples\Classes\FileStatOutput; $package = VendorPackage::fromItems([ Pair { 'Package\\Examples\\Classes\\', realpath(__DIR__ . '/src') } ]); $package->sources() ->pipeTo(new FileStatTransformer()) ->pipeTo(new FileStatOutput());
Run the test
composer install
composer test