run.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /*
  3. Copyright (c) 2009 hamcrest.org
  4. */
  5. require __DIR__ . '/../vendor/autoload.php';
  6. /*
  7. * Generates the Hamcrest\Matchers factory class and factory functions
  8. * from the @factory doctags in the various matchers.
  9. */
  10. define('GENERATOR_BASE', __DIR__);
  11. define('HAMCREST_BASE', realpath(dirname(GENERATOR_BASE) . DIRECTORY_SEPARATOR . 'hamcrest'));
  12. define('GLOBAL_FUNCTIONS_FILE', HAMCREST_BASE . DIRECTORY_SEPARATOR . 'Hamcrest.php');
  13. define('STATIC_MATCHERS_FILE', HAMCREST_BASE . DIRECTORY_SEPARATOR . 'Hamcrest' . DIRECTORY_SEPARATOR . 'Matchers.php');
  14. set_include_path(
  15. implode(
  16. PATH_SEPARATOR,
  17. array(
  18. GENERATOR_BASE,
  19. HAMCREST_BASE,
  20. get_include_path()
  21. )
  22. )
  23. );
  24. @unlink(GLOBAL_FUNCTIONS_FILE);
  25. @unlink(STATIC_MATCHERS_FILE);
  26. $generator = new FactoryGenerator(HAMCREST_BASE . DIRECTORY_SEPARATOR . 'Hamcrest');
  27. $generator->addFactoryFile(new StaticMethodFile(STATIC_MATCHERS_FILE));
  28. $generator->addFactoryFile(new GlobalFunctionFile(GLOBAL_FUNCTIONS_FILE));
  29. $generator->generate();
  30. $generator->write();