-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpolymorphine-phpcs
More file actions
58 lines (48 loc) · 1.91 KB
/
Copy pathpolymorphine-phpcs
File metadata and controls
58 lines (48 loc) · 1.91 KB
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
#!/usr/bin/env php
<?php declare(strict_types=1);
/*
* This file is part of Polymorphine/Dev package.
*
* (c) Shudd3r <q3.shudder@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
/**
* PHP_CodeSniffer detects violations of a defined coding standard.
*
* @author Greg Sherwood <gsherwood@squiz.net>
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
* @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/HEAD/licence.txt BSD Licence
*/
function runScript(PHP_CodeSniffer\Runner $runner, array $args): int
{
$_SERVER['argv'] = [__FILE__, ...$args];
return $runner->runPHPCS();
}
$exitCode = 0;
if (!isset($argv[1])) {
$scriptRoot = getcwd() === __DIR__ ? __DIR__ : dirname(__DIR__, 3);
require_once $scriptRoot . DIRECTORY_SEPARATOR . 'vendor/squizlabs/php_codesniffer/autoload.php';
if ($scriptRoot !== __DIR__) {
require_once getcwd() . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
}
$standard = $scriptRoot === __DIR__ ? 'phpcs.xml.dist' : 'phpcs.xml';
$args = ['--extensions=php', '--standard=' . __DIR__ . DIRECTORY_SEPARATOR . $standard, '--colors'];
$runner = new PHP_CodeSniffer\Runner();
$exitCode = runScript($runner, ['--version'])
| runScript($runner, [...$args, 'src'])
| runScript($runner, [...$args, '--ignore=*/code-samples/*', 'tests']);
exit($exitCode);
}
$scriptRoot = dirname(__DIR__, 3);
require_once $scriptRoot . '/vendor/squizlabs/php_codesniffer/autoload.php';
if ($argv[1] === '-') {
$cwd = explode('=', $argv[2])[1];
require_once $cwd . '/vendor/autoload.php';
$standard = $cwd === __DIR__ ? 'phpcs.xml.dist' : 'phpcs.xml';
$argv[2] = '--standard=' . __DIR__ . DIRECTORY_SEPARATOR . $standard;
}
$runner = new PHP_CodeSniffer\Runner();
$exitCode = runScript($runner, $argv);
exit($exitCode);