Skip to content

Commit dfcd71b

Browse files
authored
Fix phpdoc
* Fix phpdoc; refs pluginsGLPI/mreporting#275 (comment) * Few CS fixes
1 parent e342499 commit dfcd71b

7 files changed

Lines changed: 18 additions & 149 deletions

File tree

.phpstan-baseline.php

Lines changed: 0 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -703,12 +703,6 @@
703703
'count' => 1,
704704
'path' => __DIR__ . '/src/Auth.php',
705705
];
706-
$ignoreErrors[] = [
707-
'message' => '#^Method Auth\\:\\:login\\(\\) should return bool but returns int\\.$#',
708-
'identifier' => 'return.type',
709-
'count' => 1,
710-
'path' => __DIR__ . '/src/Auth.php',
711-
];
712706
$ignoreErrors[] = [
713707
'message' => '#^Negated boolean expression is always true\\.$#',
714708
'identifier' => 'booleanNot.alwaysTrue',
@@ -727,36 +721,6 @@
727721
'count' => 1,
728722
'path' => __DIR__ . '/src/Auth.php',
729723
];
730-
$ignoreErrors[] = [
731-
'message' => '#^Property Auth\\:\\:\\$auth_succeded \\(int\\) does not accept bool\\.$#',
732-
'identifier' => 'assign.propertyType',
733-
'count' => 1,
734-
'path' => __DIR__ . '/src/Auth.php',
735-
];
736-
$ignoreErrors[] = [
737-
'message' => '#^Property Auth\\:\\:\\$auth_succeded \\(int\\) does not accept false\\.$#',
738-
'identifier' => 'assign.propertyType',
739-
'count' => 5,
740-
'path' => __DIR__ . '/src/Auth.php',
741-
];
742-
$ignoreErrors[] = [
743-
'message' => '#^Property Auth\\:\\:\\$auth_succeded \\(int\\) does not accept true\\.$#',
744-
'identifier' => 'assign.propertyType',
745-
'count' => 1,
746-
'path' => __DIR__ . '/src/Auth.php',
747-
];
748-
$ignoreErrors[] = [
749-
'message' => '#^Property Auth\\:\\:\\$password_expired \\(int\\) does not accept default value of type false\\.$#',
750-
'identifier' => 'property.defaultValue',
751-
'count' => 1,
752-
'path' => __DIR__ . '/src/Auth.php',
753-
];
754-
$ignoreErrors[] = [
755-
'message' => '#^Property Auth\\:\\:\\$user_present \\(int\\) does not accept bool\\.$#',
756-
'identifier' => 'assign.propertyType',
757-
'count' => 1,
758-
'path' => __DIR__ . '/src/Auth.php',
759-
];
760724
$ignoreErrors[] = [
761725
'message' => '#^Strict comparison using \\!\\=\\= between 2\\|3\\|4 and null will always evaluate to true\\.$#',
762726
'identifier' => 'notIdentical.alwaysTrue',
@@ -805,30 +769,6 @@
805769
'count' => 1,
806770
'path' => __DIR__ . '/src/AuthLDAP.php',
807771
];
808-
$ignoreErrors[] = [
809-
'message' => '#^Property Auth\\:\\:\\$auth_succeded \\(int\\) does not accept false\\.$#',
810-
'identifier' => 'assign.propertyType',
811-
'count' => 1,
812-
'path' => __DIR__ . '/src/AuthLDAP.php',
813-
];
814-
$ignoreErrors[] = [
815-
'message' => '#^Property Auth\\:\\:\\$auth_succeded \\(int\\) does not accept true\\.$#',
816-
'identifier' => 'assign.propertyType',
817-
'count' => 1,
818-
'path' => __DIR__ . '/src/AuthLDAP.php',
819-
];
820-
$ignoreErrors[] = [
821-
'message' => '#^Property Auth\\:\\:\\$user_present \\(int\\) does not accept false\\.$#',
822-
'identifier' => 'assign.propertyType',
823-
'count' => 1,
824-
'path' => __DIR__ . '/src/AuthLDAP.php',
825-
];
826-
$ignoreErrors[] = [
827-
'message' => '#^Property Auth\\:\\:\\$user_present \\(int\\) does not accept true\\.$#',
828-
'identifier' => 'assign.propertyType',
829-
'count' => 2,
830-
'path' => __DIR__ . '/src/AuthLDAP.php',
831-
];
832772
$ignoreErrors[] = [
833773
'message' => '#^Strict comparison using \\!\\=\\= between mixed and null will always evaluate to true\\.$#',
834774
'identifier' => 'notIdentical.alwaysTrue',
@@ -1699,12 +1639,6 @@
16991639
'count' => 1,
17001640
'path' => __DIR__ . '/src/Console/Plugin/InstallCommand.php',
17011641
];
1702-
$ignoreErrors[] = [
1703-
'message' => '#^Property Auth\\:\\:\\$auth_succeded \\(int\\) does not accept true\\.$#',
1704-
'identifier' => 'assign.propertyType',
1705-
'count' => 1,
1706-
'path' => __DIR__ . '/src/Console/Plugin/InstallCommand.php',
1707-
];
17081642
$ignoreErrors[] = [
17091643
'message' => '#^Instanceof between DBmysql and DBmysql will always evaluate to true\\.$#',
17101644
'identifier' => 'instanceof.alwaysTrue',
@@ -4453,42 +4387,6 @@
44534387
'count' => 1,
44544388
'path' => __DIR__ . '/src/SNMPCredential.php',
44554389
];
4456-
$ignoreErrors[] = [
4457-
'message' => '#^Call to function is_array\\(\\) with array will always evaluate to true\\.$#',
4458-
'identifier' => 'function.alreadyNarrowedType',
4459-
'count' => 2,
4460-
'path' => __DIR__ . '/src/SavedSearch.php',
4461-
];
4462-
$ignoreErrors[] = [
4463-
'message' => '#^Method SavedSearch\\:\\:croncountAll\\(\\) with return type void returns int but should not return anything\\.$#',
4464-
'identifier' => 'return.void',
4465-
'count' => 1,
4466-
'path' => __DIR__ . '/src/SavedSearch.php',
4467-
];
4468-
$ignoreErrors[] = [
4469-
'message' => '#^Return type \\(void\\) of method SavedSearch\\:\\:showForm\\(\\) should be compatible with return type \\(bool\\) of method CommonDBTM\\:\\:showForm\\(\\)$#',
4470-
'identifier' => 'method.childReturnType',
4471-
'count' => 1,
4472-
'path' => __DIR__ . '/src/SavedSearch.php',
4473-
];
4474-
$ignoreErrors[] = [
4475-
'message' => '#^Method SavedSearch_Alert\\:\\:showForSavedSearch\\(\\) with return type void returns false but should not return anything\\.$#',
4476-
'identifier' => 'return.void',
4477-
'count' => 1,
4478-
'path' => __DIR__ . '/src/SavedSearch_Alert.php',
4479-
];
4480-
$ignoreErrors[] = [
4481-
'message' => '#^Property Auth\\:\\:\\$auth_succeded \\(int\\) does not accept true\\.$#',
4482-
'identifier' => 'assign.propertyType',
4483-
'count' => 1,
4484-
'path' => __DIR__ . '/src/SavedSearch_Alert.php',
4485-
];
4486-
$ignoreErrors[] = [
4487-
'message' => '#^Unreachable statement \\- code above always terminates\\.$#',
4488-
'identifier' => 'deadCode.unreachable',
4489-
'count' => 1,
4490-
'path' => __DIR__ . '/src/SavedSearch_User.php',
4491-
];
44924390
$ignoreErrors[] = [
44934391
'message' => '#^Call to function is_array\\(\\) with array will always evaluate to true\\.$#',
44944392
'identifier' => 'function.alreadyNarrowedType',
@@ -4651,18 +4549,6 @@
46514549
'count' => 1,
46524550
'path' => __DIR__ . '/src/Session.php',
46534551
];
4654-
$ignoreErrors[] = [
4655-
'message' => '#^Property Auth\\:\\:\\$auth_succeded \\(int\\) does not accept false\\.$#',
4656-
'identifier' => 'assign.propertyType',
4657-
'count' => 3,
4658-
'path' => __DIR__ . '/src/Session.php',
4659-
];
4660-
$ignoreErrors[] = [
4661-
'message' => '#^Property Auth\\:\\:\\$auth_succeded \\(int\\) does not accept true\\.$#',
4662-
'identifier' => 'assign.propertyType',
4663-
'count' => 3,
4664-
'path' => __DIR__ . '/src/Session.php',
4665-
];
46664552
$ignoreErrors[] = [
46674553
'message' => '#^Property Laminas\\\\I18n\\\\Translator\\\\Translator\\:\\:\\$cache \\(Laminas\\\\Cache\\\\Storage\\\\StorageInterface\\|null\\) does not accept Glpi\\\\Cache\\\\I18nCache\\|null\\.$#',
46684554
'identifier' => 'assign.propertyType',

front/login.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
$_POST = array_map('stripslashes', $_POST);
6060

6161
//Do login and checks
62-
//$user_present = 1;
6362
if (isset($_SESSION['namfield']) && isset($_POST[$_SESSION['namfield']])) {
6463
$login = $_POST[$_SESSION['namfield']];
6564
} else {

src/Auth.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ class Auth extends CommonGLPI
5151
public $extauth = 0;
5252
/** @var array External authentication methods */
5353
public $authtypes;
54-
/** @var int Indicates if the user is authenticated or not */
55-
public $auth_succeded = 0;
56-
/** @var int Indicates if the user is already present in database */
57-
public $user_present = 0;
58-
/** @var int Indicates if the user password expired */
54+
/** @var boolean Indicates if the user is authenticated or not */
55+
public $auth_succeded = false;
56+
/** @var boolean Indicates if the user is already present in database */
57+
public $user_present = false;
58+
/** @var boolean Indicates if the user password expired */
5959
public $password_expired = false;
6060

6161
/**
@@ -461,7 +461,7 @@ public function connection_db($name, $password)
461461
-1 !== $pass_expiration_delay
462462
&& $row['password_expiration_date'] < $_SESSION['glpi_currenttime']
463463
) {
464-
$this->password_expired = 1;
464+
$this->password_expired = true;
465465
}
466466

467467
// Update password if needed
@@ -478,7 +478,7 @@ public function connection_db($name, $password)
478478
}
479479
$this->user->getFromDBByCrit(['id' => $row['id']]);
480480
$this->extauth = 0;
481-
$this->user_present = 1;
481+
$this->user_present = true;
482482
$this->user->fields["authtype"] = self::DB_GLPI;
483483
$this->user->fields["password"] = $password;
484484

@@ -780,7 +780,7 @@ public function login($login_name, $login_password, $noauto = false, $remember_m
780780
global $CFG_GLPI, $DB;
781781

782782
$this->getAuthMethods();
783-
$this->user_present = 1;
783+
$this->user_present = true;
784784
$this->auth_succeded = false;
785785
//In case the user was deleted in the LDAP directory
786786
$user_deleted_ldap = false;

src/AuthLDAP.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3342,10 +3342,9 @@ public static function importUserFromServers($options = [])
33423342
$params['method'] = self::IDENTIFIER_EMAIL;
33433343
}
33443344

3345-
$auth->user_present = $auth->userExists($options);
3346-
3347-
//If the user does not exists
3348-
if ($auth->user_present == 0) {
3345+
//If the user does not exist
3346+
if ($auth->userExists($options) === Auth::USER_DOESNT_EXIST) {
3347+
$auth->user_present = true;
33493348
$auth->getAuthMethods();
33503349
$ldap_methods = $auth->authtypes["ldap"];
33513350

src/SavedSearch.php

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -463,18 +463,6 @@ public function cleanDBonPurge()
463463
}
464464

465465

466-
/**
467-
* Print the saved search form
468-
*
469-
* @param integer $ID ID of the item
470-
* @param array $options possible options:
471-
* - target for the Form
472-
* - type when adding
473-
* - url when adding
474-
* - itemtype when adding
475-
*
476-
* @return void
477-
**/
478466
public function showForm($ID, array $options = [])
479467
{
480468

@@ -597,6 +585,7 @@ public function showForm($ID, array $options = [])
597585
}
598586

599587
$this->showFormButtons($options);
588+
return true;
600589
}
601590

602591

@@ -998,9 +987,6 @@ public function getMine(?string $itemtype = null, bool $inverse = false, bool $e
998987
if ($user->getFromDB(Session::getLoginUserID())) {
999988
$personalorder = importArrayFromDB($user->fields[$personalorderfield]);
1000989
}
1001-
if (!is_array($personalorder)) {
1002-
$personalorder = [];
1003-
}
1004990

1005991
// Add on personal order
1006992
if (count($personalorder)) {
@@ -1067,9 +1053,9 @@ public function saveOrder(array $items)
10671053
/**
10681054
* Display buttons
10691055
*
1070-
* @param integer $type SavedSearch type to use
1071-
* @param integer $itemtype Device type of item where is the bookmark (default 0)
1072-
* @param bool $active Should the icon be displayed as active ?
1056+
* @param integer $type SavedSearch type to use
1057+
* @param integer|string $itemtype Device type of item where is the bookmark (default 0)
1058+
* @param bool $active Should the icon be displayed as active ?
10731059
*
10741060
* @return void
10751061
**/
@@ -1220,7 +1206,7 @@ public static function dropdownDoCount(array $options = [])
12201206
$p['value'] = self::COUNT_AUTO;
12211207
$p['display'] = true;
12221208

1223-
if (is_array($options) && count($options)) {
1209+
if (count($options)) {
12241210
foreach ($options as $key => $val) {
12251211
$p[$key] = $val;
12261212
}
@@ -1304,7 +1290,7 @@ public static function cronInfo($name)
13041290
*
13051291
* @param CronTask $task CronTask instance
13061292
*
1307-
* @return void
1293+
* @return integer
13081294
**/
13091295
public static function croncountAll($task)
13101296
{

src/SavedSearch_Alert.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public static function showForSavedSearch(SavedSearch $search, $withtemplate = 0
207207
!$search->getFromDB($ID)
208208
|| !$search->can($ID, READ)
209209
) {
210-
return false;
210+
return;
211211
}
212212
$canedit = $search->canEdit($ID);
213213

src/SavedSearch_User.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public static function getSpecificValueToDisplay($field, $values, array $options
5656
} else {
5757
return "<span class='fa fa-star bookmark_record'><span class='sr-only'>" . __('No') . "</span></span>";
5858
}
59-
break;
6059
}
6160
return parent::getSpecificValueToDisplay($field, $values, $options);
6261
}

0 commit comments

Comments
 (0)