Skip to content

Commit

Permalink
Feat: php-cs-fixer (#154)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Rom1-B authored Sep 9, 2024
1 parent 856cb43 commit 2a8df0a
Show file tree
Hide file tree
Showing 16 changed files with 2,360 additions and 656 deletions.
20 changes: 20 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$finder = Finder::create()
->in(__DIR__)
->name('*.php');

$config = new Config();

$rules = [
'@PER-CS2.0' => true,
'trailing_comma_in_multiline' => ['elements' => ['arguments', 'array_destructuring', 'arrays']], // For PHP 7.4 compatibility
];

return $config
->setRules($rules)
->setFinder($finder)
->setUsingCache(false);
4 changes: 2 additions & 2 deletions ajax/display_alerts.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
*/

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

Expand Down
4 changes: 2 additions & 2 deletions ajax/hide_alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
*/

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

Expand Down
26 changes: 13 additions & 13 deletions ajax/targets.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@
*/

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

Session::checkLoginUser();

if (isset($_POST['type']) && !empty($_POST['type'])) {
echo "<table class='tab_format'>";
echo "<tr>";
echo "<td>";
echo '<tr>';
echo '<td>';
switch ($_POST['type']) {
case 'User':
User::dropdown(['name' => 'items_id',
'right' => 'all',
'entity' => $_POST['entities_id'],
'entity_sons' => $_POST['is_recursive'],
User::dropdown(['name' => 'items_id',
'right' => 'all',
'entity' => $_POST['entities_id'],
'entity_sons' => $_POST['is_recursive'],
]);
break;

Expand All @@ -53,14 +53,14 @@
break;

case 'Profile':
Profile::dropdown(['name' => 'items_id',
'toadd' => [-1 => __('All', 'news')]
Profile::dropdown(['name' => 'items_id',
'toadd' => [-1 => __('All', 'news')],
]);
break;
}
echo "</td>";
echo '</td>';
echo "<td><input type='submit' name='addvisibility' value=\"" . _sx('button', 'Add', 'news') . "\"
class='submit'></td>";
echo "</tr>";
echo "</table>";
echo '</tr>';
echo '</table>';
}
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"php": ">=7.4"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.64",
"glpi-project/tools": "^0.7.3",
"php-parallel-lint/php-parallel-lint": "^1.4",
"phpstan/phpstan": "^1.12",
"squizlabs/php_codesniffer": "^3.10"
"phpstan/phpstan": "^1.12"
},
"config": {
"optimize-autoloader": true,
Expand Down
Loading

0 comments on commit 2a8df0a

Please sign in to comment.