-
Notifications
You must be signed in to change notification settings - Fork 6
/
cs-fix
executable file
·72 lines (63 loc) · 1.9 KB
/
cs-fix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env php
<?php
/**
* This file is part of the PHP CS Fixer utility, based on "FriendsOfPHP/PHP-CS-Fixer" package.
*
* Parent package authors:
*
* (c) Fabien Potencier <[email protected]>
* Dariusz Rumiński <[email protected]>
*
* This source file is subject to the MIT license that is bundled with this source code in the file LICENSE.
*/
global $argv;
// Try to disable xdebug
try {
if (\function_exists('xdebug_disable')) {
\xdebug_disable();
}
} catch (\Exception $e) {
// Do nothing
} catch (\Throwable $e) {
// Do nothing
}
// IDK for a what - this is a copy & paste from vendor binary file
\set_error_handler(function ($severity, $message, $file, $line) {
if ($severity & \error_reporting()) {
throw new ErrorException($message, 0, $severity, $file, $line);
}
});
// Require composer autoloader
if (\file_exists($autoload = __DIR__ . '/../../autoload.php')) {
require $autoload;
} else {
require __DIR__ . '/vendor/autoload.php';
}
// Detect project root directory
$reflector = new \ReflectionClass(\Composer\Autoload\ClassLoader::class);
$project_root_dir = \dirname((string) $reflector->getFileName(), 3) . '/';
// Try to detect - user pass own config, or not?
$user_config = null;
for ($i = 0; $i <= \count($argv) - 1; $i++) {
if (\strpos((string) $argv[$i], '--config') !== false) {
$user_config = isset($argv[$j = $i + 1])
? $argv[$j]
: null;
break;
}
}
// Initialize input arguments object
$input = new \Symfony\Component\Console\Input\ArgvInput($user_config === null
? \array_merge([
'php-cs-fixer',
'fix',
'--verbose',
'--config',
__DIR__ . '/config.php',
], \array_splice($argv, 1, \count($argv)))
: null
);
// And start parent app
$application = new \PhpCsFixer\Console\Application;
$application->run($input);
__HALT_COMPILER();