Skip to content

Commit

Permalink
Fix MissingClosureParamType errors
Browse files Browse the repository at this point in the history
Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed Apr 28, 2020
1 parent f3237a2 commit cc82f09
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 14 deletions.
34 changes: 34 additions & 0 deletions libraries/classes/Advisor.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public function __construct(DatabaseInterface $dbi, ExpressionLanguage $expressi
'round',
function () {
},
/**
* @param null $arguments
* @param float $num
*/
function ($arguments, $num) {
return round($num);
}
Expand All @@ -70,6 +74,12 @@ function ($arguments, $num) {
'substr',
function () {
},
/**
* @param null $arguments
* @param string $string
* @param int $start
* @param int $length
*/
function ($arguments, $string, $start, $length) {
return substr($string, $start, $length);
}
Expand All @@ -78,6 +88,11 @@ function ($arguments, $string, $start, $length) {
'preg_match',
function () {
},
/**
* @param null $arguments
* @param string $pattern
* @param string $subject
*/
function ($arguments, $pattern, $subject) {
return preg_match($pattern, $subject);
}
Expand All @@ -86,6 +101,11 @@ function ($arguments, $pattern, $subject) {
'ADVISOR_bytime',
function () {
},
/**
* @param null $arguments
* @param float $num
* @param int $precision
*/
function ($arguments, $num, $precision) {
return self::byTime($num, $precision);
}
Expand All @@ -94,6 +114,10 @@ function ($arguments, $num, $precision) {
'ADVISOR_timespanFormat',
function () {
},
/**
* @param null $arguments
* @param string $seconds
*/
function ($arguments, $seconds) {
return self::timespanFormat((int) $seconds);
}
Expand All @@ -102,6 +126,12 @@ function ($arguments, $seconds) {
'ADVISOR_formatByteDown',
function () {
},
/**
* @param null $arguments
* @param int $value
* @param int $limes
* @param int $comma
*/
function ($arguments, $value, $limes = 6, $comma = 0) {
return self::formatByteDown($value, $limes, $comma);
}
Expand All @@ -110,6 +140,10 @@ function ($arguments, $value, $limes = 6, $comma = 0) {
'fired',
function () {
},
/**
* @param null $arguments
* @param int $value
*/
function ($arguments, $value) {
if (! isset($this->runResult['fired'])) {
return 0;
Expand Down
3 changes: 3 additions & 0 deletions libraries/classes/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,9 @@ public static function emptyRecursive($value): bool
if (is_array($value)) {
array_walk_recursive(
$value,
/**
* @param mixed $item
*/
function ($item) use (&$empty) {
$empty = $empty && empty($item);
}
Expand Down
4 changes: 4 additions & 0 deletions libraries/classes/DatabaseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,10 @@ public function getTablesFull(
foreach ($tables as $one_database_name => $one_database_tables) {
uasort(
$one_database_tables,
/**
* @param array $a
* @param array $b
*/
function ($a, $b) {
$aLength = $a['Data_length'] + $a['Index_length'];
$bLength = $b['Data_length'] + $b['Index_length'];
Expand Down
2 changes: 1 addition & 1 deletion libraries/classes/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function getMySQLLocale()
*
* @return int same as strcmp
*/
public function cmp($other)
public function cmp(Language $other): int
{
return strcmp($this->name, $other->name);
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/classes/LanguageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ public function availableLanguages()
public function sortedLanguages()
{
$this->availableLanguages();
uasort($this->_available_languages, function ($a, $b) {
uasort($this->_available_languages, function (Language $a, Language $b) {
return $a->cmp($b);
});
return $this->_available_languages;
Expand Down
19 changes: 13 additions & 6 deletions libraries/classes/Plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,19 @@ public static function getPlugins($plugin_type, $plugins_dir, $plugin_param)
}
}

usort($plugin_list, function ($cmp_name_1, $cmp_name_2) {
return strcasecmp(
$cmp_name_1->getProperties()->getText(),
$cmp_name_2->getProperties()->getText()
);
});
usort(
$plugin_list,
/**
* @param mixed $cmp_name_1
* @param mixed $cmp_name_2
*/
function ($cmp_name_1, $cmp_name_2) {
return strcasecmp(
$cmp_name_1->getProperties()->getText(),
$cmp_name_2->getProperties()->getText()
);
}
);
return $plugin_list;
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/classes/Plugins/Auth/AuthenticationSignon.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function setCookieParams(array $sessionCookieParams = null): void
}

/* Sanitize cookie params */
$defaultCookieParams = function ($key) {
$defaultCookieParams = function (string $key) {
switch ($key) {
case 'lifetime':
return 0;
Expand Down
8 changes: 4 additions & 4 deletions libraries/classes/Sanitize.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ public static function replaceDocLink(array $found)
*
* @return string the sanitized message
*/
public static function sanitizeMessage($message, $escape = false, $safe = false)
public static function sanitizeMessage(string $message, $escape = false, $safe = false)
{
if (! $safe) {
$message = strtr((string) $message, ['<' => '&lt;', '>' => '&gt;']);
$message = strtr($message, ['<' => '&lt;', '>' => '&gt;']);
}

/* Interpret bb code */
Expand Down Expand Up @@ -192,14 +192,14 @@ public static function sanitizeMessage($message, $escape = false, $safe = false)
$pattern = '/\[a@([^]"@]*)(@([^]"]*))?\]/';

/* Find and replace all links */
$message = preg_replace_callback($pattern, function ($match) {
$message = preg_replace_callback($pattern, function (array $match) {
return self::replaceBBLink($match);
}, $message);

/* Replace documentation links */
$message = preg_replace_callback(
'/\[doc@([a-zA-Z0-9_-]+)(@([a-zA-Z0-9_-]*))?\]/',
function ($match) {
function (array $match) {
return self::replaceDocLink($match);
},
$message
Expand Down
1 change: 1 addition & 0 deletions libraries/classes/Server/Privileges.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ public function extractPrivInfo($row = null, $enableHTML = false, $tablePrivs =
) {
// Required for proper escaping of ` (backtick) in a column name
$grant_cols = array_map(
/** @param string $val */
function ($val) {
return Util::backquote($val);
},
Expand Down
1 change: 0 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<MissingClosureReturnType errorLevel="info" />
<MissingPropertyType errorLevel="info" />
<PropertyNotSetInConstructor errorLevel="info" />
<MissingClosureParamType errorLevel="info" />

<MissingConstructor>
<errorLevel type="suppress">
Expand Down

0 comments on commit cc82f09

Please sign in to comment.