cwreden /
php7cc-analyser
| 1 | <?php |
||
| 2 | |||
| 3 | $file = $argv[1]; |
||
| 4 | |||
| 5 | if (empty($file)) { |
||
| 6 | echo 'php7cc result json file not defined.' . PHP_EOL; |
||
| 7 | exit(3); |
||
| 8 | } elseif (!file_exists($file)) { |
||
| 9 | echo sprintf('File: %s not found.' . PHP_EOL, $file); |
||
| 10 | exit(3); |
||
| 11 | } |
||
| 12 | |||
| 13 | $content = file_get_contents($file); |
||
| 14 | $data = json_decode($content, true); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 15 | |||
| 16 | $warnings = 0; |
||
| 17 | $errors = 0; |
||
| 18 | foreach ($data['files'] AS $file) { |
||
| 19 | echo '.'; |
||
| 20 | if (isset($file['errors']) && count($file['errors']) > 0) { |
||
| 21 | $errors += count($file['errors']); |
||
| 22 | } |
||
| 23 | if (isset($file['warnings']) && count($file['warnings']) > 0) { |
||
| 24 | $warnings += count($file['warnings']); |
||
| 25 | } |
||
| 26 | } |
||
| 27 | |||
| 28 | echo PHP_EOL; |
||
| 29 | echo PHP_EOL; |
||
| 30 | |||
| 31 | echo sprintf( |
||
| 32 | '[Checked files: %d, Effected files: %d, Warnings: %d, Errors: %d]' . PHP_EOL, |
||
| 33 | $data['summary']['checkedFiles'], |
||
| 34 | count($data['files']), |
||
| 35 | $warnings, |
||
| 36 | $errors |
||
| 37 | ); |
||
| 38 | |||
| 39 | echo PHP_EOL; |
||
| 40 | |||
| 41 | if ($errors > 0) { |
||
| 42 | echo 'There are php 7 incompatible statements!' . PHP_EOL; |
||
| 43 | exit(2); |
||
| 44 | } elseif ($warnings > 0) { |
||
| 45 | echo 'There are php 7 risky statements!' . PHP_EOL; |
||
| 46 | exit(1); |
||
| 47 | } else { |
||
| 48 | echo 'There are no php 7 errors or warnings.' . PHP_EOL; |
||
| 49 | exit(0); |
||
| 50 | } |