Skip to content

Commit

Permalink
Fix coding standards violations
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Jun 22, 2018
1 parent 3b6c83e commit 1643873
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
8 changes: 4 additions & 4 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function plugin_fields_install() {
$dir = GLPI_ROOT . "/plugins/fields/inc/";
$item =strtolower($plug['class']);
if (file_exists("$dir$item.class.php")) {
if (!call_user_func(array($class,'install'), $migration, $version)) {
if (!call_user_func([$class,'install'], $migration, $version)) {
return false;
}
}
Expand Down Expand Up @@ -136,7 +136,7 @@ function plugin_fields_uninstall() {

if (file_exists("$dir$item.class.php")) {
include_once ("$dir$item.class.php");
if (!call_user_func(array($class,'uninstall'))) {
if (!call_user_func([$class,'uninstall'])) {
return false;
}
}
Expand Down Expand Up @@ -263,11 +263,11 @@ function plugin_fields_rule_matched($params = []) {

// update current field
$container->updateFieldsValues(
array(
[
'plugin_fields_containers_id' => $data['id'],
$field => $value,
'items_id' => $agent->fields['computers_id']
),
],
Computer::getType()
);
}
Expand Down
30 changes: 15 additions & 15 deletions inc/container.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ static function getSpecificValueToDisplay($field, $values, array $options = [])
}


function getValueToSelect($field_id_or_search_options, $name = '', $values = '', $options = array()) {
function getValueToSelect($field_id_or_search_options, $name = '', $values = '', $options = []) {

switch ($field_id_or_search_options['table'].'.'.$field_id_or_search_options['field']) {
// For searchoption "Type"
Expand All @@ -302,7 +302,7 @@ function getValueToSelect($field_id_or_search_options, $name = '', $values = '',
return parent::getValueToSelect($field_id_or_search_options, $name, $values, $options);
}

function defineTabs($options = array()) {
function defineTabs($options = []) {
$ong = [];
$this->addDefaultFormTab($ong);
$this->addStandardTab('PluginFieldsField', $ong, $options);
Expand Down Expand Up @@ -376,8 +376,8 @@ function prepareInputForAdd($input) {
}

$input['itemtypes'] = isset($input['itemtypes'])
? json_encode($input['itemtypes'], TRUE)
: NULL;
? json_encode($input['itemtypes'], true)
: null;

return $input;
}
Expand All @@ -401,7 +401,7 @@ function post_addItem() {

public static function generateTemplate($fields) {
$itemtypes = strlen($fields['itemtypes']) > 0
? json_decode($fields['itemtypes'], TRUE)
? json_decode($fields['itemtypes'], true)
: [];
foreach ($itemtypes as $itemtype) {
$sysname = self::getSystemName($itemtype, $fields['name']);
Expand Down Expand Up @@ -511,7 +511,7 @@ static function getTypeName($nb = 0) {
return __("Block", "fields");
}

public function showForm($ID, $options = array()) {
public function showForm($ID, $options = []) {
global $CFG_GLPI;

$this->initForm($ID, $options);
Expand Down Expand Up @@ -605,7 +605,7 @@ public function showForm($ID, $options = array()) {
return true;
}

static function showFormItemtype($params = array()) {
static function showFormItemtype($params = []) {
global $CFG_GLPI;

$is_domtab = isset($params['type']) && $params['type'] == 'domtab';
Expand All @@ -618,7 +618,7 @@ static function showFormItemtype($params = array()) {
'display_emptychoice' => $is_domtab]);

if ($is_domtab) {
Ajax::updateItemOnSelectEvent(array("dropdown_type$rand", "dropdown_itemtypes$rand"),
Ajax::updateItemOnSelectEvent(["dropdown_type$rand", "dropdown_itemtypes$rand"],
"subtype_$rand",
"../ajax/container_subtype_dropdown.php",
['type' => '__VALUE0__',
Expand Down Expand Up @@ -827,7 +827,7 @@ static function getEntries($type = 'tab', $full = false) {
AND `plugin_fields_containers_id` = '".$item['id']."'
AND `right` >= ".READ);
$first_found = array_shift($found);
if ($first_found['right'] == NULL || $first_found['right'] == 0) {
if ($first_found['right'] == null || $first_found['right'] == 0) {
continue;
}

Expand Down Expand Up @@ -878,7 +878,7 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) {
// needs to check if entity of item is in hierachy of $tab_name
foreach ($container->find("`is_active` = 1 AND `name` = '$tab_name'") as $data) {
$dataitemtypes = json_decode($data['itemtypes']);
if (in_array(get_class($item), $dataitemtypes) != FALSE) {
if (in_array(get_class($item), $dataitemtypes) != false) {
$entities = [$data['entities_id']];
if ($data['is_recursive']) {
$entities = getSonsOf(getTableForItemType('Entity'), $data['entities_id']);
Expand All @@ -901,7 +901,7 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem
$found_c = $container->find("`type` = 'tab' AND `name` = '$tabnum' AND is_active = 1");
foreach ($found_c as $data) {
$dataitemtypes = json_decode($data['itemtypes']);
if (in_array(get_class($item), $dataitemtypes) != FALSE) {
if (in_array(get_class($item), $dataitemtypes) != false) {
return PluginFieldsField::showForTabContainer($data['id'], $item->fields['id'], get_class($item));
}
}
Expand Down Expand Up @@ -963,7 +963,7 @@ function updateFieldsValues($data, $itemtype, $massiveaction = false) {
* @return nothing
*/
static function constructHistory($containers_id, $items_id, $itemtype, $data,
$old_values = array()) {
$old_values = []) {
// Don't log few itemtypes
$obj = new $itemtype();
if ($obj->dohistory == false) {
Expand Down Expand Up @@ -1189,7 +1189,7 @@ static function findContainer($itemtype, $type = 'tab', $subtype = '') {
foreach ($itemtypes as $data) {
$dataitemtypes = json_decode($data['itemtypes']);
$item = new $itemtype();
if (in_array($item->getType(), $dataitemtypes) != FALSE) {
if (in_array($item->getType(), $dataitemtypes) != false) {
$id = $data['id'];
}
}
Expand All @@ -1206,7 +1206,7 @@ static function findContainer($itemtype, $type = 'tab', $subtype = '') {
$found = $profile->find("`profiles_id` = '".$_SESSION['glpiactiveprofile']['id']."'
AND $condition");
$first_found = array_shift($found);
if ($first_found['right'] == NULL || $first_found['right'] == 0) {
if ($first_found['right'] == null || $first_found['right'] == 0) {
return false;
}
}
Expand Down Expand Up @@ -1291,7 +1291,7 @@ static function preItem(CommonDBTM $item) {
//need to check if container is usable on this object entity
$loc_c = new PluginFieldsContainer;
$loc_c->getFromDB($c_id);
$entities = array($loc_c->fields['entities_id']);
$entities = [$loc_c->fields['entities_id']];
if ($loc_c->fields['is_recursive']) {
$entities = getSonsOf(getTableForItemType('Entity'), $loc_c->fields['entities_id']);
}
Expand Down
8 changes: 4 additions & 4 deletions inc/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ function getNextRanking() {
return 0;
}

function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) {
if (!$withtemplate) {
$nb = 0;
switch ($item->getType()) {
Expand All @@ -243,13 +243,13 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
"`plugin_fields_containers_id` = '".$item->getID()."'"));
}

static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) {
$fup = new self();
$fup->showSummary($item);
return true;
}

function defineTabs($options = array()) {
function defineTabs($options = []) {
$ong = [];
$this->addDefaultFormTab($ong);
$this->addStandardTab('PluginFieldsLabelTranslation', $ong, $options);
Expand Down Expand Up @@ -348,7 +348,7 @@ function showSummary($container) {
}


function showForm($ID, $options = array()) {
function showForm($ID, $options = []) {
global $CFG_GLPI;

if (isset($options['parent_id']) && !empty($options['parent_id'])) {
Expand Down
6 changes: 3 additions & 3 deletions inc/labeltranslation.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ static function createForItem(CommonDBTM $item) {
return true;
}

function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) {
$nb = countElementsInTable(self::getTable(),
"`plugin_fields_itemtype` = '{$item::getType()}' AND
`plugin_fields_items_id` = '{$item->getID()}'");
return self::createTabEntry(self::getTypeName($nb), $nb);

}

static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) {
self::showTranslations($item);
}

Expand Down Expand Up @@ -177,7 +177,7 @@ static function showTranslations(CommonDBTM $item) {
*
* @return void
*/
function showForm($itemtype, $items_id, $id=-1) {
function showForm($itemtype, $items_id, $id = -1) {
global $CFG_GLPI;

if ($id > 0) {
Expand Down
4 changes: 2 additions & 2 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function plugin_init_fields() {

// Init hook about itemtype(s) for plugin fields
if (!isset($PLUGIN_HOOKS['plugin_fields'])) {
$PLUGIN_HOOKS['plugin_fields'] = array();
$PLUGIN_HOOKS['plugin_fields'] = [];
}

// When a Category is changed during ticket creation
Expand Down Expand Up @@ -241,7 +241,7 @@ function plugin_fields_checkFiles($force = false) {

foreach ($containers as $container) {
$itemtypes = (strlen($container['itemtypes']) > 0)
? json_decode($container['itemtypes'], TRUE)
? json_decode($container['itemtypes'], true)
: [];
foreach ($itemtypes as $itemtype) {
$classname = PluginFieldsContainer::getClassname($itemtype, $container['name']);
Expand Down

0 comments on commit 1643873

Please sign in to comment.