-
Notifications
You must be signed in to change notification settings - Fork 12
/
engine.php
48 lines (35 loc) · 1.05 KB
/
engine.php
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
<?php
declare(ticks=1);
namespace PHPMD\TextUI;
use CodeClimate\PHPMD\Runner;
error_reporting(E_ERROR | E_PARSE | E_NOTICE);
date_default_timezone_set('UTC');
ini_set('memory_limit', -1);
require_once __DIR__.'/vendor/autoload.php';
require_once "Fingerprint.php";
require_once "JSONRenderer.php";
require_once "Runner.php";
require_once "Category.php";
use PHPMD\PHPMD;
use PHPMD\RuleSetFactory;
use PHPMD\Writer\StreamWriter;
use PHPMD\Renderer\JSONRenderer;
// obtain the config
$config = json_decode(file_get_contents('/config.json'), true);
// setup forking daemon
$server = new \fork_daemon();
$server->max_children_set(3);
$server->max_work_per_child_set(50);
$server->store_result_set(true);
$runner = new Runner($config, $server);
$server->register_child_run(array($runner, "run"));
$runner->queueDirectory("/code");
$server->process_work(true);
$results = $server->get_all_results();
foreach ($results as $result_file) {
if (is_a($result_file, "Throwable")) {
exit(1);
}
echo file_get_contents($result_file);
unlink($result_file);
}