php-cs-fixer 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. if (getenv('PHP_CS_FIXER_FUTURE_MODE')) {
  17. error_reporting(-1);
  18. }
  19. if (defined('HHVM_VERSION_ID')) {
  20. fwrite(STDERR, "HHVM is not supported.\n");
  21. if (getenv('PHP_CS_FIXER_IGNORE_ENV')) {
  22. fwrite(STDERR, "Ignoring environment requirements because `PHP_CS_FIXER_IGNORE_ENV` is set. Execution may be unstable.\n");
  23. } else {
  24. exit(1);
  25. }
  26. } elseif (!defined('PHP_VERSION_ID') || \PHP_VERSION_ID < 50600 || \PHP_VERSION_ID >= 70300) {
  27. fwrite(STDERR, "PHP needs to be a minimum version of PHP 5.6.0 and maximum version of PHP 7.2.*.\n");
  28. if (getenv('PHP_CS_FIXER_IGNORE_ENV')) {
  29. fwrite(STDERR, "Ignoring environment requirements because `PHP_CS_FIXER_IGNORE_ENV` is set. Execution may be unstable.\n");
  30. } else {
  31. exit(1);
  32. }
  33. }
  34. set_error_handler(function ($severity, $message, $file, $line) {
  35. if ($severity & error_reporting()) {
  36. throw new ErrorException($message, 0, $severity, $file, $line);
  37. }
  38. });
  39. $require = true;
  40. if (class_exists('Phar')) {
  41. // Maybe this file is used as phar-stub? Let's try!
  42. try {
  43. Phar::mapPhar('php-cs-fixer.phar');
  44. require_once 'phar://php-cs-fixer.phar/vendor/autoload.php';
  45. $require = false;
  46. } catch (PharException $e) {
  47. }
  48. }
  49. if ($require) {
  50. // OK, it's not, let give Composer autoloader a try!
  51. if (file_exists($a = __DIR__.'/../../autoload.php')) {
  52. require_once $a;
  53. } else {
  54. require_once __DIR__.'/vendor/autoload.php';
  55. }
  56. }
  57. unset($require);
  58. use Composer\XdebugHandler\XdebugHandler;
  59. use PhpCsFixer\Console\Application;
  60. // Restart if xdebug is loaded, unless the environment variable PHP_CS_FIXER_ALLOW_XDEBUG is set.
  61. $xdebug = new XdebugHandler('PHP_CS_FIXER', '--ansi');
  62. $xdebug->check();
  63. unset($xdebug);
  64. $application = new Application();
  65. $application->run();
  66. __HALT_COMPILER();