Skip to content

Commit

Permalink
Fix some typos (#18271)
Browse files Browse the repository at this point in the history
* Fix some typos

* Apply suggestions from code review

Co-authored-by: Curtis Conard <[email protected]>

* Not a typo

* CS

---------

Co-authored-by: Curtis Conard <[email protected]>
  • Loading branch information
trasher and cconard96 authored Nov 8, 2024
1 parent df8ff03 commit 99ad801
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 73 deletions.
24 changes: 0 additions & 24 deletions .phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -2587,18 +2587,6 @@
'count' => 2,
'path' => __DIR__ . '/src/Glpi/Search/Input/QueryBuilder.php',
];
$ignoreErrors[] = [
// identifier: parameter.notFound
'message' => '#^PHPDoc tag @param references unknown parameter\\: \\$field$#',
'count' => 1,
'path' => __DIR__ . '/src/Glpi/Search/Input/QueryBuilder.php',
];
$ignoreErrors[] = [
// identifier: parameter.notFound
'message' => '#^PHPDoc tag @param references unknown parameter\\: \\$table$#',
'count' => 1,
'path' => __DIR__ . '/src/Glpi/Search/Input/QueryBuilder.php',
];
$ignoreErrors[] = [
// identifier: method.notFound
'message' => '#^Call to an undefined method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\IWriter\\:\\:setOrientation\\(\\)\\.$#',
Expand Down Expand Up @@ -2761,18 +2749,6 @@
'count' => 1,
'path' => __DIR__ . '/src/Glpi/Search/SearchEngine.php',
];
$ignoreErrors[] = [
// identifier: parameter.notFound
'message' => '#^PHPDoc tag @param references unknown parameter\\: \\$digits$#',
'count' => 1,
'path' => __DIR__ . '/src/Glpi/Security/TOTPManager.php',
];
$ignoreErrors[] = [
// identifier: parameter.notFound
'message' => '#^PHPDoc tag @param references unknown parameter\\: \\$period$#',
'count' => 1,
'path' => __DIR__ . '/src/Glpi/Security/TOTPManager.php',
];
$ignoreErrors[] = [
// identifier: return.void
'message' => '#^Method Glpi\\\\Socket\\:\\:showListForItem\\(\\) with return type void returns false but should not return anything\\.$#',
Expand Down
2 changes: 1 addition & 1 deletion src/Glpi/Search/CriteriaFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
$nb = 0;
if (($filter = self::getForItem($item))) {
// important: array_walk_recursive iterates only over non-array values
// so we need to count only when we we found the 'field' key
// so we need to count only when we found the 'field' key
array_walk_recursive($filter->fields['search_criteria'], function ($value, $key) use (&$nb) {
if ($key === 'field') {
$nb++;
Expand Down
2 changes: 1 addition & 1 deletion src/Glpi/Search/FilterableInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function itemMatchFilter(CommonDBTM $item): bool;
/**
* Create or update filter for the current item
*
* @param array $search_criteria Search criterias used as filter
* @param array $search_criteria Search criteria used as filter
*
* @return bool
*/
Expand Down
5 changes: 2 additions & 3 deletions src/Glpi/Search/Input/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ public static function displaySortCriteria(array $request = []): void

/**
* Display a group of nested criteria.
* A group (parent) criteria can contains children criteria (who also cantains children, etc)
* A group (parent) criteria can contain children criteria (who also contain children, etc)
*
* @since 9.4
*
Expand Down Expand Up @@ -940,8 +940,7 @@ private static function findCriteriaInSession($itemtype = '', $num = 0, $parents
/**
* Get the input value validation pattern for given datatype.
*
* @param string $table
* @param string $field
* @param string $datatype
* @param bool $with_delimiters
* True to return a complete pattern, including delimiters.
* False to return a pattern without delimiters, that can be used inside another regex or in a HTML input pattern.
Expand Down
6 changes: 3 additions & 3 deletions src/Glpi/Search/Output/HTMLSearchOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function displayData(array $data, array $params = [])
}
}

// Contruct parameters
// Construct parameters
$globallinkto = \Toolbox::append_params([
'criteria' => $search['criteria'],
'metacriteria' => $search['metacriteria'],
Expand Down Expand Up @@ -156,12 +156,12 @@ public function displayData(array $data, array $params = [])
$used_soptions_names[] = _n('View', 'Views', 1);
}

// check also if there any default filters
// check also if there is any default filters
if ($defaultfilter = \DefaultFilter::getSearchCriteria($itemtype)) {
array_unshift($used_soptions_names, $defaultfilter['name']);
}

// remove latitute and longitude if as map is enabled
// remove latitude and longitude if as map is enabled
$as_map = $data['search']['as_map'] ?? 0;
if ($as_map == 1) {
unset($used_soptions_names[array_search(__('Latitude'), $used_soptions_names)]);
Expand Down
10 changes: 5 additions & 5 deletions src/Glpi/Search/Provider/SQLProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4595,7 +4595,7 @@ public static function constructData(array &$data, $onlycount = false)

if ($onlycount) {
Profiler::getInstance()->stop('SQLProvider::constructData');
//we just want to coutn results; no need to continue process
//we just want to count results; no need to continue process
return;
}

Expand Down Expand Up @@ -4875,7 +4875,7 @@ public static function constructData(array &$data, $onlycount = false)
/**
* Create SQL search condition
*
* @param string $field Nname (should be ` protected)
* @param string $field Name (should be ` protected)
* @param string $val Value to search
* @param boolean $not Is a negative search ? (false by default)
* @param string $link With previous criteria (default 'AND')
Expand Down Expand Up @@ -4961,7 +4961,7 @@ public static function makeTextSearchValue($val)
// Remove leading `^`
$val = ltrim(preg_replace('/^\^/', '', $val));
} else {
// Add % wildcard before searched string if not begining by a `^`
// Add % wildcard before searched string if not beginning by a `^`
$val = '%' . $val;
}

Expand Down Expand Up @@ -5038,7 +5038,7 @@ public static function giveItem(
$oparams = $searchopt[$ID]['addobjectparams'];
}

// Search option may not exists in subtype
// Search option may not exist in subtype
// This is the case for "Inventory number" for a Software listed from ReservationItem search
$subtype_so = SearchOption::getOptionsForItemtype($data["TYPE"]);
if (!array_key_exists($ID, $subtype_so)) {
Expand Down Expand Up @@ -5349,7 +5349,7 @@ public static function giveItem(
? $data[$ID][$k]['name']
: $data[$ID][$k]['tickets_id_2'];

// If link ID is int or integer string, force conversion to int. Coversion to int and then string to compare is needed to ensure it isn't a decimal
// If link ID is int or integer string, force conversion to int. Conversion to int and then string to compare is needed to ensure it isn't a decimal
if (is_numeric($linkid) && ((string)(int)$linkid === (string)$linkid)) {
$linkid = (int) $linkid;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Glpi/Search/SearchEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public static function getMetaItemtypeAvailable($itemtype): array
$linked = [];
foreach ($CFG_GLPI as $key => $values) {
if ($key === 'link_types') {
// Links are associated to all items of a type, it does not make any sense to use them in meta search
// Links are associated to all items of a type, it does not make any sense to use them in metasearch
continue;
}
if ($key === 'ticket_types' && $item instanceof \CommonITILObject) {
Expand Down Expand Up @@ -273,7 +273,7 @@ public static function getMetaReferenceItemtype($itemtype)
* @param string $itemtype Item type
* @param array $params Array of parameters
* may include sort, order, start, list_limit, deleted, criteria, metacriteria
* @param array $forcedisplay Array of columns to display (default empty = empty use display pref and search criterias)
* @param array $forcedisplay Array of columns to display (default empty = empty use display pref and search criteria)
*
* @return array prepare to be used for a search (include criteria and others needed information)
**/
Expand Down Expand Up @@ -404,7 +404,7 @@ public static function prepareDataForSearch($itemtype, array $params, array $for
}
$data['meta_toview'] = [];
if (!$forcetoview) {
// Add items to display depending of personal prefs
// Add items to display depending on personal prefs
$displaypref = \DisplayPreference::getForTypeUser($itemtype, \Session::getLoginUserID(), \Session::getCurrentInterface());
if (count($displaypref)) {
foreach ($displaypref as $val) {
Expand Down Expand Up @@ -649,7 +649,7 @@ public static function getData(string $itemtype, array $params, array $forced_di
/**
* @param string $itemtype The itemtype being displayed
* @param array $params The search parameters
* @param array $forced_display Array of columns to display (default empty = empty use display pref and search criterias)
* @param array $forced_display Array of columns to display (default empty = empty use display pref and search criteria)
* @return void
*/
public static function showOutput(string $itemtype, array $params, array $forced_display = []): void
Expand Down
4 changes: 2 additions & 2 deletions src/Glpi/Search/SearchOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ public static function getOptionNumber($itemtype, $field, $meta_itemtype = null)
* Clean search options depending on the user active profile
*
* @param class-string<\CommonDBTM> $itemtype Item type to manage
* @param integer $action Action which is used to manupulate searchoption
* @param integer $action Action which is used to manipulate searchoption
* (default READ)
* @param boolean $withplugins Get plugins options (true by default)
*
Expand Down Expand Up @@ -765,7 +765,7 @@ public static function getDefaultToView(string $itemtype, array $params): array
* plugin name is provided.
*
* @param string $string_identifier
* @param string $plugin
* @param ?string $plugin
* @return int
*/
public static function generateAProbablyUniqueId(string $string_identifier, ?string $plugin = null): int
Expand Down
12 changes: 5 additions & 7 deletions src/Glpi/Security/TOTPManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,9 @@ final class TOTPManager

/**
* Get an instance of the TwoFactorAuth class
* @param int $digits Number of digits in the TOTP code
* @param int $period Number of seconds the TOTP code is valid for.
* @param string $algorithm Algorithm used to generate the TOTP code.
* @return TwoFactorAuth
* @throws \RobThree\Auth\TwoFactorAuthException
* @throws TwoFactorAuthException
*/
private function getTwoFactorAuth(string $algorithm = 'sha1'): TwoFactorAuth
{
Expand All @@ -125,7 +123,7 @@ private function getTwoFactorAuth(string $algorithm = 'sha1'): TwoFactorAuth
/**
* Generate a new TOTP secret code
* @return string The secret code
* @throws \RobThree\Auth\TwoFactorAuthException
* @throws TwoFactorAuthException
*/
public function createSecret(): string
{
Expand Down Expand Up @@ -235,7 +233,7 @@ public function is2FAEnabled(int $users_id): bool
* @param int $users_id ID of the user
* @return bool True if the code is valid, false otherwise
* @throws \JsonException
* @throws \RobThree\Auth\TwoFactorAuthException
* @throws TwoFactorAuthException
*/
public function verifyCodeForUser(string $code, int $users_id): bool
{
Expand All @@ -251,7 +249,7 @@ public function verifyCodeForUser(string $code, int $users_id): bool
* @param string $code The code to verify
* @param string $secret The secret to use
* @return string|false The algorithm matched if the code is valid, false otherwise
* @throws \RobThree\Auth\TwoFactorAuthException
* @throws TwoFactorAuthException
*/
public function verifyCodeForSecret(string $code, string $secret): string|false
{
Expand Down Expand Up @@ -481,7 +479,7 @@ public function showTOTPPrompt(int $users_id): void
* Show a form to set up TOTP for the current user or manage the settings if it is set up already.
* @param int $users_id ID of the user
* @param bool $force_setup Force the setup form to be shown even if 2FA is already enabled
* @param bool $regenerate_backup_codes Regenerate backup codes immedately when showing the status form
* @param bool $regenerate_backup_codes Regenerate backup codes immediately when showing the status form
* @return void
* @throws \JsonException
* @throws TwoFactorAuthException
Expand Down
6 changes: 3 additions & 3 deletions src/Glpi/System/Diagnostic/DatabaseKeysChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function getUselessKeys(string $table_name): array
continue; // This is not another key.
}
if (count($checked_fields) >= count($other_fields)) {
continue; // Other key does not contains more that expected fields, it is not a larger key.
continue; // Other key does not contain more that expected fields, it is not a larger key.
}

foreach ($checked_fields as $i => $checked_field) {
Expand Down Expand Up @@ -199,7 +199,7 @@ private function areFieldsCorrecltyIndexed(string $table_name, array $fields, st
{
$index = $this->getIndex($table_name);

// Check if primary key matches matches given fields.
// Check if primary key matches given fields.
if (array_key_exists('PRIMARY', $index) && $index['PRIMARY'] === $fields) {
return true;
}
Expand All @@ -217,7 +217,7 @@ private function areFieldsCorrecltyIndexed(string $table_name, array $fields, st
// Check if a larger key exists and contains given fields.
foreach ($index as $key_fields) {
if (count($fields) >= count($key_fields)) {
continue; // Key does not contains more that expected fields, it is not a larger key.
continue; // Key does not contain more that expected fields, it is not a larger key.
}
foreach ($fields as $i => $field) {
if (!array_key_exists($i, $key_fields) || $key_fields[$i] !== $field) {
Expand Down
18 changes: 9 additions & 9 deletions src/Glpi/System/Diagnostic/DatabaseSchemaIntegrityChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public function extractSchemaFromFile(string $schema_path): array
* Check if there is differences between effective schema and schema contained in given file.
*
* @param string $schema_path The absolute path to the schema file
* @param bool $include_unknown_tables Indicates whether unknown existing tables should be include in results
* @param bool $include_unknown_tables Indicates whether unknown existing tables should be included in results
* @param string $context Context used for unknown tables identification (could be 'core' or 'plugin:plugin_key')
*
* @return array List of tables that differs from the expected schema.
Expand Down Expand Up @@ -326,7 +326,7 @@ public function checkCompleteSchema(
* Check if there is differences between effective schema and expected schema for given version/context.
*
* @param string|null $schema_version Installed schema version
* @param bool $include_unknown_tables Indicates whether unknown existing tables should be include in results
* @param bool $include_unknown_tables Indicates whether unknown existing tables should be included in results
* @param string $context Context used for unknown tables identification (could be 'core' or 'plugin:plugin_key')
*
* @return array List of tables that differs from the expected schema.
Expand Down Expand Up @@ -499,10 +499,10 @@ function ($matches) {
&& $dbversion !== null
&& version_compare(VersionParser::getNormalizedVersion($dbversion), '10.0', '<')
) {
// Before GLPI 10.0.0, COLLATE property was not explicitely defined for glpi_notimportedemails,
// Before GLPI 10.0.0, COLLATE property was not explicitly defined for glpi_notimportedemails,
// and charset was not the same as other tables.
// If installed schema is < 10.0.0, we exclude CHARACTER SET and COLLATE properties from
// diff as we cannot easilly predict effective values (COLLATE will depend on server configuration)
// diff as we cannot easily predict effective values (COLLATE will depend on server configuration)
// and, anyway, it will be fixed during GLPI 10.0.0 migration.
$column_replacements['/( CHARACTER SET \w+)? COLLATE \w+/i'] = '';
}
Expand Down Expand Up @@ -537,7 +537,7 @@ function ($matches) {
// MariaDB in some recent version (at least 10.11.7) seems to mention it on some indexes, but we do not know why.
'/(`\w+`)\(250\)/' => '$1',
// Mysql and MariaDB does not always have the same default value for index type depending on the index
// for example, the create query might return "UNIQUE KEY `unicity` USING HASH (`users_id`)" one one side
// for example, the create query might return "UNIQUE KEY `unicity` USING HASH (`users_id`)" one side
// and "UNIQUE KEY `unicity` (`users_id`)" on the other side, despite being the same index.
'/(UNIQUE KEY|FULLTEXT KEY|KEY) (.*) USING (\w+)/i' => '$1 $2',
];
Expand Down Expand Up @@ -575,7 +575,7 @@ function (string $a, string $b) {
unset($properties['ROW_FORMAT']);
}
if (!$this->strict && ($properties['ROW_FORMAT'] ?? '') === 'DYNAMIC') {
// MySQL 5.7+ and MariaDB 10.2+ does not ouput ROW_FORMAT when ROW_FORMAT has not been specified in creation query
// MySQL 5.7+ and MariaDB 10.2+ does not output ROW_FORMAT when ROW_FORMAT has not been specified in creation query
// and so uses default value.
// Drop it if value is 'DYNAMIC' as we assume this is the default value.
unset($properties['ROW_FORMAT']);
Expand Down Expand Up @@ -604,10 +604,10 @@ function (string $a, string $b) {
&& $dbversion !== null
&& version_compare(VersionParser::getNormalizedVersion($dbversion), '10.0', '<')
) {
// Before GLPI 10.0.0, COLLATE property was not explicitely defined for glpi_notimportedemails,
// Before GLPI 10.0.0, COLLATE property was not explicitly defined for glpi_notimportedemails,
// and charset was not the same as other tables.
// If installed schema is < 10.0.0, we exclude DEFAULT CHARSET and COLLATE properties from
// diff as we cannot easilly predict effective values (COLLATE will depend on server configuration)
// diff as we cannot easily predict effective values (COLLATE will depend on server configuration)
// and, anyway, it will be fixed during GLPI 10.0.0 migration.
unset($properties['DEFAULT CHARSET']);
unset($properties['COLLATE']);
Expand Down Expand Up @@ -793,7 +793,7 @@ final public function canCheckIntegrity(?string $schema_version = null, string $
$is_latest_version = $schema_version === GLPI_SCHEMA_VERSION;

if (!$is_stable_version && !$is_latest_version) {
// Cannot check integrity if version is not stable, unless installed version is latest one.
// Cannot check integrity if version is not stable, unless installed version is the latest one.
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Glpi/System/Requirement/InstallationNotOverriden.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected function check()

if ($version_files_count == 0) {
// Cannot do the check.
// Indicating that `version` directory is missing would be useless, as it would probably incitate administrator
// Indicating that `version` directory is missing would be useless, as it would probably encourage administrator
// to restore it, and it would result in a "false positive" type validation.
$this->out_of_context = true;
return;
Expand Down
Loading

0 comments on commit 99ad801

Please sign in to comment.