|
@@ -13,93 +13,95 @@
|
|
|
|
|
|
error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);
|
|
|
|
|
|
-if (defined('HHVM_VERSION_ID')) {
|
|
|
- fwrite(STDERR, "HHVM is not supported.\n");
|
|
|
-
|
|
|
- if (getenv('PHP_CS_FIXER_IGNORE_ENV')) {
|
|
|
- fwrite(STDERR, "Ignoring environment requirements because `PHP_CS_FIXER_IGNORE_ENV` is set. Execution may be unstable.\n");
|
|
|
- } else {
|
|
|
- exit(1);
|
|
|
- }
|
|
|
-} elseif (!defined('PHP_VERSION_ID')) { // PHP_VERSION_ID is available as of PHP 5.2.7
|
|
|
- fwrite(STDERR, 'PHP version no supported, please update. Current PHP version: '.PHP_VERSION.".\n");
|
|
|
-
|
|
|
- exit(1);
|
|
|
-} elseif (\PHP_VERSION_ID === 80000) {
|
|
|
- fwrite(STDERR, "PHP CS Fixer is not able run on PHP 8.0.0 due to bug in PHP tokenizer (https://bugs.php.net/bug.php?id=80462).\n");
|
|
|
- fwrite(STDERR, "Update PHP version to unblock execution.\n");
|
|
|
-
|
|
|
- exit(1);
|
|
|
-} elseif (
|
|
|
- \PHP_VERSION_ID < 70103
|
|
|
- || \PHP_VERSION_ID >= 80100
|
|
|
-) {
|
|
|
- fwrite(STDERR, "PHP needs to be a minimum version of PHP 7.1.3 and maximum version of PHP 8.0.*.\n");
|
|
|
- fwrite(STDERR, 'Current PHP version: '.PHP_VERSION.".\n");
|
|
|
-
|
|
|
- if (getenv('PHP_CS_FIXER_IGNORE_ENV')) {
|
|
|
- fwrite(STDERR, "Ignoring environment requirements because `PHP_CS_FIXER_IGNORE_ENV` is set. Execution may be unstable.\n");
|
|
|
- } else {
|
|
|
- fwrite(STDERR, "To ignore this requirement please set `PHP_CS_FIXER_IGNORE_ENV`.\n");
|
|
|
- fwrite(STDERR, "If you use PHP version higher than supported, you may experience code modified in a wrong way.\n");
|
|
|
- fwrite(STDERR, "Please report such cases at https://github.com/FriendsOfPHP/PHP-CS-Fixer .\n");
|
|
|
-
|
|
|
- exit(1);
|
|
|
+set_error_handler(static function ($severity, $message, $file, $line) {
|
|
|
+ if ($severity & error_reporting()) {
|
|
|
+ throw new ErrorException($message, 0, $severity, $file, $line);
|
|
|
}
|
|
|
-}
|
|
|
+});
|
|
|
|
|
|
-foreach (['json', 'tokenizer'] as $extension) {
|
|
|
- if (!extension_loaded($extension)) {
|
|
|
- fwrite(STDERR, sprintf("PHP extension ext-%s is missing from your system. Install or enable it.\n", $extension));
|
|
|
+// check environment requirements
|
|
|
+(function () {
|
|
|
+ if (defined('HHVM_VERSION_ID')) {
|
|
|
+ fwrite(STDERR, "HHVM is not supported.\n");
|
|
|
|
|
|
if (getenv('PHP_CS_FIXER_IGNORE_ENV')) {
|
|
|
fwrite(STDERR, "Ignoring environment requirements because `PHP_CS_FIXER_IGNORE_ENV` is set. Execution may be unstable.\n");
|
|
|
} else {
|
|
|
exit(1);
|
|
|
}
|
|
|
- }
|
|
|
-}
|
|
|
-unset($extension);
|
|
|
+ } elseif (!defined('PHP_VERSION_ID')) { // PHP_VERSION_ID is available as of PHP 5.2.7
|
|
|
+ fwrite(STDERR, 'PHP version no supported, please update. Current PHP version: '.PHP_VERSION.".\n");
|
|
|
|
|
|
-set_error_handler(static function ($severity, $message, $file, $line) {
|
|
|
- if ($severity & error_reporting()) {
|
|
|
- throw new ErrorException($message, 0, $severity, $file, $line);
|
|
|
- }
|
|
|
-});
|
|
|
+ exit(1);
|
|
|
+ } elseif (\PHP_VERSION_ID === 80000) {
|
|
|
+ fwrite(STDERR, "PHP CS Fixer is not able run on PHP 8.0.0 due to bug in PHP tokenizer (https://bugs.php.net/bug.php?id=80462).\n");
|
|
|
+ fwrite(STDERR, "Update PHP version to unblock execution.\n");
|
|
|
+
|
|
|
+ exit(1);
|
|
|
+ } elseif (
|
|
|
+ \PHP_VERSION_ID < 70103
|
|
|
+ || \PHP_VERSION_ID >= 80100
|
|
|
+ ) {
|
|
|
+ fwrite(STDERR, "PHP needs to be a minimum version of PHP 7.1.3 and maximum version of PHP 8.0.*.\n");
|
|
|
+ fwrite(STDERR, 'Current PHP version: '.PHP_VERSION.".\n");
|
|
|
|
|
|
-$require = true;
|
|
|
-if (class_exists('Phar')) {
|
|
|
- // Maybe this file is used as phar-stub? Let's try!
|
|
|
- try {
|
|
|
- Phar::mapPhar('php-cs-fixer.phar');
|
|
|
+ if (getenv('PHP_CS_FIXER_IGNORE_ENV')) {
|
|
|
+ fwrite(STDERR, "Ignoring environment requirements because `PHP_CS_FIXER_IGNORE_ENV` is set. Execution may be unstable.\n");
|
|
|
+ } else {
|
|
|
+ fwrite(STDERR, "To ignore this requirement please set `PHP_CS_FIXER_IGNORE_ENV`.\n");
|
|
|
+ fwrite(STDERR, "If you use PHP version higher than supported, you may experience code modified in a wrong way.\n");
|
|
|
+ fwrite(STDERR, "Please report such cases at https://github.com/FriendsOfPHP/PHP-CS-Fixer .\n");
|
|
|
|
|
|
- require_once 'phar://php-cs-fixer.phar/vendor/autoload.php';
|
|
|
- $require = false;
|
|
|
- } catch (PharException $e) {
|
|
|
+ exit(1);
|
|
|
+ }
|
|
|
}
|
|
|
-}
|
|
|
|
|
|
-if ($require) {
|
|
|
- // OK, it's not, let give Composer autoloader a try!
|
|
|
- $possibleFiles = [__DIR__.'/../../autoload.php', __DIR__.'/../autoload.php', __DIR__.'/vendor/autoload.php'];
|
|
|
- $file = null;
|
|
|
- foreach ($possibleFiles as $possibleFile) {
|
|
|
- if (file_exists($possibleFile)) {
|
|
|
- $file = $possibleFile;
|
|
|
+ foreach (['json', 'tokenizer'] as $extension) {
|
|
|
+ if (!extension_loaded($extension)) {
|
|
|
+ fwrite(STDERR, sprintf("PHP extension ext-%s is missing from your system. Install or enable it.\n", $extension));
|
|
|
|
|
|
- break;
|
|
|
+ if (getenv('PHP_CS_FIXER_IGNORE_ENV')) {
|
|
|
+ fwrite(STDERR, "Ignoring environment requirements because `PHP_CS_FIXER_IGNORE_ENV` is set. Execution may be unstable.\n");
|
|
|
+ } else {
|
|
|
+ exit(1);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if (null === $file) {
|
|
|
- throw new RuntimeException('Unable to locate autoload.php file.');
|
|
|
+})();
|
|
|
+
|
|
|
+// load dependencies
|
|
|
+(function () {
|
|
|
+ $require = true;
|
|
|
+ if (class_exists('Phar')) {
|
|
|
+ // Maybe this file is used as phar-stub? Let's try!
|
|
|
+ try {
|
|
|
+ Phar::mapPhar('php-cs-fixer.phar');
|
|
|
+
|
|
|
+ require_once 'phar://php-cs-fixer.phar/vendor/autoload.php';
|
|
|
+ $require = false;
|
|
|
+ } catch (PharException $e) {
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- require_once $file;
|
|
|
+ if ($require) {
|
|
|
+ // OK, it's not, let give Composer autoloader a try!
|
|
|
+ $possibleFiles = [__DIR__.'/../../autoload.php', __DIR__.'/../autoload.php', __DIR__.'/vendor/autoload.php'];
|
|
|
+ $file = null;
|
|
|
+ foreach ($possibleFiles as $possibleFile) {
|
|
|
+ if (file_exists($possibleFile)) {
|
|
|
+ $file = $possibleFile;
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- unset($possibleFiles, $possibleFile, $file);
|
|
|
-}
|
|
|
-unset($require);
|
|
|
+ if (null === $file) {
|
|
|
+ throw new RuntimeException('Unable to locate autoload.php file.');
|
|
|
+ }
|
|
|
+
|
|
|
+ require_once $file;
|
|
|
+ }
|
|
|
+})();
|
|
|
|
|
|
use Composer\XdebugHandler\XdebugHandler;
|
|
|
use PhpCsFixer\Console\Application;
|