diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index ddf4eba..4c7cac8 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -3,19 +3,26 @@ use PhpCsFixer\Config; use PhpCsFixer\Finder; +$baseline_file = __DIR__ . '/../../PluginsPhpCsFixer.php'; +if (!file_exists($baseline_file)) { + throw new RuntimeException( + sprintf( + 'Unable to find "%s". Running php-cs-fixer on a plugin requires a GLPI development checkout that ships PluginsPhpCsFixer.php.', + $baseline_file, + ), + ); +} + +$baseline = require $baseline_file; + $finder = Finder::create() ->in(__DIR__) - ->name('*.php') - ->ignoreVCSIgnored(true); - -$config = new Config(); + ->ignoreVCSIgnored(true) + ->name('*.php'); -$rules = [ - '@PER-CS' => true, // Latest PER rules. -]; +/** @var Config $config */ +$config = $baseline($finder); return $config - ->setRules($rules) - ->setFinder($finder) ->setCacheFile(__DIR__ . '/var/php-cs-fixer/.php-cs-fixer.cache') ; diff --git a/CHANGELOG.md b/CHANGELOG.md index c555f88..ab14cf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fix search crash when the "Tags - Entity" column is displayed - Fix tag associate item +- Fix lint by applying GLPI shared coding standards ## [2.15.0] - 2026-10-06 diff --git a/hook.php b/hook.php index 18a9fa8..8db6189 100644 --- a/hook.php +++ b/hook.php @@ -273,7 +273,7 @@ function plugin_tag_MassiveActions($itemtype = '') /** * Plugin install process * - * @return boolean + * @return bool */ function plugin_tag_install() { @@ -309,7 +309,7 @@ function plugin_tag_install() /** * Plugin uninstall process * - * @return boolean + * @return bool */ function plugin_tag_uninstall() { diff --git a/inc/questiontype.class.php b/inc/questiontype.class.php index 8178de4..7c32649 100644 --- a/inc/questiontype.class.php +++ b/inc/questiontype.class.php @@ -137,7 +137,7 @@ public function getTargetQuestionType(array $rawData): string public function getAvailableTags(?Form $form = null): array { $active_entities_ids = Session::getActiveEntities(); - if ($active_entities_ids === [] && $form) { + if ($active_entities_ids === [] && $form instanceof Form) { $active_entities_ids = [$form->getEntityID()]; } diff --git a/inc/tag.class.php b/inc/tag.class.php index 06bc739..3389455 100644 --- a/inc/tag.class.php +++ b/inc/tag.class.php @@ -814,7 +814,7 @@ public function prepareInputForUpdate($input) * Check that the color field, if provided, is a valid hexadecimal color * * @param array $input - * @return boolean + * @return bool */ public function checkColorField($input = []) { @@ -850,7 +850,7 @@ public function encodeSubtypes($input) * Check all mandatory field are filled * * @param array $input - * @return boolean + * @return bool */ public function checkMandatoryFields($input = []) { @@ -876,7 +876,7 @@ public function checkMandatoryFields($input = []) /** * Retrieve the current itemtype from the current page url * - * @return string|boolean false if not itemtype found, the string itemtype if found + * @return string|bool false if not itemtype found, the string itemtype if found */ public static function getCurrentItemtype() { diff --git a/inc/tagitem.class.php b/inc/tagitem.class.php index 8bbd800..39e02f4 100644 --- a/inc/tagitem.class.php +++ b/inc/tagitem.class.php @@ -152,7 +152,7 @@ public static function uninstall() /** * Display the list of available itemtype * - * @return boolean + * @return bool */ public static function showForTag(PluginTagTag $tag) { @@ -467,7 +467,7 @@ public static function showForTag(PluginTagTag $tag) * Add tags to an item * * - * @return boolean + * @return bool */ public static function updateItem(CommonDBTM $item, bool $delete_existing_tags = true) { @@ -584,7 +584,7 @@ private static function keepVisibleTags(array $tag_values): array /** * Delete all tags associated to an item * - * @return boolean + * @return bool */ public static function purgeItem(CommonDBTM $item) { diff --git a/rector.php b/rector.php index 54d3dc1..2eeadcc 100644 --- a/rector.php +++ b/rector.php @@ -48,6 +48,7 @@ $config = $baseline([ __DIR__ . '/ajax', __DIR__ . '/inc', + __DIR__ . '/src', __DIR__ . '/stubs', __DIR__ . '/tests', ]); diff --git a/src/Controller/TagItemController.php b/src/Controller/TagItemController.php index 6a7a571..a88e716 100644 --- a/src/Controller/TagItemController.php +++ b/src/Controller/TagItemController.php @@ -35,11 +35,11 @@ use Glpi\Exception\Http\AccessDeniedHttpException; use Glpi\Exception\Http\BadRequestHttpException; use Glpi\Http\RedirectResponse; +use Glpi\Routing\Attribute\ItemtypeFormRoute; use Html; use PluginTagTag; use PluginTagTagItem; use Session; -use Glpi\Routing\Attribute\ItemtypeFormRoute; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; diff --git a/tests/QuestionTypeTestCase.php b/tests/QuestionTypeTestCase.php index b9d923e..0e6834e 100644 --- a/tests/QuestionTypeTestCase.php +++ b/tests/QuestionTypeTestCase.php @@ -35,7 +35,6 @@ use Glpi\Controller\Form\RendererController; use Glpi\Form\Form; use Glpi\Tests\FormTesterTrait; -use GlpiPlugin\Tag\Tests\TagTestCase; use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\HttpFoundation\Request; diff --git a/tests/Units/TagTest.php b/tests/Units/TagTest.php index aabfb6d..d23d0a3 100644 --- a/tests/Units/TagTest.php +++ b/tests/Units/TagTest.php @@ -31,9 +31,9 @@ namespace GlpiPlugin\Tag\Tests\Units; use DBmysql; +use Glpi\Search\SearchOption; use GlpiPlugin\Tag\Tests\TagTestCase; use PluginTagTag; -use Glpi\Search\SearchOption; use Search; use Ticket;