Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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-CS2.0' => true,
'trailing_comma_in_multiline' => ['elements' => ['arguments', 'array_destructuring', 'arrays']], // For PHP 7.4 compatibility
];
/** @var Config $config */
$config = $baseline($finder);

return $config
->setRules($rules)
->setFinder($finder)
->setUsingCache(false);
->setCacheFile(__DIR__ . '/var/php-cs-fixer/.php-cs-fixer.cache')
;
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Add Transifex translations link to README

### Fixed

- CI: use the GLPI shared php-cs-fixer configuration and apply its coding style

## [2.16.0] - 2026-10-05

### Fixed
Expand Down
3 changes: 1 addition & 2 deletions inc/backend.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* -------------------------------------------------------------------------
*/


use function Safe\preg_match;

/*
Expand Down Expand Up @@ -57,7 +56,7 @@ abstract class PluginDatainjectionBackend
* Get header of the file
*
* @param PluginDatainjectionData|null $injectionData
* @param boolean $header_present
* @param bool $header_present
*
* @return array with the data from the header
**/
Expand Down
6 changes: 3 additions & 3 deletions inc/backendcsv.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function setDelimiter($delimiter)


/**
* @param boolean $present (true by default)
* @param bool $present (true by default)
**/
public function setHeaderPresent($present = true)
{
Expand All @@ -88,7 +88,7 @@ public function setHeaderPresent($present = true)
*
* @param mixed $fic
* @param array $data
* @param integer $encoding (default 1)
* @param int $encoding (default 1)
**/
public static function parseLine($fic, $data, $encoding = 1)
{
Expand Down Expand Up @@ -123,7 +123,7 @@ public function init($newfile, $encoding)
/**
* Read a CSV file and store data in an array
*
* @param integer $numberOfLines inumber of lines to be read (-1 means all file) (default 1)
* @param int $numberOfLines inumber of lines to be read (-1 means all file) (default 1)
**/
public function read($numberOfLines = 1)
{
Expand Down
2 changes: 1 addition & 1 deletion inc/backendinterface.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ interface PluginDatainjectionBackendInterface
/**
* Read from file
*
* @param integer $numberOfLines (default 1)
* @param int $numberOfLines (default 1)
**/
public function read($numberOfLines = 1);

Expand Down
2 changes: 1 addition & 1 deletion inc/clientinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public static function showUploadFileForm($options = [])

/**
* @param PluginDatainjectionModel $model PluginDatainjectionModel object
* @param integer $entities_id
* @param int $entities_id
**/
public static function showInjectionForm(PluginDatainjectionModel $model, $entities_id)
{
Expand Down
20 changes: 10 additions & 10 deletions inc/commoninjectionlib.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public function areTypeMandatoryFieldsOK($injectionClass)
*
* @param string $field_type the type of field
*
* @return boolean true if it's a dropdown type, false if not
* @return bool true if it's a dropdown type, false if not
**/
public static function isFieldADropdown($field_type)
{
Expand Down Expand Up @@ -599,7 +599,7 @@ private function getFieldValue(
$itemtype,
$searchOption,
$field,
$value
$value,
) {
$linkfield = $searchOption['storevaluein'] ?? $searchOption['linkfield'];

Expand Down Expand Up @@ -969,7 +969,7 @@ private function unsetValue($itemtype, $field)
* @param string $itemtype
* @param string $field name
* @param string|int $value of the field
* @param boolean $fromdb boolean
* @param bool $fromdb boolean
**/
private function setValueForItemtype($itemtype, $field, $value, $fromdb = false)
{
Expand Down Expand Up @@ -1409,7 +1409,7 @@ private function check()
*
* @param mixed $val the value to check
*
* @return boolean true if it's a float, false otherwise
* @return bool true if it's a float, false otherwise
*/
private function isFloat($val)
{
Expand All @@ -1422,7 +1422,7 @@ private function isFloat($val)
*
* @param mixed $val the value to check
*
* @return boolean true if it's an integer, false otherwise
* @return bool true if it's an integer, false otherwise
*/
private function isInteger($val)
{
Expand All @@ -1437,7 +1437,7 @@ private function isInteger($val)
* @param array $option the option associated with the field
* @param string $field_name the field name
* @param mixed $data the data to check
* @param boolean $mandatory is the field mandatory
* @param bool $mandatory is the field mandatory
*
* @return int the result of the check
**/
Expand Down Expand Up @@ -1772,7 +1772,7 @@ public function processAddOrUpdate()
/**
* Flag the current line as partially injected and log the reason
*
* @param integer $code log label describing the reason
* @param int $code log label describing the reason
* @param string $itemtype itemtype that could not be written
**/
private function addCheckWarning(int $code, string $itemtype): void
Expand All @@ -1789,7 +1789,7 @@ private function addCheckWarning(int $code, string $itemtype): void
* @param PluginDatainjectionInjectionInterface $injectionClass class which represents the object to inject
* @param CommonDBTM $item the CommonDBTM object representing the itemtype to inject
* @param array|string|false $values the values to inject
* @param boolean $add true to insert an object, false to update an existing object
* @param bool $add true to insert an object, false to update an existing object
*
* @return int|string the id of the object added or updated
**/
Expand Down Expand Up @@ -2252,7 +2252,7 @@ private function addTemplateFields($itemtype)
* Log event into the history
*
* @param object $item the item to log
* @param boolean $add true if it's an add, false if it's an update
* @param bool $add true if it's an add, false if it's an update
*
* @return void nothing
**/
Expand Down Expand Up @@ -2354,7 +2354,7 @@ public static function getLogLabel($type)
public static function addToSearchOptions(
array $type_searchOptions,
array $options,
PluginDatainjectionInjectionInterface $injectionClass
PluginDatainjectionInjectionInterface $injectionClass,
) {

self::addTemplateSearchOptions($injectionClass, $type_searchOptions);
Expand Down
2 changes: 1 addition & 1 deletion inc/data.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getData()


/**
* @param integer $line_id
* @param int $line_id
**/
public function getDataAtLine($line_id)
{
Expand Down
2 changes: 1 addition & 1 deletion inc/devicecaseinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function getOptions($primary_type = '')

/**
* @param array $values
* @param boolean $add (true by default)
* @param bool $add (true by default)
* @param array|null $rights array
**/
public function processAfterInsertOrUpdate($values, $add = true, $rights = [])
Expand Down
2 changes: 1 addition & 1 deletion inc/devicecontrolinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function getOptions($primary_type = '')

/**
* @param array $values
* @param boolean $add (true by default)
* @param bool $add (true by default)
* @param array|null $rights array
**/
public function processAfterInsertOrUpdate($values, $add = true, $rights = [])
Expand Down
2 changes: 1 addition & 1 deletion inc/devicedriveinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function getOptions($primary_type = '')

/**
* @param array $values
* @param boolean $add (true by default)
* @param bool $add (true by default)
* @param array|null $rights array
*/
public function processAfterInsertOrUpdate($values, $add = true, $rights = [])
Expand Down
2 changes: 1 addition & 1 deletion inc/deviceharddriveinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function getOptions($primary_type = '')

/**
* @param array $values
* @param boolean $add (true by default)
* @param bool $add (true by default)
* @param array|null $rights array
*/
public function processAfterInsertOrUpdate($values, $add = true, $rights = [])
Expand Down
2 changes: 1 addition & 1 deletion inc/devicememoryinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function getOptions($primary_type = '')

/**
* @param array $values
* @param boolean $add (true by default)
* @param bool $add (true by default)
* @param array|null $rights array
**/
public function processAfterInsertOrUpdate($values, $add = true, $rights = [])
Expand Down
2 changes: 1 addition & 1 deletion inc/devicemotherboardinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function getOptions($primary_type = '')

/**
* @param array $values
* @param boolean $add (true by default)
* @param bool $add (true by default)
* @param array|null $rights array
*/
public function processAfterInsertOrUpdate($values, $add = true, $rights = [])
Expand Down
2 changes: 1 addition & 1 deletion inc/devicenetworkcardinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function getOptions($primary_type = '')

/**
* @param array $values
* @param boolean $add (true by default)
* @param bool $add (true by default)
* @param array|null $rights array
*/
public function processAfterInsertOrUpdate($values, $add = true, $rights = [])
Expand Down
2 changes: 1 addition & 1 deletion inc/deviceprocessorinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function getOptions($primary_type = '')

/**
* @param array $values
* @param boolean $add (true by default)
* @param bool $add (true by default)
* @param array|null $rights array
**/
public function processAfterInsertOrUpdate($values, $add = true, $rights = [])
Expand Down
4 changes: 2 additions & 2 deletions inc/dropdown.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ public static function getFileEncodingValue()

public static function portUnicityValues()
{
return [__('Port number'), __('Name'), __('Mac address'), __('Port number') . "+" . __('Name'), __('Port number') . "+" . __('Mac address'), __('Port number') . "+" . __('Name') . "+" .
__('Mac address')];
return [__('Port number'), __('Name'), __('Mac address'), __('Port number') . "+" . __('Name'), __('Port number') . "+" . __('Mac address'), __('Port number') . "+" . __('Name') . "+"
. __('Mac address')];
}


Expand Down
2 changes: 1 addition & 1 deletion inc/engine.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function addValueToInject(
$searchOptions,
$mapping,
$value,
$several = []
$several = [],
): void {

// Option will be found only for "main" type.
Expand Down
2 changes: 1 addition & 1 deletion inc/entityinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static function getRootEntityName()

/**
* @param array $input array
* @param boolean $add (true by default)
* @param bool $add (true by default)
* @param array|null $rights array
**/
public function customimport($input = [], $add = true, $rights = [])
Expand Down
10 changes: 5 additions & 5 deletions inc/info.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

use Glpi\Application\View\TemplateRenderer;

use function Safe\ob_start;
use function Safe\ob_get_clean;
use function Safe\ob_start;

class PluginDatainjectionInfo extends CommonDBTM
{
Expand Down Expand Up @@ -74,14 +74,14 @@ public function getInfosType()

/**
* @param PluginDatainjectionModel $model PluginDatainjectionModel object
* @param boolean $canedit (false by default)
* @param bool $canedit (false by default)
**/
public static function showAddInfo(PluginDatainjectionModel $model, $canedit = false)
{

if ($canedit) {
echo "<form method='post' name='form' id='form' action='" .
Toolbox::getItemTypeFormURL(self::class) . "'>";
echo "<form method='post' name='form' id='form' action='"
. Toolbox::getItemTypeFormURL(self::class) . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr>";
echo "<th>" . __s('Tables', 'datainjection') . "</th>";
Expand Down Expand Up @@ -327,7 +327,7 @@ public static function showAdditionalInformation(
PluginDatainjectionInfo $info,
$option,
$injectionClass,
$values = []
$values = [],
) {

$name = "info[" . $option['linkfield'] . "]";
Expand Down
2 changes: 1 addition & 1 deletion inc/infocollection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class PluginDatainjectionInfoCollection
/**
* Load all the mappings for a specified model
*
* @param integer $models_id the model ID
* @param int $models_id the model ID
**/
public function load($models_id)
{
Expand Down
2 changes: 1 addition & 1 deletion inc/injectioninterface.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interface PluginDatainjectionInjectionInterface
/**
* Tells datainjection is the type is a primary type or not
*
* @return boolean a boolean
* @return bool a boolean
**/
public function isPrimaryType();

Expand Down
6 changes: 3 additions & 3 deletions inc/injectiontype.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class PluginDatainjectionInjectionType
/**
* Return all injectable types
*
* @param boolean $only_primary return only primary types (false by default)
* @param bool $only_primary return only primary types (false by default)
*
* @return array which contains array(itemtype => itemtype name)
**/
Expand Down Expand Up @@ -94,7 +94,7 @@ public static function getItemtypes($only_primary = false)
* Display a list of all importable types using datainjection plugin
*
* @param string $value the selected value (default '')
* @param boolean $only_primary (false by default)
* @param bool $only_primary (false by default)
**/
public static function dropdown($value = '', $only_primary = false)
{
Expand Down Expand Up @@ -286,7 +286,7 @@ public static function dropdownFields($options = [])
* @param array $option array the current searchOption (field definition)
* @param array $mapping
*
* @return boolean the value matches the searchOption or not
* @return bool the value matches the searchOption or not
**/
public static function isEqual($option, $mapping)
{
Expand Down
Loading
Loading