Visitar URL original
Merge pull request #18203 from kamil-tekiela/first-class-callable · phpmyadmin/phpmyadmin@802d8f1 · GitHub
Skip to content

Commit 802d8f1

Browse files
Merge pull request #18203 from kamil-tekiela/first-class-callable
Use first class callables
2 parents 24d843c + e71b8c2 commit 802d8f1

9 files changed

Lines changed: 15 additions & 12 deletions

File tree

‎libraries/classes/Config/Validator.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace PhpMyAdmin\Config;
99

1010
use PhpMyAdmin\Core;
11+
use PhpMyAdmin\Sanitize;
1112
use PhpMyAdmin\Util;
1213

1314
use function __;
@@ -183,7 +184,7 @@ public static function validate(
183184
$result[$key] = [];
184185
}
185186

186-
$errorList = array_map('PhpMyAdmin\Sanitize::sanitizeMessage', (array) $errorList);
187+
$errorList = array_map(Sanitize::sanitizeMessage(...), (array) $errorList);
187188
$result[$key] = array_merge($result[$key], $errorList);
188189
}
189190
}

‎libraries/classes/Controllers/Sql/ColumnPreferencesController.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use function array_map;
1717
use function explode;
18+
use function intval;
1819
use function is_string;
1920

2021
final class ColumnPreferencesController extends AbstractController
@@ -41,14 +42,14 @@ public function __invoke(ServerRequest $request): void
4142
// set column order
4243
$colorder = $request->getParsedBodyParam('col_order');
4344
if (is_string($colorder)) {
44-
$propertyValue = array_map('intval', explode(',', $colorder));
45+
$propertyValue = array_map(intval(...), explode(',', $colorder));
4546
$status = $tableObject->setUiProp(Table::PROP_COLUMN_ORDER, $propertyValue, $tableCreateTime);
4647
}
4748

4849
// set column visibility
4950
$colvisib = $request->getParsedBodyParam('col_visib');
5051
if ($status === true && is_string($colvisib)) {
51-
$propertyValue = array_map('intval', explode(',', $colvisib));
52+
$propertyValue = array_map(intval(...), explode(',', $colvisib));
5253
$status = $tableObject->setUiProp(Table::PROP_COLUMN_ORDER, $propertyValue, $tableCreateTime);
5354
}
5455

‎libraries/classes/Controllers/Table/TrackingController.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use function is_array;
3030
use function mb_strlen;
3131
use function sprintf;
32+
use function trim;
3233

3334
final class TrackingController extends AbstractController
3435
{
@@ -118,7 +119,7 @@ public function __invoke(ServerRequest $request): void
118119
/** @var string $users */
119120
$users = $request->getParsedBodyParam('users', '*');
120121

121-
$GLOBALS['filter_users'] = array_map('trim', explode(',', $users));
122+
$GLOBALS['filter_users'] = array_map(trim(...), explode(',', $users));
122123
}
123124

124125
$dateFrom ??= new DateTimeImmutable();

‎libraries/classes/Encoding.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use function mb_detect_encoding;
2020
use function mb_list_encodings;
2121
use function recode_string;
22+
use function strtolower;
2223
use function tempnam;
2324
use function unlink;
2425

@@ -340,7 +341,7 @@ public static function listEncodings(): array
340341
}
341342

342343
return array_intersect(
343-
array_map('strtolower', mb_list_encodings()),
344+
array_map(strtolower(...), mb_list_encodings()),
344345
$GLOBALS['cfg']['AvailableCharsets'],
345346
);
346347
}

‎libraries/classes/Server/Privileges.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,7 @@ public function extractPrivInfo(array|null $row = null, bool $enableHTML = false
233233
) {
234234
// Required for proper escaping of ` (backtick) in a column name
235235
$grantCols = array_map(
236-
/** @param string $val */
237-
static fn ($val): string => Util::backquote($val),
236+
Util::backquote(...),
238237
$GLOBALS[$currentGrant[0]],
239238
);
240239

‎libraries/classes/Table.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
use function htmlspecialchars;
3737
use function implode;
3838
use function in_array;
39+
use function intval;
3940
use function is_array;
4041
use function is_numeric;
4142
use function is_string;
@@ -1836,7 +1837,7 @@ public function getUiProp(string $property): mixed
18361837

18371838
// check if the table has not been modified
18381839
if ($this->getStatusInfo('Create_time') == $this->uiprefs['CREATE_TIME']) {
1839-
return array_map('intval', $this->uiprefs[$property]);
1840+
return array_map(intval(...), $this->uiprefs[$property]);
18401841
}
18411842

18421843
// remove the property, since the table has been modified

‎libraries/classes/Util.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2370,7 +2370,7 @@ public static function isErrorReportingAvailable(): bool
23702370
$disabled = ini_get('disable_functions');
23712371
if (is_string($disabled)) {
23722372
$disabled = explode(',', $disabled);
2373-
$disabled = array_map(static fn (string $part) => trim($part), $disabled);
2373+
$disabled = array_map(trim(...), $disabled);
23742374

23752375
return ! in_array('error_reporting', $disabled);
23762376
}

‎libraries/classes/Utils/Gis.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use function array_map;
88
use function bin2hex;
99
use function mb_strtolower;
10+
use function mb_strtoupper;
1011
use function preg_match;
1112
use function trim;
1213

@@ -78,7 +79,7 @@ public static function getDataTypes(bool $upperCase = false): array
7879
'geometrycollection',
7980
];
8081
if ($upperCase) {
81-
return array_map('mb_strtoupper', $gisDataTypes);
82+
return array_map(mb_strtoupper(...), $gisDataTypes);
8283
}
8384

8485
return $gisDataTypes;

‎psalm-baseline.xml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,6 @@
668668
<code>$uv[$i]</code>
669669
<code>$values[$path]</code>
670670
<code>$vid</code>
671-
<code>(array) $errorList</code>
672671
<code><![CDATA[empty($values['Servers/1/controlpass']) ? '' : $values['Servers/1/controlpass']]]></code>
673672
<code><![CDATA[empty($values['Servers/1/controluser']) ? '' : $values['Servers/1/controluser']]]></code>
674673
<code><![CDATA[empty($values['Servers/1/host']) ? '' : $values['Servers/1/host']]]></code>
@@ -13217,7 +13216,6 @@
1321713216
<code><![CDATA[$row['Field']]]></code>
1321813217
<code><![CDATA[$row['Type']]]></code>
1321913218
<code><![CDATA[$row['Type']]]></code>
13220-
<code><![CDATA[$this->uiprefs[$property]]]></code>
1322113219
<code><![CDATA[$trigger['create']]]></code>
1322213220
<code><![CDATA[$trigger['name']]]></code>
1322313221
</MixedArrayAccess>

0 commit comments

Comments
 (0)