PHP code example of griffin / harpy

1. Go to this page and download the library: Download griffin/harpy library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

griffin / harpy example snippets


use Griffin\Harpy\Harpy;

$harpy = new Harpy();

$classnames = $harpy->search(
    // Files
    './src/Harpy.php',
    './tests/HarpyTest.php',
    // Directories
    './src',
    './tests',
);

var_dump($classnames);

/*
array(6) {
  [0]=>
  string(19) "Griffin\Harpy\Harpy"
  [1]=>
  string(27) "GriffinTest\Harpy\HarpyTest"
  [2]=>
  string(20) "Griffin\Harpy\Finder"
  [3]=>
  string(20) "Griffin\Harpy\Parser"
  [4]=>
  string(28) "GriffinTest\Harpy\FinderTest"
  [5]=>
  string(28) "GriffinTest\Harpy\ParserTest"
}
 */

use FooBar\ExampleInterface;
use Griffin\Harpy\Harpy;

$objects    = [];
$classnames = (new Harpy())->search('src');

foreach ($classnames as $classname) {
    if (is_subclass_of($classname, ExampleInterface::class, true /* allow string */)) {
        $objects[] = new $classname();
    }
}