Merge pull request #20232 from kamil-tekiela/Small-fixes-2
Small fixes 2
This commit is contained in:
commit
ab773cb61c
@ -4238,6 +4238,8 @@
|
||||
<code><![CDATA[$params]]></code>
|
||||
</InvalidArgument>
|
||||
<MixedAssignment>
|
||||
<code><![CDATA[$_SESSION['debug']]]></code>
|
||||
<code><![CDATA[$subObject]]></code>
|
||||
<code><![CDATA[$subObject]]></code>
|
||||
</MixedAssignment>
|
||||
<MixedReturnTypeCoercion>
|
||||
@ -4264,9 +4266,6 @@
|
||||
<code><![CDATA[$object]]></code>
|
||||
<code><![CDATA[empty($_REQUEST['no_debug'])]]></code>
|
||||
</RiskyTruthyFalsyComparison>
|
||||
<UnusedReturnValue>
|
||||
<code><![CDATA[mixed]]></code>
|
||||
</UnusedReturnValue>
|
||||
</file>
|
||||
<file src="src/Gis/Ds/Polygon.php">
|
||||
<NullArgument>
|
||||
|
||||
@ -252,12 +252,12 @@ class TwigLintCommand extends Command
|
||||
}
|
||||
|
||||
/** @return string[] */
|
||||
private function getContext(string $template, int $line, int $context = 3): array
|
||||
private function getContext(string $template, int $line): array
|
||||
{
|
||||
$lines = explode("\n", $template);
|
||||
|
||||
$position = max(0, $line - $context);
|
||||
$max = min(count($lines), $line - 1 + $context);
|
||||
$position = max(0, $line - 3);
|
||||
$max = min(count($lines), $line - 1 + 3);
|
||||
|
||||
$result = [];
|
||||
while ($position < $max) {
|
||||
|
||||
@ -66,7 +66,7 @@ final readonly class ExportController implements InvocableController
|
||||
/** @var array|null $aliasesParam */
|
||||
$aliasesParam = $request->getParsedBodyParam('aliases');
|
||||
$structureOrDataForced = (bool) $request->getParsedBodyParamAsStringOrNull('structure_or_data_forced');
|
||||
$rememberTemplate = $request->getParsedBodyParamAsString('remember_template', '');
|
||||
$rememberTemplate = $request->hasBodyParam('remember_template');
|
||||
$dbSelect = $request->getParsedBodyParam('db_select');
|
||||
$tableStructure = $request->getParsedBodyParam('table_structure');
|
||||
$lockTables = $request->hasBodyParam('lock_tables');
|
||||
@ -231,7 +231,7 @@ final readonly class ExportController implements InvocableController
|
||||
if (OutputHandler::$asFile) {
|
||||
$filenameTemplate = $request->getParsedBodyParamAsString('filename_template', '');
|
||||
|
||||
if ((bool) $rememberTemplate) {
|
||||
if ($rememberTemplate) {
|
||||
$this->export->rememberFilename($this->userPreferencesHandler, $exportType, $filenameTemplate);
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@ namespace PhpMyAdmin\Controllers\Import;
|
||||
use PhpMyAdmin\Bookmarks\Bookmark;
|
||||
use PhpMyAdmin\Bookmarks\BookmarkRepository;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Controllers\InvocableController;
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\Current;
|
||||
@ -704,8 +703,6 @@ final readonly class ImportController implements InvocableController
|
||||
if (Import::$result) {
|
||||
// Save a Bookmark with more than one queries (if Bookmark label given).
|
||||
if (! empty($request->getParsedBodyParam('bkm_label')) && Import::$importText !== '') {
|
||||
$relation = new Relation($this->dbi);
|
||||
|
||||
$this->sql->storeTheQueryAsBookmark(
|
||||
Current::$database,
|
||||
$this->config->selectedServer['user'],
|
||||
|
||||
@ -37,15 +37,6 @@ final class DatabasesController implements InvocableController
|
||||
/** @var mixed[] array of database details */
|
||||
private array $databases = [];
|
||||
|
||||
/** @var int number of databases */
|
||||
private int $databaseCount = 0;
|
||||
|
||||
/** @var string sort by column */
|
||||
private string $sortBy = '';
|
||||
|
||||
/** @var string sort order of databases */
|
||||
private string $sortOrder = '';
|
||||
|
||||
/** @var bool whether to show database statistics */
|
||||
private bool $hasStatistics = false;
|
||||
|
||||
@ -77,11 +68,11 @@ final class DatabasesController implements InvocableController
|
||||
|
||||
$sortBy = $request->getParam('sort_by', '');
|
||||
Assert::string($sortBy);
|
||||
$this->sortBy = self::SORT_BY_ALLOWED_LIST[array_search($sortBy, self::SORT_BY_ALLOWED_LIST, true)];
|
||||
$sortBy = self::SORT_BY_ALLOWED_LIST[array_search($sortBy, self::SORT_BY_ALLOWED_LIST, true)];
|
||||
|
||||
$sortOrder = $request->getParam('sort_order', '');
|
||||
Assert::string($sortOrder);
|
||||
$this->sortOrder = strtolower($sortOrder) !== 'desc' ? 'asc' : 'desc';
|
||||
$sortOrder = strtolower($sortOrder) !== 'desc' ? 'asc' : 'desc';
|
||||
|
||||
$this->response->addScriptFiles(['server/databases.js']);
|
||||
|
||||
@ -95,6 +86,8 @@ final class DatabasesController implements InvocableController
|
||||
$primaryInfo = $replicationInfo->getPrimaryInfo();
|
||||
$replicaInfo = $replicationInfo->getReplicaInfo();
|
||||
|
||||
$databaseCount = 0;
|
||||
|
||||
/**
|
||||
* Gets the databases list
|
||||
*/
|
||||
@ -104,8 +97,8 @@ final class DatabasesController implements InvocableController
|
||||
null,
|
||||
$this->hasStatistics,
|
||||
ConnectionType::User,
|
||||
$this->sortBy,
|
||||
$this->sortOrder,
|
||||
$sortBy,
|
||||
$sortOrder,
|
||||
$position,
|
||||
true,
|
||||
);
|
||||
@ -122,14 +115,14 @@ final class DatabasesController implements InvocableController
|
||||
return $this->response->response();
|
||||
}
|
||||
|
||||
$this->databaseCount = count($this->dbi->getDatabaseList());
|
||||
$databaseCount = count($this->dbi->getDatabaseList());
|
||||
}
|
||||
|
||||
$urlParams = [
|
||||
'statistics' => $this->hasStatistics,
|
||||
'pos' => $position,
|
||||
'sort_by' => $this->sortBy,
|
||||
'sort_order' => $this->sortOrder,
|
||||
'sort_by' => $sortBy,
|
||||
'sort_order' => $sortOrder,
|
||||
];
|
||||
|
||||
$databases = $this->getDatabases($primaryInfo, $replicaInfo);
|
||||
@ -168,7 +161,7 @@ final class DatabasesController implements InvocableController
|
||||
'total_statistics' => $databases['total_statistics'],
|
||||
'header_statistics' => $headerStatistics,
|
||||
'charsets' => $charsetsList,
|
||||
'database_count' => $this->databaseCount,
|
||||
'database_count' => $databaseCount,
|
||||
'pos' => $position,
|
||||
'url_params' => $urlParams,
|
||||
'max_db_list' => $this->config->config->MaxDbList,
|
||||
|
||||
@ -191,8 +191,8 @@ class Designer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<ColumnInfo>[] $tableColumnsInfo table column info
|
||||
* @param array<string, bool> $tablesAllKeys unique or primary indices
|
||||
* @param array<string, list<ColumnInfo>> $tableColumnsInfo table column info
|
||||
* @param array<string, bool> $tablesAllKeys unique or primary indices
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
|
||||
@ -77,7 +77,7 @@ class Common
|
||||
*
|
||||
* @param DesignerTable[] $designerTables The designer tables
|
||||
*
|
||||
* @return list<ColumnInfo>[] table column nfo
|
||||
* @return array<string, list<ColumnInfo>> table column nfo
|
||||
*/
|
||||
public function getColumnsInfo(array $designerTables): array
|
||||
{
|
||||
|
||||
@ -48,7 +48,7 @@ class Footer
|
||||
*
|
||||
* @return mixed Reference passed object
|
||||
*/
|
||||
private static function removeRecursion(mixed &$object, array $stack = []): mixed
|
||||
private static function removeRecursion(mixed $object, array $stack = []): mixed
|
||||
{
|
||||
if ((is_object($object) || is_array($object)) && $object) {
|
||||
if ($object instanceof Traversable) {
|
||||
@ -57,7 +57,7 @@ class Footer
|
||||
$stack[] = $object;
|
||||
// @phpstan-ignore-next-line
|
||||
foreach ($object as &$subObject) {
|
||||
self::removeRecursion($subObject, $stack);
|
||||
$subObject = self::removeRecursion($subObject, $stack);
|
||||
}
|
||||
} else {
|
||||
$object = '***RECURSION***';
|
||||
@ -74,8 +74,7 @@ class Footer
|
||||
{
|
||||
$retval = '\'false\'';
|
||||
if ($this->config->config->debug->sql && empty($_REQUEST['no_debug']) && ! empty($_SESSION['debug'])) {
|
||||
// Remove recursions and iterators from $_SESSION['debug']
|
||||
self::removeRecursion($_SESSION['debug']);
|
||||
$_SESSION['debug'] = self::removeRecursion($_SESSION['debug']);
|
||||
|
||||
$retval = (string) json_encode($_SESSION['debug']);
|
||||
$_SESSION['debug'] = [];
|
||||
|
||||
@ -12,7 +12,6 @@ use Psr\Http\Server\MiddlewareInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
|
||||
use function assert;
|
||||
use function is_string;
|
||||
|
||||
final class SqlQueryGlobalSetting implements MiddlewareInterface
|
||||
{
|
||||
@ -28,11 +27,7 @@ final class SqlQueryGlobalSetting implements MiddlewareInterface
|
||||
{
|
||||
$sqlQuery = '';
|
||||
if ($request->isPost()) {
|
||||
/** @var mixed $sqlQuery */
|
||||
$sqlQuery = $request->getParsedBodyParam('sql_query');
|
||||
if (! is_string($sqlQuery)) {
|
||||
$sqlQuery = '';
|
||||
}
|
||||
$sqlQuery = $request->getParsedBodyParamAsString('sql_query', '');
|
||||
}
|
||||
|
||||
Current::$sqlQuery = $sqlQuery;
|
||||
|
||||
@ -23,7 +23,6 @@ use PhpMyAdmin\Properties\Plugins\ExportPluginProperties;
|
||||
|
||||
use function __;
|
||||
use function implode;
|
||||
use function in_array;
|
||||
use function is_string;
|
||||
use function preg_replace;
|
||||
use function str_replace;
|
||||
@ -261,10 +260,9 @@ class ExportExcel extends ExportPlugin
|
||||
/** @return 'win'|'mac_excel2003'|'mac_excel2008' */
|
||||
private function setEdition(string $edition): string
|
||||
{
|
||||
if (in_array($edition, ['mac_excel2003', 'mac_excel2008'], true)) {
|
||||
return $edition;
|
||||
}
|
||||
|
||||
return 'win';
|
||||
return match ($edition) {
|
||||
'mac_excel2003', 'mac_excel2008' => $edition,
|
||||
default => 'win',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -2635,21 +2635,19 @@ class ExportSql extends ExportPlugin
|
||||
/** @return 'NONE'|'ANSI'|'DB2'|'MAXDB'|'MYSQL323'|'MYSQL40'|'MSSQL'|'ORACLE'|'TRADITIONAL' */
|
||||
private function setCompatibility(string $mode): string
|
||||
{
|
||||
if (in_array($mode, ['ANSI', 'DB2', 'MAXDB', 'MYSQL323', 'MYSQL40', 'MSSQL', 'ORACLE', 'TRADITIONAL'], true)) {
|
||||
return $mode;
|
||||
}
|
||||
|
||||
return 'NONE';
|
||||
return match ($mode) {
|
||||
'ANSI', 'DB2', 'MAXDB', 'MYSQL323', 'MYSQL40', 'MSSQL', 'ORACLE', 'TRADITIONAL' => $mode,
|
||||
default => 'NONE',
|
||||
};
|
||||
}
|
||||
|
||||
/** @return 'INSERT'|'UPDATE'|'REPLACE' */
|
||||
private function setType(string $type): string
|
||||
{
|
||||
if (in_array($type, ['UPDATE', 'REPLACE'], true)) {
|
||||
return $type;
|
||||
}
|
||||
|
||||
return 'INSERT';
|
||||
return match ($type) {
|
||||
'UPDATE', 'REPLACE' => $type,
|
||||
default => 'INSERT',
|
||||
};
|
||||
}
|
||||
|
||||
public function setAutoIncrement(bool $autoIncrement): void
|
||||
@ -2660,11 +2658,10 @@ class ExportSql extends ExportPlugin
|
||||
/** @return 'complete'|'extended'|'both'|'none' */
|
||||
private function setInsertSyntax(string $syntax): string
|
||||
{
|
||||
if (in_array($syntax, ['complete', 'extended', 'none'], true)) {
|
||||
return $syntax;
|
||||
}
|
||||
|
||||
return 'both';
|
||||
return match ($syntax) {
|
||||
'complete', 'extended', 'none' => $syntax,
|
||||
default => 'both',
|
||||
};
|
||||
}
|
||||
|
||||
/** @return int<0, max> */
|
||||
|
||||
@ -22,6 +22,7 @@ use function __;
|
||||
use function array_key_exists;
|
||||
use function count;
|
||||
use function ksort;
|
||||
use function max;
|
||||
|
||||
/**
|
||||
* Adapted from a LGPL script by Philip Clarke
|
||||
@ -155,7 +156,7 @@ class Pdf extends PdfLib
|
||||
$this->setXY($l, $this->tMargin);
|
||||
$this->MultiCell($this->tablewidths[$col], $this->FontSizePt, $txt ?? 'NULL');
|
||||
$l += $this->tablewidths[$col];
|
||||
$maxY = $maxY < $this->GetY() ? $this->GetY() : $maxY;
|
||||
$maxY = max($maxY, $this->GetY());
|
||||
}
|
||||
|
||||
$this->setXY($this->lMargin, $this->tMargin);
|
||||
|
||||
@ -332,7 +332,7 @@ class Util
|
||||
// use 1024.0 to avoid integer overflow on 64-bit machines
|
||||
$value = round($value / (1024 ** $d / $dh)) / $dh;
|
||||
$unit = $byteUnits[$d];
|
||||
break 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user