Skip to content

Commit 2a8df0a

Browse files
authored
Feat: php-cs-fixer (#154)
* Feat: php-cs-fixer * fix rules * clean config * clean rules * trailing_comma_in_multiline * Revert "trailing_comma_in_multiline" This reverts commit e6acf11. * php 7.4 compatiblity * remove php_codesniffer
1 parent 856cb43 commit 2a8df0a

16 files changed

+2360
-656
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/display_alerts.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
*/
3030

3131
$AJAX_INCLUDE = 1;
32-
include("../../../inc/includes.php");
33-
header("Content-Type: text/html; charset=UTF-8");
32+
include('../../../inc/includes.php');
33+
header('Content-Type: text/html; charset=UTF-8');
3434
Html::header_nocache();
3535
Session::checkLoginUser();
3636

ajax/hide_alert.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
*/
3030

3131
$AJAX_INCLUDE = 1;
32-
include("../../../inc/includes.php");
33-
header("Content-Type: text/html; charset=UTF-8");
32+
include('../../../inc/includes.php');
33+
header('Content-Type: text/html; charset=UTF-8');
3434
Html::header_nocache();
3535
Session::checkLoginUser();
3636

ajax/targets.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@
2929
*/
3030

3131
$AJAX_INCLUDE = 1;
32-
include("../../../inc/includes.php");
33-
header("Content-Type: text/html; charset=UTF-8");
32+
include('../../../inc/includes.php');
33+
header('Content-Type: text/html; charset=UTF-8');
3434
Html::header_nocache();
3535

3636
Session::checkLoginUser();
3737

3838
if (isset($_POST['type']) && !empty($_POST['type'])) {
3939
echo "<table class='tab_format'>";
40-
echo "<tr>";
41-
echo "<td>";
40+
echo '<tr>';
41+
echo '<td>';
4242
switch ($_POST['type']) {
4343
case 'User':
44-
User::dropdown(['name' => 'items_id',
45-
'right' => 'all',
46-
'entity' => $_POST['entities_id'],
47-
'entity_sons' => $_POST['is_recursive'],
44+
User::dropdown(['name' => 'items_id',
45+
'right' => 'all',
46+
'entity' => $_POST['entities_id'],
47+
'entity_sons' => $_POST['is_recursive'],
4848
]);
4949
break;
5050

@@ -53,14 +53,14 @@
5353
break;
5454

5555
case 'Profile':
56-
Profile::dropdown(['name' => 'items_id',
57-
'toadd' => [-1 => __('All', 'news')]
56+
Profile::dropdown(['name' => 'items_id',
57+
'toadd' => [-1 => __('All', 'news')],
5858
]);
5959
break;
6060
}
61-
echo "</td>";
61+
echo '</td>';
6262
echo "<td><input type='submit' name='addvisibility' value=\"" . _sx('button', 'Add', 'news') . "\"
6363
class='submit'></td>";
64-
echo "</tr>";
65-
echo "</table>";
64+
echo '</tr>';
65+
echo '</table>';
6666
}

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"php": ">=7.4"
44
},
55
"require-dev": {
6+
"friendsofphp/php-cs-fixer": "^3.64",
67
"glpi-project/tools": "^0.7.3",
78
"php-parallel-lint/php-parallel-lint": "^1.4",
8-
"phpstan/phpstan": "^1.12",
9-
"squizlabs/php_codesniffer": "^3.10"
9+
"phpstan/phpstan": "^1.12"
1010
},
1111
"config": {
1212
"optimize-autoloader": true,

0 commit comments

Comments
 (0)