Skip to content

Commit fc47155

Browse files
authored
Add php-cs-fixer (#30)
1 parent 88f6a5b commit fc47155

File tree

16 files changed

+2828
-1136
lines changed

16 files changed

+2828
-1136
lines changed

.php-cs-fixer.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
use PhpCsFixer\Config;
4+
use PhpCsFixer\Finder;
5+
6+
$finder = Finder::create()
7+
->in(__DIR__)
8+
->name('*.php');
9+
10+
$config = new Config();
11+
12+
$rules = [
13+
'@PER-CS2.0' => true,
14+
'trailing_comma_in_multiline' => ['elements' => ['arguments', 'array_destructuring', 'arrays']], // For PHP 7.4 compatibility
15+
];
16+
17+
return $config
18+
->setRules($rules)
19+
->setFinder($finder)
20+
->setUsingCache(false);

ajax/ack.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434

3535
Session::checkRight('computer', UPDATE);
3636

37-
header("Content-Type: text/html; charset=UTF-8");
37+
header('Content-Type: text/html; charset=UTF-8');
3838

3939
if (isset($_POST['hostid'])) {
40-
$host = new Host();
41-
$res_a = $host->acknowledgement($_POST['hostid'], $_POST['params']);
40+
$host = new Host();
41+
$res_a = $host->acknowledgement($_POST['hostid'], $_POST['params']);
4242
}

ajax/cancelDowntime.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434

3535
Session::checkRight('computer', UPDATE);
3636

37-
header("Content-Type: text/html; charset=UTF-8");
37+
header('Content-Type: text/html; charset=UTF-8');
3838

3939
if (isset($_POST['downtimeid'])) {
40-
$host = new Host();
41-
$res_d = $host->cancelActualDownTime($_POST['downtimeid']);
40+
$host = new Host();
41+
$res_d = $host->cancelActualDownTime($_POST['downtimeid']);
4242
}

ajax/hostTimeline.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535

3636
Session::checkRight('computer', READ);
3737

38-
header("Content-Type: text/html; charset=UTF-8");
38+
header('Content-Type: text/html; charset=UTF-8');
3939

4040
if (isset($_GET['period']) && isset($_GET['hostid'])) {
4141
$param_period = $_GET['period'];
4242
$param_hostid = $_GET['hostid'];
43-
$host = new Host();
44-
$res = $host->hostTimeline($param_hostid, $_GET['period']);
43+
$host = new Host();
44+
$res = $host->hostTimeline($param_hostid, $_GET['period']);
4545
}

ajax/sendCheck.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434

3535
Session::checkRight('computer', UPDATE);
3636

37-
header("Content-Type: text/html; charset=UTF-8");
37+
header('Content-Type: text/html; charset=UTF-8');
3838

3939
if (isset($_POST['hostid'])) {
40-
$host = new Host();
40+
$host = new Host();
4141
$rescheck = $host->sendCheck($_POST['hostid']);
4242
}

ajax/setDowntime.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434

3535
Session::checkRight('computer', UPDATE);
3636

37-
header("Content-Type: text/html; charset=UTF-8");
37+
header('Content-Type: text/html; charset=UTF-8');
3838

3939
if (isset($_POST['params'])) {
40-
$params = $_POST['params'];
41-
$hostid = (int) $_POST['hostid'];
42-
$host = new Host();
40+
$params = $_POST['params'];
41+
$hostid = (int) $_POST['hostid'];
42+
$host = new Host();
4343
$resdowntime = $host->setDowntime($hostid, $params);
4444
}

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"php": ">=7.4"
44
},
55
"require-dev": {
6+
"friendsofphp/php-cs-fixer": "^3.64",
67
"glpi-project/tools": "^0.7.4",
78
"php-parallel-lint/php-parallel-lint": "^1.4",
89
"phpstan/phpstan": "^1.12",

0 commit comments

Comments
 (0)