Completed
Push — master ( 01736a...256029 )
by personal
08:26 queued 05:25
created

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 53 and the first side effect is on line 2.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
chdir(__DIR__);
3
4
if (!file_exists('vendor/autoload.php')) {
5
  echo '[ERROR] It\'s required to run "composer install" before building PhpMetrics!' . PHP_EOL;
6
  exit(1);
7
}
8
9
$filename = 'build/phpmetrics.phar';
10
if (file_exists($filename)) {
11
    unlink($filename);
12
}
13
14
$phar = new \Phar($filename, 0, 'phpmetrics.phar');
15
$phar->setSignatureAlgorithm(\Phar::SHA1);
16
$phar->startBuffering();
17
18
19
$files = array_merge(rglob('*.php'), rglob('*.twig'), rglob('*.json'), rglob('*.pp'));
20
$exclude = '!(.git)|(.svn)|(bin)|(tests)|(Tests)|(phpmetrics)!';
21
foreach($files as $file) {
22
    if(preg_match($exclude, $file)) continue;
23
    $path = str_replace(__DIR__.'/', '', $file);
24
    $phar->addFromString($path, file_get_contents($file));
25
}
26
27
$phar->setStub(<<<STUB
28
#!/usr/bin/env php
29
<?php
30
31
/*
32
* This file is part of the PhpMetrics
33
*
34
* (c) Jean-François Lépine
35
*
36
* This source file is subject to the MIT license that is bundled
37
* with this source code in the file LICENSE.
38
*/
39
40
Phar::mapPhar('phpmetrics.phar');
41
42
require_once 'phar://phpmetrics.phar/vendor/autoload.php';
43
\$app = new Hal\Application\Console\PhpMetricsApplication('PhpMetrics, by Jean-François Lépine (https://twitter.com/Halleck45)', '<VERSION>'); // version will be inserted by build.
44
\$app->run();
45
46
__HALT_COMPILER();
47
STUB
48
);
49
$phar->stopBuffering();
50
51
chmod($filename, 0755);
52
53
function rglob($pattern='*', $flags = 0, $path='')
54
{
55
    $paths=glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT);
56
    $files=glob($path.$pattern, $flags);
57
    foreach ($paths as $path) { $files=array_merge($files,rglob($pattern, $flags, $path)); }
58
    return $files;
59
}