php-cs-fixer 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/usr/bin/env php
  2. <?php
  3. /*
  4. * This file is part of PHP CS Fixer.
  5. *
  6. * (c) Fabien Potencier <fabien@symfony.com>
  7. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  8. *
  9. * This source file is subject to the MIT license that is bundled
  10. * with this source code in the file LICENSE.
  11. */
  12. /**
  13. * @author Fabien Potencier <fabien@symfony.com>
  14. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  15. */
  16. error_reporting(-1);
  17. if (defined('HHVM_VERSION_ID')) {
  18. fwrite(STDERR, "HHVM is not supported.\n");
  19. if (getenv('PHP_CS_FIXER_IGNORE_ENV')) {
  20. fwrite(STDERR, "Ignoring environment requirements because `PHP_CS_FIXER_IGNORE_ENV` is set. Execution may be unstable.\n");
  21. } else {
  22. exit(1);
  23. }
  24. } elseif (!defined('PHP_VERSION_ID') || \PHP_VERSION_ID < 50600 || \PHP_VERSION_ID >= 70400) {
  25. fwrite(STDERR, "PHP needs to be a minimum version of PHP 5.6.0 and maximum version of PHP 7.3.*.\n");
  26. if (getenv('PHP_CS_FIXER_IGNORE_ENV')) {
  27. fwrite(STDERR, "Ignoring environment requirements because `PHP_CS_FIXER_IGNORE_ENV` is set. Execution may be unstable.\n");
  28. } else {
  29. exit(1);
  30. }
  31. }
  32. set_error_handler(function ($severity, $message, $file, $line) {
  33. if ($severity & error_reporting()) {
  34. throw new ErrorException($message, 0, $severity, $file, $line);
  35. }
  36. });
  37. $require = true;
  38. if (class_exists('Phar')) {
  39. // Maybe this file is used as phar-stub? Let's try!
  40. try {
  41. Phar::mapPhar('php-cs-fixer.phar');
  42. require_once 'phar://php-cs-fixer.phar/vendor/autoload.php';
  43. $require = false;
  44. } catch (PharException $e) {
  45. }
  46. }
  47. if ($require) {
  48. // OK, it's not, let give Composer autoloader a try!
  49. if (file_exists($a = __DIR__.'/../../autoload.php')) {
  50. require_once $a;
  51. } else {
  52. require_once __DIR__.'/vendor/autoload.php';
  53. }
  54. }
  55. unset($require);
  56. use Composer\XdebugHandler\XdebugHandler;
  57. use PhpCsFixer\Console\Application;
  58. // Restart if xdebug is loaded, unless the environment variable PHP_CS_FIXER_ALLOW_XDEBUG is set.
  59. $xdebug = new XdebugHandler('PHP_CS_FIXER', '--ansi');
  60. $xdebug->check();
  61. unset($xdebug);
  62. $application = new Application();
  63. $application->run();
  64. __HALT_COMPILER();