Skip to content

Commit 26b5860

Browse files
Merge pull request #18089 from kamil-tekiela/first-class-callable
Convert to first class callables
2 parents a8afdb2 + b6f0da1 commit 26b5860

14 files changed

Lines changed: 55 additions & 61 deletions

libraries/classes/Database/Qbe.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,7 @@ private function getFromClause(array $formColumns): string
13821382
// Create cartesian product
13831383
return implode(
13841384
', ',
1385-
array_map([Util::class, 'backquote'], $searchTables)
1385+
array_map(Util::backquote(...), $searchTables)
13861386
);
13871387
}
13881388

@@ -1483,7 +1483,7 @@ private function getJoinForFromClause(array $searchTables, array $searchColumns)
14831483
// Add these tables as cartesian product before joined tables
14841484
$join .= implode(
14851485
', ',
1486-
array_map([Util::class, 'backquote'], $unfinalized)
1486+
array_map(Util::backquote(...), $unfinalized)
14871487
);
14881488
}
14891489
}

libraries/classes/DatabaseInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public function getTablesFull(
376376
if ($table !== [] && $table !== '') {
377377
if (is_array($table)) {
378378
$sqlWhereTable = QueryGenerator::getTableNameConditionForMultiple(
379-
array_map([$this, 'quoteString'], $table)
379+
array_map($this->quoteString(...), $table)
380380
);
381381
} else {
382382
$sqlWhereTable = QueryGenerator::getTableNameCondition(

libraries/classes/ErrorHandler.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ public function __construct()
6868
* rely on PHPUnit doing it's own error handling which we break here.
6969
*/
7070
if (! defined('TESTSUITE')) {
71-
set_exception_handler([$this, 'handleException']);
72-
set_error_handler([$this, 'handleError']);
71+
set_exception_handler($this->handleException(...));
72+
set_error_handler($this->handleError(...));
7373
}
7474

7575
if (! Util::isErrorReportingAvailable()) {
@@ -184,14 +184,16 @@ public function sliceErrors(int $count): array
184184
* @param string $errfile error file
185185
* @param int $errline error line
186186
*
187+
* @return false
188+
*
187189
* @throws ErrorException
188190
*/
189191
public function handleError(
190192
int $errno,
191193
string $errstr,
192194
string $errfile,
193195
int $errline
194-
): void {
196+
): bool {
195197
if (Util::isErrorReportingAvailable()) {
196198
/**
197199
* Check if Error Control Operator (@) was used, but still show
@@ -213,15 +215,17 @@ public function handleError(
213215
$this->errorReporting != 0 &&
214216
($errno & (E_USER_WARNING | E_USER_ERROR | E_USER_NOTICE | E_USER_DEPRECATED)) == 0
215217
) {
216-
return;
218+
return false;
217219
}
218220
} else {
219221
if (($errno & (E_USER_WARNING | E_USER_ERROR | E_USER_NOTICE | E_USER_DEPRECATED)) == 0) {
220-
return;
222+
return false;
221223
}
222224
}
223225

224226
$this->addError($errstr, $errno, $errfile, $errline, true);
227+
228+
return false;
225229
}
226230

227231
/**

libraries/classes/Query/Generator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ public static function getQueryForPartitioningTable(
429429
*/
430430
public static function getAddIndexSql(string $indexType, string $table, array $selectedColumns): string
431431
{
432-
$columnsSql = implode(', ', array_map([Util::class, 'backquote'], $selectedColumns));
432+
$columnsSql = implode(', ', array_map(Util::backquote(...), $selectedColumns));
433433

434434
return 'ALTER TABLE ' . Util::backquote($table) . ' ADD ' . $indexType . '(' . $columnsSql . ');';
435435
}

libraries/classes/SqlQueryForm.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function init($query)
167167
$tmp_db_link .= htmlspecialchars($db) . '</a>';
168168
$legend = sprintf(__('Run SQL query/queries on database %s'), $tmp_db_link);
169169
if (empty($query)) {
170-
$query = Util::expandUserString($GLOBALS['cfg']['DefaultQueryDatabase'], [Util::class, 'backquote']);
170+
$query = Util::expandUserString($GLOBALS['cfg']['DefaultQueryDatabase'], Util::backquote(...));
171171
}
172172
} else {
173173
$db = $GLOBALS['db'];
@@ -182,7 +182,7 @@ public function init($query)
182182
$tmp_tbl_link .= htmlspecialchars($db) . '.' . htmlspecialchars($table) . '</a>';
183183
$legend = sprintf(__('Run SQL query/queries on table %s'), $tmp_tbl_link);
184184
if (empty($query)) {
185-
$query = Util::expandUserString($GLOBALS['cfg']['DefaultQueryTable'], [Util::class, 'backquote']);
185+
$query = Util::expandUserString($GLOBALS['cfg']['DefaultQueryTable'], Util::backquote(...));
186186
}
187187
}
188188

libraries/classes/Twig/AssetExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ final class AssetExtension extends AbstractExtension
1616
public function getFunctions()
1717
{
1818
return [
19-
new TwigFunction('image', [$this, 'getImagePath']),
19+
new TwigFunction('image', $this->getImagePath(...)),
2020
];
2121
}
2222

libraries/classes/Twig/CoreExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function getFilters()
2020
return [
2121
new TwigFilter(
2222
'link',
23-
[Core::class, 'linkURL']
23+
Core::linkURL(...)
2424
),
2525
];
2626
}

libraries/classes/Twig/SanitizeExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function getFilters()
2121
return [
2222
new TwigFilter(
2323
'sanitize',
24-
[Sanitize::class, 'sanitizeMessage'],
24+
Sanitize::sanitizeMessage(...),
2525
['is_safe' => ['html']]
2626
),
2727
];
@@ -37,7 +37,7 @@ public function getFunctions()
3737
return [
3838
new TwigFunction(
3939
'get_js_value',
40-
[Sanitize::class, 'getJsValue'],
40+
Sanitize::getJsValue(...),
4141
['is_safe' => ['html']]
4242
),
4343
];

libraries/classes/Twig/TrackerExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function getFunctions()
2020
return [
2121
new TwigFunction(
2222
'get_tracker_version',
23-
[Tracker::class, 'getVersion']
23+
Tracker::getVersion(...)
2424
),
2525
];
2626
}

libraries/classes/Twig/TransformationsExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ public function getFunctions()
2222
return [
2323
new TwigFunction(
2424
'get_description',
25-
[$transformations, 'getDescription']
25+
$transformations->getDescription(...)
2626
),
2727
new TwigFunction(
2828
'get_name',
29-
[$transformations, 'getName']
29+
$transformations->getName(...)
3030
),
3131
];
3232
}

0 commit comments

Comments
 (0)