phar-autoload.php.in 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env php
  2. <?php
  3. if (version_compare('5.6.0', PHP_VERSION, '>')) {
  4. fwrite(
  5. STDERR,
  6. sprintf(
  7. 'This version of PHPCPD is supported on PHP 5.6, PHP 7.0, and PHP 7.1.' . PHP_EOL .
  8. 'You are using PHP %s%s.' . PHP_EOL,
  9. PHP_VERSION,
  10. defined('PHP_BINARY') ? ' (' . PHP_BINARY . ')' : ''
  11. )
  12. );
  13. die(1);
  14. }
  15. if ($_SERVER['SCRIPT_NAME'] != '-') {
  16. $phar = realpath($_SERVER['SCRIPT_NAME']);
  17. } else {
  18. $files = get_included_files();
  19. $phar = $files[0];
  20. }
  21. define('__PHPCPD_PHAR__', str_replace(DIRECTORY_SEPARATOR, '/', $phar));
  22. define('__PHPCPD_PHAR_ROOT__', 'phar://___PHAR___');
  23. spl_autoload_register(
  24. function ($class)
  25. {
  26. static $classes = NULL;
  27. if ($classes === NULL) {
  28. $classes = array(
  29. ___CLASSLIST___
  30. );
  31. }
  32. $class = strtolower($class);
  33. if (isset($classes[$class])) {
  34. require 'phar://___PHAR___' . $classes[$class];
  35. }
  36. }
  37. );
  38. Phar::mapPhar('___PHAR___');
  39. if (isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] == '--manifest') {
  40. print file_get_contents(__PHPCPD_PHAR_ROOT__ . '/manifest.txt');
  41. exit;
  42. }
  43. $application = new SebastianBergmann\PHPCPD\CLI\Application;
  44. $application->run();
  45. __HALT_COMPILER();