Merge pull request #18084 from kamil-tekiela/union-types
Add union types
This commit is contained in:
commit
4ab4348fee
@ -146,7 +146,7 @@ class Advisor
|
||||
* @param string|int $variable Variable to set
|
||||
* @param mixed $value Value to set
|
||||
*/
|
||||
public function setVariable($variable, $value): void
|
||||
public function setVariable(string|int $variable, $value): void
|
||||
{
|
||||
$this->variables[$variable] = $value;
|
||||
}
|
||||
|
||||
@ -193,11 +193,12 @@ class Bookmark
|
||||
*
|
||||
* @param array $bkm_fields the properties of the bookmark to add; here, $bkm_fields['bkm_sql_query'] is urlencoded
|
||||
* @param bool $all_users whether to make the bookmark available for all users
|
||||
*
|
||||
* @return Bookmark|false
|
||||
*/
|
||||
public static function createBookmark(DatabaseInterface $dbi, array $bkm_fields, bool $all_users = false)
|
||||
{
|
||||
public static function createBookmark(
|
||||
DatabaseInterface $dbi,
|
||||
array $bkm_fields,
|
||||
bool $all_users = false
|
||||
): Bookmark|false {
|
||||
if (
|
||||
! (isset($bkm_fields['bkm_sql_query'], $bkm_fields['bkm_label'])
|
||||
&& strlen($bkm_fields['bkm_sql_query']) > 0
|
||||
@ -243,7 +244,7 @@ class Bookmark
|
||||
BookmarkFeature $bookmarkFeature,
|
||||
DatabaseInterface $dbi,
|
||||
string $user,
|
||||
$db = false
|
||||
string|false $db = false
|
||||
): array {
|
||||
$query = 'SELECT * FROM ' . Util::backquote($bookmarkFeature->database)
|
||||
. '.' . Util::backquote($bookmarkFeature->bookmark)
|
||||
@ -288,7 +289,7 @@ class Bookmark
|
||||
DatabaseInterface $dbi,
|
||||
string $user,
|
||||
DatabaseName $db,
|
||||
$id,
|
||||
int|string $id,
|
||||
string $id_field = 'id',
|
||||
bool $action_bookmark_all = false,
|
||||
bool $exact_user_match = false
|
||||
|
||||
@ -139,7 +139,7 @@ class FormDisplayTemplate
|
||||
* @param string|array $validators validators callback
|
||||
* @param array $jsArray will be updated with javascript code
|
||||
*/
|
||||
public function addJsValidate($fieldId, $validators, array &$jsArray): void
|
||||
public function addJsValidate($fieldId, string|array $validators, array &$jsArray): void
|
||||
{
|
||||
foreach ((array) $validators as $validator) {
|
||||
$validator = (array) $validator;
|
||||
|
||||
@ -1894,10 +1894,9 @@ final class Settings
|
||||
/**
|
||||
* @param array<int|string, mixed> $settings
|
||||
*
|
||||
* @return bool|string
|
||||
* @psalm-return bool|'sameorigin'
|
||||
*/
|
||||
private function setAllowThirdPartyFraming(array $settings)
|
||||
private function setAllowThirdPartyFraming(array $settings): bool|string
|
||||
{
|
||||
if (! isset($settings['AllowThirdPartyFraming'])) {
|
||||
return false;
|
||||
@ -2086,10 +2085,9 @@ final class Settings
|
||||
/**
|
||||
* @param array<int|string, mixed> $settings
|
||||
*
|
||||
* @return bool|string
|
||||
* @psalm-return 'auto'|bool
|
||||
*/
|
||||
private function setOBGzip(array $settings)
|
||||
private function setOBGzip(array $settings): bool|string
|
||||
{
|
||||
if (! isset($settings['OBGzip']) || $settings['OBGzip'] === 'auto') {
|
||||
return 'auto';
|
||||
@ -2585,7 +2583,7 @@ final class Settings
|
||||
*
|
||||
* @return false|string|string[]
|
||||
*/
|
||||
private function setNavigationTreeTableSeparator(array $settings)
|
||||
private function setNavigationTreeTableSeparator(array $settings): false|string|array
|
||||
{
|
||||
if (! isset($settings['NavigationTreeTableSeparator'])) {
|
||||
return '__';
|
||||
@ -3153,10 +3151,9 @@ final class Settings
|
||||
/**
|
||||
* @param array<int|string, mixed> $settings
|
||||
*
|
||||
* @return false|string
|
||||
* @psalm-return 'blob'|'noblob'|'all'|false
|
||||
*/
|
||||
private function setProtectBinary(array $settings)
|
||||
private function setProtectBinary(array $settings): false|string
|
||||
{
|
||||
if (
|
||||
! isset($settings['ProtectBinary'])
|
||||
|
||||
@ -427,10 +427,9 @@ final class Import
|
||||
/**
|
||||
* @param array<int|string, mixed> $import
|
||||
*
|
||||
* @return bool|string
|
||||
* @psalm-return 'auto'|bool
|
||||
*/
|
||||
private function setLdiLocalOption(array $import)
|
||||
private function setLdiLocalOption(array $import): bool|string
|
||||
{
|
||||
if (! isset($import['ldi_local_option']) || $import['ldi_local_option'] === 'auto') {
|
||||
return 'auto';
|
||||
|
||||
@ -915,7 +915,7 @@ final class Server
|
||||
*
|
||||
* @return string|string[]
|
||||
*/
|
||||
private function setOnlyDb(array $server)
|
||||
private function setOnlyDb(array $server): string|array
|
||||
{
|
||||
$onlyDb = '';
|
||||
if (isset($server['only_db'])) {
|
||||
@ -971,10 +971,8 @@ final class Server
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $server
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
private function setBookmarktable(array $server)
|
||||
private function setBookmarktable(array $server): false|string
|
||||
{
|
||||
if (isset($server['bookmarktable'])) {
|
||||
return $server['bookmarktable'] === false ? false : (string) $server['bookmarktable'];
|
||||
@ -985,10 +983,8 @@ final class Server
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $server
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
private function setRelation(array $server)
|
||||
private function setRelation(array $server): false|string
|
||||
{
|
||||
if (isset($server['relation'])) {
|
||||
return $server['relation'] === false ? false : (string) $server['relation'];
|
||||
@ -999,10 +995,8 @@ final class Server
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $server
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
private function setTableInfo(array $server)
|
||||
private function setTableInfo(array $server): false|string
|
||||
{
|
||||
if (isset($server['table_info'])) {
|
||||
return $server['table_info'] === false ? false : (string) $server['table_info'];
|
||||
@ -1013,10 +1007,8 @@ final class Server
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $server
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
private function setTableCoords(array $server)
|
||||
private function setTableCoords(array $server): false|string
|
||||
{
|
||||
if (isset($server['table_coords'])) {
|
||||
return $server['table_coords'] === false ? false : (string) $server['table_coords'];
|
||||
@ -1027,10 +1019,8 @@ final class Server
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $server
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
private function setPdfPages(array $server)
|
||||
private function setPdfPages(array $server): false|string
|
||||
{
|
||||
if (isset($server['pdf_pages'])) {
|
||||
return $server['pdf_pages'] === false ? false : (string) $server['pdf_pages'];
|
||||
@ -1041,10 +1031,8 @@ final class Server
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $server
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
private function setColumnInfo(array $server)
|
||||
private function setColumnInfo(array $server): false|string
|
||||
{
|
||||
if (isset($server['column_info'])) {
|
||||
return $server['column_info'] === false ? false : (string) $server['column_info'];
|
||||
@ -1055,10 +1043,8 @@ final class Server
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $server
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
private function setHistory(array $server)
|
||||
private function setHistory(array $server): false|string
|
||||
{
|
||||
if (isset($server['history'])) {
|
||||
return $server['history'] === false ? false : (string) $server['history'];
|
||||
@ -1069,10 +1055,8 @@ final class Server
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $server
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
private function setRecent(array $server)
|
||||
private function setRecent(array $server): false|string
|
||||
{
|
||||
if (isset($server['recent'])) {
|
||||
return $server['recent'] === false ? false : (string) $server['recent'];
|
||||
@ -1083,10 +1067,8 @@ final class Server
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $server
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
private function setFavorite(array $server)
|
||||
private function setFavorite(array $server): false|string
|
||||
{
|
||||
if (isset($server['favorite'])) {
|
||||
return $server['favorite'] === false ? false : (string) $server['favorite'];
|
||||
@ -1097,10 +1079,8 @@ final class Server
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $server
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
private function setTableUiprefs(array $server)
|
||||
private function setTableUiprefs(array $server): false|string
|
||||
{
|
||||
if (isset($server['table_uiprefs'])) {
|
||||
return $server['table_uiprefs'] === false ? false : (string) $server['table_uiprefs'];
|
||||
@ -1111,10 +1091,8 @@ final class Server
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $server
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
private function setTracking(array $server)
|
||||
private function setTracking(array $server): false|string
|
||||
{
|
||||
if (isset($server['tracking'])) {
|
||||
return $server['tracking'] === false ? false : (string) $server['tracking'];
|
||||
@ -1125,10 +1103,8 @@ final class Server
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $server
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
private function setUserconfig(array $server)
|
||||
private function setUserconfig(array $server): false|string
|
||||
{
|
||||
if (isset($server['userconfig'])) {
|
||||
return $server['userconfig'] === false ? false : (string) $server['userconfig'];
|
||||
@ -1139,10 +1115,8 @@ final class Server
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $server
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
private function setUsers(array $server)
|
||||
private function setUsers(array $server): false|string
|
||||
{
|
||||
if (isset($server['users'])) {
|
||||
return $server['users'] === false ? false : (string) $server['users'];
|
||||
@ -1153,10 +1127,8 @@ final class Server
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $server
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
private function setUsergroups(array $server)
|
||||
private function setUsergroups(array $server): false|string
|
||||
{
|
||||
if (isset($server['usergroups'])) {
|
||||
return $server['usergroups'] === false ? false : (string) $server['usergroups'];
|
||||
@ -1167,10 +1139,8 @@ final class Server
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $server
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
private function setNavigationhiding(array $server)
|
||||
private function setNavigationhiding(array $server): false|string
|
||||
{
|
||||
if (isset($server['navigationhiding'])) {
|
||||
return $server['navigationhiding'] === false
|
||||
@ -1183,10 +1153,8 @@ final class Server
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $server
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
private function setSavedsearches(array $server)
|
||||
private function setSavedsearches(array $server): false|string
|
||||
{
|
||||
if (isset($server['savedsearches'])) {
|
||||
return $server['savedsearches'] === false ? false : (string) $server['savedsearches'];
|
||||
@ -1197,10 +1165,8 @@ final class Server
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $server
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
private function setCentralColumns(array $server)
|
||||
private function setCentralColumns(array $server): false|string
|
||||
{
|
||||
if (isset($server['central_columns'])) {
|
||||
return $server['central_columns'] === false ? false : (string) $server['central_columns'];
|
||||
@ -1211,10 +1177,8 @@ final class Server
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $server
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
private function setDesignerSettings(array $server)
|
||||
private function setDesignerSettings(array $server): false|string
|
||||
{
|
||||
if (isset($server['designer_settings'])) {
|
||||
return $server['designer_settings'] === false
|
||||
@ -1227,10 +1191,8 @@ final class Server
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $server
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
private function setExportTemplates(array $server)
|
||||
private function setExportTemplates(array $server): false|string
|
||||
{
|
||||
if (isset($server['export_templates'])) {
|
||||
return $server['export_templates'] === false
|
||||
|
||||
@ -120,15 +120,13 @@ class Validator
|
||||
* @param array $values Values to validate
|
||||
* @param bool $isPostSource tells whether $values are directly from
|
||||
* POST request
|
||||
*
|
||||
* @return bool|array
|
||||
*/
|
||||
public static function validate(
|
||||
ConfigFile $cf,
|
||||
$validatorId,
|
||||
string|array $validatorId,
|
||||
array $values,
|
||||
$isPostSource
|
||||
) {
|
||||
): bool|array {
|
||||
// find validators
|
||||
$validatorId = (array) $validatorId;
|
||||
$validators = static::getValidators($cf);
|
||||
@ -210,8 +208,6 @@ class Validator
|
||||
* @param string $user username to use
|
||||
* @param string $pass password to use
|
||||
* @param string $errorKey key to use in return array
|
||||
*
|
||||
* @return bool|array
|
||||
*/
|
||||
public static function testDBConnection(
|
||||
$host,
|
||||
@ -220,7 +216,7 @@ class Validator
|
||||
$user,
|
||||
$pass = null,
|
||||
$errorKey = 'Server'
|
||||
) {
|
||||
): bool|array {
|
||||
if ($GLOBALS['cfg']['DBG']['demo']) {
|
||||
// Connection test disabled on the demo server!
|
||||
return true;
|
||||
@ -576,10 +572,8 @@ class Validator
|
||||
* @param string $path path to config
|
||||
* @param array $values config values
|
||||
* @param string $regex regular expression to match
|
||||
*
|
||||
* @return array|string
|
||||
*/
|
||||
public static function validateByRegex($path, array $values, $regex)
|
||||
public static function validateByRegex($path, array $values, $regex): array|string
|
||||
{
|
||||
if (! isset($values[$path])) {
|
||||
return '';
|
||||
|
||||
@ -489,7 +489,7 @@ class Relation
|
||||
*
|
||||
* @return string|false field name or false
|
||||
*/
|
||||
public function getDisplayField($db, $table)
|
||||
public function getDisplayField($db, $table): string|false
|
||||
{
|
||||
$displayFeature = $this->getRelationParameters()->displayFeature;
|
||||
|
||||
@ -723,7 +723,7 @@ class Relation
|
||||
*
|
||||
* @return array|bool list of history items
|
||||
*/
|
||||
public function getHistory($username)
|
||||
public function getHistory($username): array|bool
|
||||
{
|
||||
$sqlHistoryFeature = $this->getRelationParameters()->sqlHistoryFeature;
|
||||
if ($sqlHistoryFeature === null) {
|
||||
@ -1003,7 +1003,7 @@ class Relation
|
||||
* }
|
||||
*/
|
||||
public function getForeignData(
|
||||
$foreigners,
|
||||
array|bool $foreigners,
|
||||
$field,
|
||||
$override_total,
|
||||
string $foreign_filter,
|
||||
@ -1461,10 +1461,8 @@ class Relation
|
||||
*
|
||||
* @param array $foreigners Table Foreign data
|
||||
* @param string $column Column name
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
public function searchColumnInForeigners(array $foreigners, $column)
|
||||
public function searchColumnInForeigners(array $foreigners, $column): array|false
|
||||
{
|
||||
if (isset($foreigners[$column])) {
|
||||
return $foreigners[$column];
|
||||
|
||||
@ -103,7 +103,7 @@ final class SetVariableController extends AbstractController
|
||||
*
|
||||
* @return array formatted string and bool if string is HTML formatted
|
||||
*/
|
||||
private function formatVariable($name, $value): array
|
||||
private function formatVariable($name, int|string $value): array
|
||||
{
|
||||
$isHtmlFormatted = false;
|
||||
$formattedValue = $value;
|
||||
|
||||
@ -102,7 +102,7 @@ class VariablesController extends AbstractController
|
||||
*
|
||||
* @return array formatted string and bool if string is HTML formatted
|
||||
*/
|
||||
private function formatVariable($name, $value): array
|
||||
private function formatVariable($name, int|string $value): array
|
||||
{
|
||||
$isHtmlFormatted = false;
|
||||
$formattedValue = $value;
|
||||
|
||||
@ -246,7 +246,7 @@ class FindReplaceController extends AbstractController
|
||||
$find,
|
||||
$replaceWith,
|
||||
$charSet
|
||||
) {
|
||||
): array|bool {
|
||||
$column = $this->columnNames[$columnIndex];
|
||||
$sql_query = 'SELECT '
|
||||
. Util::backquote($column) . ','
|
||||
|
||||
@ -166,7 +166,7 @@ class Core
|
||||
*
|
||||
* @param string|int $size size (Default = 0)
|
||||
*/
|
||||
public static function getRealSize($size = 0): int
|
||||
public static function getRealSize(string|int $size = 0): int
|
||||
{
|
||||
if (! $size) {
|
||||
return 0;
|
||||
@ -597,7 +597,7 @@ class Core
|
||||
*
|
||||
* @param array|string $query_data Array containing queries or query itself
|
||||
*/
|
||||
public static function previewSQL($query_data): void
|
||||
public static function previewSQL(array|string $query_data): void
|
||||
{
|
||||
$retval = '<div class="preview_sql">';
|
||||
if (empty($query_data)) {
|
||||
@ -665,7 +665,7 @@ class Core
|
||||
*
|
||||
* @return string|bool the ip of the user
|
||||
*/
|
||||
public static function getIp()
|
||||
public static function getIp(): string|bool
|
||||
{
|
||||
/* Get the address of user */
|
||||
if (empty($_SERVER['REMOTE_ADDR'])) {
|
||||
|
||||
@ -189,15 +189,13 @@ class DatabaseInterface implements DbalInterface
|
||||
* to use unbuffered mode
|
||||
* @param bool $cacheAffectedRows whether to cache affected row
|
||||
* @psalm-param ConnectionType $connectionType
|
||||
*
|
||||
* @return ResultInterface|false
|
||||
*/
|
||||
public function tryQuery(
|
||||
string $query,
|
||||
int $connectionType = Connection::TYPE_USER,
|
||||
int $options = self::QUERY_BUFFERED,
|
||||
bool $cacheAffectedRows = true
|
||||
) {
|
||||
): ResultInterface|false {
|
||||
$debug = isset($GLOBALS['cfg']['DBG']) && $GLOBALS['cfg']['DBG']['sql'];
|
||||
if (! isset($this->connections[$connectionType])) {
|
||||
return false;
|
||||
@ -289,7 +287,7 @@ class DatabaseInterface implements DbalInterface
|
||||
*
|
||||
* @return ResultInterface|false the result set, or false if the query failed
|
||||
*/
|
||||
public function tryQueryAsControlUser(string $sql)
|
||||
public function tryQueryAsControlUser(string $sql): ResultInterface|false
|
||||
{
|
||||
// Avoid caching of the number of rows affected; for example, this function
|
||||
// is called for tracking purposes but we want to display the correct number
|
||||
@ -1209,7 +1207,7 @@ class DatabaseInterface implements DbalInterface
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function fetchValueOrValueByIndex($row, $value)
|
||||
private function fetchValueOrValueByIndex(array|string $row, $value)
|
||||
{
|
||||
return $value === null ? $row : $row[$value];
|
||||
}
|
||||
@ -1667,7 +1665,7 @@ class DatabaseInterface implements DbalInterface
|
||||
*
|
||||
* @return ResultInterface|false false when empty results / result set when not empty
|
||||
*/
|
||||
public function storeResult(int $connectionType = Connection::TYPE_USER)
|
||||
public function storeResult(int $connectionType = Connection::TYPE_USER): ResultInterface|false
|
||||
{
|
||||
if (! isset($this->connections[$connectionType])) {
|
||||
return false;
|
||||
@ -1683,7 +1681,7 @@ class DatabaseInterface implements DbalInterface
|
||||
*
|
||||
* @return string|bool type of connection used
|
||||
*/
|
||||
public function getHostInfo(int $connectionType = Connection::TYPE_USER)
|
||||
public function getHostInfo(int $connectionType = Connection::TYPE_USER): string|bool
|
||||
{
|
||||
if (! isset($this->connections[$connectionType])) {
|
||||
return false;
|
||||
@ -1699,7 +1697,7 @@ class DatabaseInterface implements DbalInterface
|
||||
*
|
||||
* @return int|bool version of the MySQL protocol used
|
||||
*/
|
||||
public function getProtoInfo(int $connectionType = Connection::TYPE_USER)
|
||||
public function getProtoInfo(int $connectionType = Connection::TYPE_USER): int|bool
|
||||
{
|
||||
if (! isset($this->connections[$connectionType])) {
|
||||
return false;
|
||||
@ -1738,10 +1736,9 @@ class DatabaseInterface implements DbalInterface
|
||||
*
|
||||
* @param string $query query to run
|
||||
*
|
||||
* @return string|int
|
||||
* @psalm-return int|numeric-string
|
||||
*/
|
||||
public function queryAndGetNumRows(string $query)
|
||||
public function queryAndGetNumRows(string $query): string|int
|
||||
{
|
||||
$result = $this->tryQuery($query);
|
||||
|
||||
@ -1777,13 +1774,12 @@ class DatabaseInterface implements DbalInterface
|
||||
* @param bool $getFromCache whether to retrieve from cache
|
||||
* @psalm-param ConnectionType $connectionType
|
||||
*
|
||||
* @return int|string
|
||||
* @psalm-return int|numeric-string
|
||||
*/
|
||||
public function affectedRows(
|
||||
int $connectionType = Connection::TYPE_USER,
|
||||
bool $getFromCache = true
|
||||
) {
|
||||
): int|string {
|
||||
if (! isset($this->connections[$connectionType])) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -319,7 +319,7 @@ interface DbalInterface
|
||||
*/
|
||||
public function fetchValue(
|
||||
string $query,
|
||||
$field = 0,
|
||||
int|string $field = 0,
|
||||
int $connectionType = Connection::TYPE_USER
|
||||
);
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ interface DbiExtension
|
||||
*
|
||||
* @return ResultInterface|false result
|
||||
*/
|
||||
public function realQuery(string $query, Connection $connection, int $options);
|
||||
public function realQuery(string $query, Connection $connection, int $options): ResultInterface|false;
|
||||
|
||||
/**
|
||||
* Run the multi query and output the results
|
||||
@ -60,7 +60,7 @@ interface DbiExtension
|
||||
*
|
||||
* @return ResultInterface|false false when empty results / result set when not empty
|
||||
*/
|
||||
public function storeResult(Connection $connection);
|
||||
public function storeResult(Connection $connection): ResultInterface|false;
|
||||
|
||||
/**
|
||||
* Returns a string representing the type of connection used
|
||||
@ -91,10 +91,9 @@ interface DbiExtension
|
||||
/**
|
||||
* returns the number of rows affected by last query
|
||||
*
|
||||
* @return int|string
|
||||
* @psalm-return int|numeric-string
|
||||
*/
|
||||
public function affectedRows(Connection $connection);
|
||||
public function affectedRows(Connection $connection): int|string;
|
||||
|
||||
/**
|
||||
* returns properly escaped string for use in MySQL queries
|
||||
|
||||
@ -178,10 +178,8 @@ class DbiMysqli implements DbiExtension
|
||||
*
|
||||
* @param string $query query to execute
|
||||
* @param int $options query options
|
||||
*
|
||||
* @return MysqliResult|false
|
||||
*/
|
||||
public function realQuery(string $query, Connection $connection, int $options)
|
||||
public function realQuery(string $query, Connection $connection, int $options): MysqliResult|false
|
||||
{
|
||||
$method = MYSQLI_STORE_RESULT;
|
||||
if ($options == ($options | DatabaseInterface::QUERY_UNBUFFERED)) {
|
||||
@ -239,7 +237,7 @@ class DbiMysqli implements DbiExtension
|
||||
*
|
||||
* @return MysqliResult|false false when empty results / result set when not empty
|
||||
*/
|
||||
public function storeResult(Connection $connection)
|
||||
public function storeResult(Connection $connection): MysqliResult|false
|
||||
{
|
||||
/** @var mysqli $mysqli */
|
||||
$mysqli = $connection->connection;
|
||||
@ -314,10 +312,9 @@ class DbiMysqli implements DbiExtension
|
||||
/**
|
||||
* returns the number of rows affected by last query
|
||||
*
|
||||
* @return int|string
|
||||
* @psalm-return int|numeric-string
|
||||
*/
|
||||
public function affectedRows(Connection $connection)
|
||||
public function affectedRows(Connection $connection): int|string
|
||||
{
|
||||
/** @var mysqli $mysqli */
|
||||
$mysqli = $connection->connection;
|
||||
|
||||
@ -213,10 +213,9 @@ final class MysqliResult implements ResultInterface
|
||||
/**
|
||||
* Returns the number of rows in the result
|
||||
*
|
||||
* @return string|int
|
||||
* @psalm-return int|numeric-string
|
||||
*/
|
||||
public function numRows()
|
||||
public function numRows(): string|int
|
||||
{
|
||||
if (! $this->result) {
|
||||
return 0;
|
||||
|
||||
@ -43,11 +43,9 @@ interface ResultInterface extends IteratorAggregate
|
||||
/**
|
||||
* Returns a single value from the given result; false on error
|
||||
*
|
||||
* @param int|string $field
|
||||
*
|
||||
* @return string|false|null
|
||||
*/
|
||||
public function fetchValue($field = 0);
|
||||
public function fetchValue(int|string $field = 0);
|
||||
|
||||
/**
|
||||
* Returns all rows of the result
|
||||
|
||||
@ -404,13 +404,13 @@ class Results
|
||||
* @psalm-param int|numeric-string $numRows
|
||||
*/
|
||||
public function setProperties(
|
||||
$unlimNumRows,
|
||||
int|string $unlimNumRows,
|
||||
array $fieldsMeta,
|
||||
$isCount,
|
||||
$isExport,
|
||||
$isFunction,
|
||||
$isAnalyse,
|
||||
$numRows,
|
||||
int|string $numRows,
|
||||
$fieldsCount,
|
||||
$queryTime,
|
||||
$textDirection,
|
||||
@ -2272,10 +2272,10 @@ class Results
|
||||
private function getRowValues(
|
||||
array $row,
|
||||
$rowNumber,
|
||||
$colOrder,
|
||||
array|false $colOrder,
|
||||
array $map,
|
||||
string $gridEditConfig,
|
||||
$colVisib,
|
||||
bool|array|string $colVisib,
|
||||
$urlSqlQuery,
|
||||
StatementInfo $statementInfo
|
||||
) {
|
||||
@ -2581,7 +2581,7 @@ class Results
|
||||
*
|
||||
* @return array<string, mixed> associative array with column nama -> value
|
||||
*/
|
||||
private function getRowInfoForSpecialLinks(array $row, $colOrder): array
|
||||
private function getRowInfoForSpecialLinks(array $row, array|bool $colOrder): array
|
||||
{
|
||||
$rowInfo = [];
|
||||
$fieldsMeta = $this->properties['fields_meta'];
|
||||
|
||||
@ -492,10 +492,8 @@ class Export
|
||||
* @param array|string $dumpBuffer the current dump buffer
|
||||
* @param string $compression the compression mode
|
||||
* @param string $filename the filename
|
||||
*
|
||||
* @return array|string|bool
|
||||
*/
|
||||
public function compress($dumpBuffer, string $compression, string $filename)
|
||||
public function compress(array|string $dumpBuffer, string $compression, string $filename): array|string|bool
|
||||
{
|
||||
if ($compression === 'zip' && function_exists('gzcompress')) {
|
||||
$zipExtension = new ZipExtension();
|
||||
@ -574,7 +572,7 @@ class Export
|
||||
* @param string $separateFiles whether it is a separate-files export
|
||||
*/
|
||||
public function exportServer(
|
||||
$dbSelect,
|
||||
string|array $dbSelect,
|
||||
string $whatStrucOrData,
|
||||
ExportPlugin $exportPlugin,
|
||||
string $errorUrl,
|
||||
|
||||
@ -108,8 +108,8 @@ final class Options
|
||||
$db,
|
||||
$table,
|
||||
$sqlQuery,
|
||||
$numTables,
|
||||
$unlimNumRows,
|
||||
int|string $numTables,
|
||||
int|string $unlimNumRows,
|
||||
array $exportList
|
||||
) {
|
||||
$exportTemplatesFeature = $this->relation->getRelationParameters()->exportTemplatesFeature;
|
||||
|
||||
@ -58,10 +58,7 @@ final class TemplateModel
|
||||
return $this->dbi->getError(Connection::TYPE_CONTROL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Template|string
|
||||
*/
|
||||
public function load(DatabaseName $db, TableName $table, string $user, int $id)
|
||||
public function load(DatabaseName $db, TableName $table, string $user, int $id): Template|string
|
||||
{
|
||||
$query = sprintf(
|
||||
'SELECT * FROM %s.%s WHERE `id` = %s AND `username` = \'%s\';',
|
||||
@ -110,7 +107,7 @@ final class TemplateModel
|
||||
/**
|
||||
* @return Template[]|string
|
||||
*/
|
||||
public function getAll(DatabaseName $db, TableName $table, string $user, string $exportType)
|
||||
public function getAll(DatabaseName $db, TableName $table, string $user, string $exportType): array|string
|
||||
{
|
||||
$query = sprintf(
|
||||
'SELECT * FROM %s.%s WHERE `username` = \'%s\' AND `export_type` = \'%s\' ORDER BY `template_name`;',
|
||||
|
||||
@ -159,7 +159,7 @@ class File
|
||||
*
|
||||
* @return string|false the binary file content, or false if no content
|
||||
*/
|
||||
public function getRawContent()
|
||||
public function getRawContent(): string|false
|
||||
{
|
||||
if ($this->content !== null) {
|
||||
return $this->content;
|
||||
@ -184,7 +184,7 @@ class File
|
||||
* @return string|false the binary file content as a string,
|
||||
* or false if no content
|
||||
*/
|
||||
public function getContent()
|
||||
public function getContent(): string|false
|
||||
{
|
||||
$result = $this->getRawContent();
|
||||
if ($result === false) {
|
||||
@ -507,7 +507,7 @@ class File
|
||||
* @todo move file read part into readChunk() or getChunk()
|
||||
* @todo add support for compression plugins
|
||||
*/
|
||||
protected function detectCompression()
|
||||
protected function detectCompression(): string|false
|
||||
{
|
||||
// suppress warnings from being displayed, but not from being logged
|
||||
// f.e. any file access outside of open_basedir will issue a warning
|
||||
|
||||
@ -28,7 +28,7 @@ class FileListing
|
||||
*
|
||||
* @return array|bool sorted file list on success, false on failure
|
||||
*/
|
||||
public function getDirContent(string $dir, string $expression = '')
|
||||
public function getDirContent(string $dir, string $expression = ''): array|bool
|
||||
{
|
||||
if (! @file_exists($dir)) {
|
||||
return false;
|
||||
@ -76,7 +76,7 @@ class FileListing
|
||||
string $dir,
|
||||
string $extensions = '',
|
||||
string $active = ''
|
||||
) {
|
||||
): string|false {
|
||||
$list = $this->getDirContent($dir, $extensions);
|
||||
if ($list === false) {
|
||||
return false;
|
||||
|
||||
@ -23,7 +23,7 @@ class GisFactory
|
||||
*
|
||||
* @static
|
||||
*/
|
||||
public static function factory($type)
|
||||
public static function factory($type): GisGeometry|false
|
||||
{
|
||||
return match (strtoupper($type)) {
|
||||
'MULTIPOLYGON' => GisMultiPolygon::singleton(),
|
||||
|
||||
@ -421,7 +421,7 @@ class GisPolygon extends GisGeometry
|
||||
*
|
||||
* @return array|false a point on the surface of the ring
|
||||
*/
|
||||
public static function getPointOnSurface(array $ring)
|
||||
public static function getPointOnSurface(array $ring): array|false
|
||||
{
|
||||
$x0 = null;
|
||||
$x1 = null;
|
||||
|
||||
@ -611,8 +611,12 @@ class GisVisualization
|
||||
*
|
||||
* @return mixed the formatted array of data
|
||||
*/
|
||||
private function prepareDataSet(array $data, array $scale_data, $format, $results)
|
||||
{
|
||||
private function prepareDataSet(
|
||||
array $data,
|
||||
array $scale_data,
|
||||
$format,
|
||||
ImageWrapper|TCPDF|string|false $results
|
||||
) {
|
||||
/** @var int[][] $colors */
|
||||
$colors = $this->settings['colors'];
|
||||
$color_index = 0;
|
||||
|
||||
@ -469,7 +469,7 @@ class Generator
|
||||
* @throws SyntaxError
|
||||
*/
|
||||
public static function getMessage(
|
||||
$message,
|
||||
Message|string $message,
|
||||
$sqlQuery = null,
|
||||
$type = 'notice'
|
||||
): string {
|
||||
@ -1008,7 +1008,7 @@ class Generator
|
||||
$urlPath,
|
||||
$urlParams,
|
||||
$message,
|
||||
$tagParams = [],
|
||||
string|array $tagParams = [],
|
||||
$target = '',
|
||||
bool $respectUrlLengthLimit = true
|
||||
): string {
|
||||
|
||||
@ -90,10 +90,7 @@ final class ImageWrapper
|
||||
return imagearc($this->image, $centerX, $centerY, $width, $height, $startAngle, $endAngle, $color);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|false
|
||||
*/
|
||||
public function colorAllocate(int $red, int $green, int $blue)
|
||||
public function colorAllocate(int $red, int $green, int $blue): int|false
|
||||
{
|
||||
return imagecolorallocate($this->image, $red, $green, $blue);
|
||||
}
|
||||
|
||||
@ -312,7 +312,7 @@ class Import
|
||||
*
|
||||
* @return string|bool part of file/buffer
|
||||
*/
|
||||
public function getNextChunk(?File $importHandle = null, int $size = 32768)
|
||||
public function getNextChunk(?File $importHandle = null, int $size = 32768): string|bool
|
||||
{
|
||||
$GLOBALS['charset_conversion'] = $GLOBALS['charset_conversion'] ?? null;
|
||||
$GLOBALS['charset_of_file'] = $GLOBALS['charset_of_file'] ?? null;
|
||||
@ -576,11 +576,11 @@ class Import
|
||||
* @todo Handle the error cases more elegantly
|
||||
*/
|
||||
public function detectSize(
|
||||
$lastCumulativeSize,
|
||||
string|int $lastCumulativeSize,
|
||||
?int $lastCumulativeType,
|
||||
int $currentCellType,
|
||||
string $cell
|
||||
) {
|
||||
): string|int {
|
||||
$currSize = mb_strlen($cell);
|
||||
|
||||
/**
|
||||
@ -849,7 +849,7 @@ class Import
|
||||
*
|
||||
* @todo Handle the error case more elegantly
|
||||
*/
|
||||
public function analyzeTable(array $table)
|
||||
public function analyzeTable(array $table): array|bool
|
||||
{
|
||||
/* Get number of rows in table */
|
||||
$numRows = count($table[self::ROWS]);
|
||||
@ -1453,10 +1453,8 @@ class Import
|
||||
|
||||
/**
|
||||
* @param array $importList List of plugin instances.
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
public static function getLocalFiles(array $importList)
|
||||
public static function getLocalFiles(array $importList): false|string
|
||||
{
|
||||
$fileListing = new FileListing();
|
||||
|
||||
|
||||
@ -34,8 +34,6 @@ final class SimulateDml
|
||||
/**
|
||||
* Find the matching rows for UPDATE/DELETE query.
|
||||
*
|
||||
* @param DeleteStatement|UpdateStatement|Statement $statement
|
||||
*
|
||||
* @return array<string, int|string>
|
||||
* @psalm-return array{
|
||||
* sql_query: string,
|
||||
@ -43,8 +41,11 @@ final class SimulateDml
|
||||
* matched_rows_url: string
|
||||
* }
|
||||
*/
|
||||
public function getMatchedRows(string $query, Parser $parser, $statement): array
|
||||
{
|
||||
public function getMatchedRows(
|
||||
string $query,
|
||||
Parser $parser,
|
||||
DeleteStatement|UpdateStatement|Statement $statement
|
||||
): array {
|
||||
$matchedRowQuery = '';
|
||||
if ($statement instanceof DeleteStatement) {
|
||||
$matchedRowQuery = $this->getSimulatedDeleteQuery($parser, $statement);
|
||||
@ -72,10 +73,9 @@ final class SimulateDml
|
||||
*
|
||||
* @param string $matchedRowQuery SQL query
|
||||
*
|
||||
* @return int|string
|
||||
* @psalm-return int|numeric-string
|
||||
*/
|
||||
private function executeMatchedRowQuery(string $matchedRowQuery)
|
||||
private function executeMatchedRowQuery(string $matchedRowQuery): int|string
|
||||
{
|
||||
$this->dbi->selectDb($GLOBALS['db']);
|
||||
// Execute the query.
|
||||
|
||||
@ -1202,7 +1202,7 @@ class InsertEdit
|
||||
* @param string|false $gotoInclude store some script for include, otherwise it is
|
||||
* boolean false
|
||||
*/
|
||||
public function getGotoInclude($gotoInclude): string
|
||||
public function getGotoInclude(string|false $gotoInclude): string
|
||||
{
|
||||
$validOptions = [
|
||||
'new_insert',
|
||||
@ -1618,7 +1618,7 @@ class InsertEdit
|
||||
public function getQueryValueForInsert(
|
||||
EditField $editField,
|
||||
bool $usingKey,
|
||||
$whereClause
|
||||
string|int $whereClause
|
||||
): string {
|
||||
$protectedValue = '';
|
||||
if ($editField->type === 'protected' && $usingKey && $whereClause !== '') {
|
||||
|
||||
@ -859,7 +859,7 @@ class LanguageManager
|
||||
*
|
||||
* @return Language|false Language object or false on failure
|
||||
*/
|
||||
public function getLanguage($code)
|
||||
public function getLanguage($code): Language|false
|
||||
{
|
||||
$code = strtolower($code);
|
||||
$langs = $this->availableLanguages();
|
||||
|
||||
@ -31,7 +31,7 @@ class Linter
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getLines($str)
|
||||
public static function getLines(string|UtfString $str)
|
||||
{
|
||||
if ((! ($str instanceof UtfString)) && defined('USE_UTF_STRINGS') && USE_UTF_STRINGS) {
|
||||
// If the lexer uses UtfString for processing then the position will
|
||||
|
||||
@ -325,7 +325,7 @@ class NavigationTree
|
||||
*
|
||||
* @return Node|bool The active node or false in case of failure, or true: (@see buildPathPart())
|
||||
*/
|
||||
private function buildPath()
|
||||
private function buildPath(): Node|bool
|
||||
{
|
||||
$retval = $this->tree;
|
||||
|
||||
@ -372,7 +372,7 @@ class NavigationTree
|
||||
*
|
||||
* @return Node|bool The active node or false in case of failure, true if the path contains <= 1 items
|
||||
*/
|
||||
private function buildPathPart(array $path, string $type2, int $pos2, string $type3, int $pos3)
|
||||
private function buildPathPart(array $path, string $type2, int $pos2, string $type3, int $pos3): Node|bool
|
||||
{
|
||||
if (count($path) <= 1) {
|
||||
return true;
|
||||
@ -908,7 +908,7 @@ class NavigationTree
|
||||
*
|
||||
* @return string|false HTML code for the navigation tree
|
||||
*/
|
||||
public function renderPath()
|
||||
public function renderPath(): string|false
|
||||
{
|
||||
$node = $this->buildPath();
|
||||
if (! is_bool($node)) {
|
||||
|
||||
@ -28,7 +28,7 @@ class NodeFactory
|
||||
*/
|
||||
public static function getInstance(
|
||||
string $class,
|
||||
$name = 'default',
|
||||
string|array $name = 'default',
|
||||
$type = Node::OBJECT,
|
||||
$isGroup = false
|
||||
): Node {
|
||||
|
||||
@ -47,10 +47,8 @@ class ExportJson extends ExportPlugin
|
||||
* Encodes the data into JSON
|
||||
*
|
||||
* @param mixed $data Data to encode
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
public function encode($data)
|
||||
public function encode($data): string|false
|
||||
{
|
||||
$options = 0;
|
||||
if (isset($GLOBALS['json_pretty_print']) && $GLOBALS['json_pretty_print']) {
|
||||
|
||||
@ -176,7 +176,7 @@ abstract class ExportPlugin implements Plugin
|
||||
*/
|
||||
public function exportMetadata(
|
||||
$db,
|
||||
$tables,
|
||||
string|array $tables,
|
||||
array $metadataTypes
|
||||
): bool {
|
||||
return true;
|
||||
|
||||
@ -229,10 +229,8 @@ class ImportOds extends ImportPlugin
|
||||
*
|
||||
* @param SimpleXMLElement $cell_attrs Cell attributes
|
||||
* @param SimpleXMLElement $text Texts
|
||||
*
|
||||
* @return float|string
|
||||
*/
|
||||
protected function getValue($cell_attrs, $text)
|
||||
protected function getValue($cell_attrs, $text): float|string
|
||||
{
|
||||
if (
|
||||
isset($_REQUEST['ods_recognize_percentages'])
|
||||
@ -391,7 +389,7 @@ class ImportOds extends ImportPlugin
|
||||
*
|
||||
* @return array|array[]
|
||||
*/
|
||||
private function iterateOverTables($sheets): array
|
||||
private function iterateOverTables(array|SimpleXMLElement $sheets): array
|
||||
{
|
||||
$tables = [];
|
||||
$max_cols = 0;
|
||||
|
||||
@ -19,10 +19,8 @@ class ShapeFileImport extends ShapeFile
|
||||
* Reads given number of bytes from SHP file
|
||||
*
|
||||
* @param int $bytes number of bytes
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
public function readSHP(int $bytes)
|
||||
public function readSHP(int $bytes): string|false
|
||||
{
|
||||
return ImportShp::readFromBuffer($bytes);
|
||||
}
|
||||
|
||||
@ -126,11 +126,11 @@ class Pdf extends PdfLib
|
||||
* @param float|int $topMargin The top margin
|
||||
*/
|
||||
public function setScale(
|
||||
$scale = 1,
|
||||
$xMin = 0,
|
||||
$yMin = 0,
|
||||
$leftMargin = -1,
|
||||
$topMargin = -1
|
||||
float|int $scale = 1,
|
||||
float|int $xMin = 0,
|
||||
float|int $yMin = 0,
|
||||
float|int $leftMargin = -1,
|
||||
float|int $topMargin = -1
|
||||
): void {
|
||||
$this->scale = $scale;
|
||||
$this->xMin = $xMin;
|
||||
@ -161,8 +161,8 @@ class Pdf extends PdfLib
|
||||
* @param string $link Link
|
||||
*/
|
||||
public function cellScale(
|
||||
$w,
|
||||
$h = 0,
|
||||
float|int $w,
|
||||
float|int $h = 0,
|
||||
$txt = '',
|
||||
$border = 0,
|
||||
$ln = 0,
|
||||
|
||||
@ -198,8 +198,8 @@ class Svg extends XMLWriter
|
||||
$name,
|
||||
$x,
|
||||
$y,
|
||||
$width = '',
|
||||
$height = '',
|
||||
int|string $width = '',
|
||||
int|string $height = '',
|
||||
?string $text = '',
|
||||
$styles = ''
|
||||
): void {
|
||||
|
||||
@ -25,7 +25,7 @@ class Cache
|
||||
* @param array $tables information for tables of some databases
|
||||
* @param string|bool $table table name
|
||||
*/
|
||||
public function cacheTableData(array $tables, $table): void
|
||||
public function cacheTableData(array $tables, string|bool $table): void
|
||||
{
|
||||
// Note: I don't see why we would need array_merge_recursive() here,
|
||||
// as it creates double entries for the same table (for example a double
|
||||
|
||||
@ -176,8 +176,12 @@ class Utilities
|
||||
* @param ResultInterface|false $result Query result
|
||||
* @param int|float $time Time to execute query
|
||||
*/
|
||||
public static function debugLogQueryIntoSession(string $query, ?string $errorMessage, $result, $time): void
|
||||
{
|
||||
public static function debugLogQueryIntoSession(
|
||||
string $query,
|
||||
?string $errorMessage,
|
||||
ResultInterface|false $result,
|
||||
int|float $time
|
||||
): void {
|
||||
$dbgInfo = [];
|
||||
|
||||
if ($result === false && $errorMessage !== null) {
|
||||
|
||||
@ -54,7 +54,7 @@ class Replication
|
||||
*
|
||||
* @return ResultInterface|false|int output of DatabaseInterface::tryQuery
|
||||
*/
|
||||
public function replicaControl(string $action, ?string $control, int $connectionType)
|
||||
public function replicaControl(string $action, ?string $control, int $connectionType): ResultInterface|false|int
|
||||
{
|
||||
$action = mb_strtoupper($action);
|
||||
$control = $control !== null ? mb_strtoupper($control) : '';
|
||||
@ -93,7 +93,7 @@ class Replication
|
||||
bool $stop,
|
||||
bool $start,
|
||||
int $connectionType
|
||||
) {
|
||||
): ResultInterface|false {
|
||||
if ($stop) {
|
||||
$this->replicaControl('STOP', null, $connectionType);
|
||||
}
|
||||
|
||||
@ -246,7 +246,7 @@ class ResponseRenderer
|
||||
* @param mixed|null $value Null, if passing an array in $json otherwise
|
||||
* it's a string value to the key
|
||||
*/
|
||||
public function addJSON($json, $value = null): void
|
||||
public function addJSON(string|int|array $json, $value = null): void
|
||||
{
|
||||
if (is_array($json)) {
|
||||
foreach ($json as $key => $value) {
|
||||
|
||||
@ -120,7 +120,7 @@ class SavedSearches
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setCriterias($criterias, $json = false)
|
||||
public function setCriterias(array|string $criterias, $json = false)
|
||||
{
|
||||
if ($json === true && is_string($criterias)) {
|
||||
$this->criterias = json_decode($criterias, true);
|
||||
|
||||
@ -2945,7 +2945,7 @@ class Privileges
|
||||
$urlDbname,
|
||||
string $username,
|
||||
string $hostname,
|
||||
$dbname,
|
||||
string|array $dbname,
|
||||
$tablename,
|
||||
string $route
|
||||
): string {
|
||||
|
||||
@ -579,7 +579,7 @@ class Sql
|
||||
* @return int|string number of rows affected or changed
|
||||
* @psalm-return int|numeric-string
|
||||
*/
|
||||
private function getNumberOfRowsAffectedOrChanged($isAffected, $result)
|
||||
private function getNumberOfRowsAffectedOrChanged($isAffected, ResultInterface|false $result): int|string
|
||||
{
|
||||
if ($isAffected) {
|
||||
return $this->dbi->affectedRows();
|
||||
@ -651,12 +651,12 @@ class Sql
|
||||
* @psalm-return int|numeric-string
|
||||
*/
|
||||
private function countQueryResults(
|
||||
$numRows,
|
||||
int|string $numRows,
|
||||
bool $justBrowsing,
|
||||
string $db,
|
||||
string $table,
|
||||
StatementInfo $statementInfo
|
||||
) {
|
||||
): int|string {
|
||||
/* Shortcut for not analyzed/empty query */
|
||||
if ($statementInfo->statement === null || $statementInfo->parser === null) {
|
||||
return 0;
|
||||
@ -883,7 +883,7 @@ class Sql
|
||||
private function getMessageForNoRowsReturned(
|
||||
?string $messageToShow,
|
||||
StatementInfo $statementInfo,
|
||||
$numRows
|
||||
int|string $numRows
|
||||
): Message {
|
||||
if ($statementInfo->queryType === 'DELETE') {
|
||||
$message = Message::getMessageForDeletedRows($numRows);
|
||||
@ -977,7 +977,7 @@ class Sql
|
||||
string $db,
|
||||
?string $table,
|
||||
?string $messageToShow,
|
||||
$numRows,
|
||||
int|string $numRows,
|
||||
$displayResultsObject,
|
||||
?array $extraData,
|
||||
?array $profilingResults,
|
||||
@ -1139,8 +1139,8 @@ class Sql
|
||||
$displayResultsObject,
|
||||
DisplayParts $displayParts,
|
||||
$editable,
|
||||
$unlimNumRows,
|
||||
$numRows,
|
||||
int|string $unlimNumRows,
|
||||
int|string $numRows,
|
||||
?array $showTable,
|
||||
$result,
|
||||
StatementInfo $statementInfo,
|
||||
@ -1260,7 +1260,7 @@ class Sql
|
||||
?string $displayQuery,
|
||||
bool $showSql,
|
||||
array $sqlData,
|
||||
$displayMessage
|
||||
Message|string $displayMessage
|
||||
): string {
|
||||
if ($displayQuery !== null && $showSql && $sqlData === []) {
|
||||
return Generator::getMessage($displayMessage, $displayQuery, 'success');
|
||||
@ -1348,8 +1348,8 @@ class Sql
|
||||
?string $table,
|
||||
?array $sqlData,
|
||||
$displayResultsObject,
|
||||
$unlimNumRows,
|
||||
$numRows,
|
||||
int|string $unlimNumRows,
|
||||
int|string $numRows,
|
||||
?string $dispQuery,
|
||||
$dispMessage,
|
||||
?array $profilingResults,
|
||||
|
||||
@ -62,8 +62,8 @@ class SqlQueryForm
|
||||
public function getHtml(
|
||||
string $db,
|
||||
string $table,
|
||||
$query = true,
|
||||
$display_tab = false,
|
||||
bool|string $query = true,
|
||||
bool|string $display_tab = false,
|
||||
$delimiter = ';'
|
||||
) {
|
||||
if (! $display_tab) {
|
||||
|
||||
@ -35,7 +35,7 @@ class SystemDatabase
|
||||
*
|
||||
* @return ResultInterface|false Result of executed SQL query
|
||||
*/
|
||||
public function getExistingTransformationData($db)
|
||||
public function getExistingTransformationData($db): ResultInterface|false
|
||||
{
|
||||
$browserTransformationFeature = $this->relation->getRelationParameters()->browserTransformationFeature;
|
||||
if ($browserTransformationFeature === null) {
|
||||
|
||||
@ -207,7 +207,7 @@ class Table implements Stringable
|
||||
* @param string[]|string $engine Checks the table engine against an
|
||||
* array of engine strings or a single string, should be uppercase
|
||||
*/
|
||||
public function isEngine($engine): bool
|
||||
public function isEngine(array|string $engine): bool
|
||||
{
|
||||
$engine = (array) $engine;
|
||||
$tableStorageEngine = $this->getStorageEngine();
|
||||
@ -483,7 +483,7 @@ class Table implements Stringable
|
||||
string $length = '',
|
||||
$attribute = '',
|
||||
$collation = '',
|
||||
$null = false,
|
||||
bool|string $null = false,
|
||||
$defaultType = 'USER_DEFINED',
|
||||
$defaultValue = '',
|
||||
$extra = '',
|
||||
@ -796,7 +796,7 @@ class Table implements Stringable
|
||||
$length,
|
||||
$attribute,
|
||||
$collation,
|
||||
$null,
|
||||
bool|string $null,
|
||||
$defaultType,
|
||||
$defaultValue,
|
||||
$extra,
|
||||
@ -836,8 +836,6 @@ class Table implements Stringable
|
||||
* @param array $whereFields Which fields will be used for the WHERE query (array('FIELDNAME' => 'FIELDVALUE'))
|
||||
* @param array $newFields Which fields will be used as new VALUES. These are the important keys which differ
|
||||
* from the old entry (array('FIELDNAME' => 'NEW FIELDVALUE'))
|
||||
*
|
||||
* @return int|bool
|
||||
*/
|
||||
public static function duplicateInfo(
|
||||
$work,
|
||||
@ -845,7 +843,7 @@ class Table implements Stringable
|
||||
array $getFields,
|
||||
array $whereFields,
|
||||
array $newFields
|
||||
) {
|
||||
): int|bool {
|
||||
$relation = new Relation($GLOBALS['dbi']);
|
||||
$relationParameters = $relation->getRelationParameters();
|
||||
$relationParams = $relationParameters->toArray();
|
||||
@ -1877,10 +1875,8 @@ class Table implements Stringable
|
||||
* @param string $property Property
|
||||
* @param mixed $value Value for the property
|
||||
* @param string $tableCreateTime Needed for PROP_COLUMN_ORDER and PROP_COLUMN_VISIB
|
||||
*
|
||||
* @return bool|Message
|
||||
*/
|
||||
public function setUiProp($property, $value, $tableCreateTime = null)
|
||||
public function setUiProp($property, $value, $tableCreateTime = null): bool|Message
|
||||
{
|
||||
if (empty($this->uiprefs)) {
|
||||
$this->loadUiPrefs();
|
||||
@ -2484,7 +2480,7 @@ class Table implements Stringable
|
||||
* @return array|bool associative array of column name and their expressions
|
||||
* or false on failure
|
||||
*/
|
||||
public function getColumnGenerationExpression($column = null)
|
||||
public function getColumnGenerationExpression($column = null): array|bool
|
||||
{
|
||||
if (
|
||||
Compatibility::isMySqlOrPerconaDb()
|
||||
|
||||
@ -113,10 +113,7 @@ final class Indexes
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|DatabaseName $db
|
||||
*/
|
||||
public function executeAddIndexSql($db, string $sql): Message
|
||||
public function executeAddIndexSql(string|DatabaseName $db, string $sql): Message
|
||||
{
|
||||
$this->dbi->selectDb($db);
|
||||
$result = $this->dbi->tryQuery($sql);
|
||||
|
||||
@ -177,7 +177,7 @@ class ThemeManager
|
||||
*
|
||||
* @return string|false theme name from cookie or false
|
||||
*/
|
||||
public function getThemeCookie()
|
||||
public function getThemeCookie(): string|false
|
||||
{
|
||||
$GLOBALS['config'] = $GLOBALS['config'] ?? null;
|
||||
|
||||
|
||||
@ -412,7 +412,7 @@ class Tracker
|
||||
$tableName,
|
||||
$version,
|
||||
$type,
|
||||
$newData
|
||||
string|array $newData
|
||||
): bool {
|
||||
$relation = new Relation($GLOBALS['dbi']);
|
||||
|
||||
|
||||
@ -96,10 +96,8 @@ class Tracking
|
||||
|
||||
/**
|
||||
* Function to get the list versions of the table
|
||||
*
|
||||
* @return ResultInterface|false
|
||||
*/
|
||||
public function getListOfVersionsOfTable(string $db, string $table)
|
||||
public function getListOfVersionsOfTable(string $db, string $table): ResultInterface|false
|
||||
{
|
||||
$trackingFeature = $this->relation->getRelationParameters()->trackingFeature;
|
||||
if ($trackingFeature === null) {
|
||||
@ -182,10 +180,8 @@ class Tracking
|
||||
|
||||
/**
|
||||
* Function to get sql results for selectable tables
|
||||
*
|
||||
* @return ResultInterface|false
|
||||
*/
|
||||
public function getSqlResultForSelectableTables(string $db)
|
||||
public function getSqlResultForSelectableTables(string $db): ResultInterface|false
|
||||
{
|
||||
$trackingFeature = $this->relation->getRelationParameters()->trackingFeature;
|
||||
if ($trackingFeature === null) {
|
||||
|
||||
@ -122,7 +122,7 @@ class Util
|
||||
*
|
||||
* @return string the message
|
||||
*/
|
||||
public static function getFormattedMaximumUploadSize($maxUploadSize): string
|
||||
public static function getFormattedMaximumUploadSize(int|float|string $maxUploadSize): string
|
||||
{
|
||||
// I have to reduce the second parameter (sensitiveness) from 6 to 4
|
||||
// to avoid weird results like 512 kKib
|
||||
@ -484,7 +484,7 @@ class Util
|
||||
* @return string the formatted value and its unit
|
||||
*/
|
||||
public static function formatNumber(
|
||||
$value,
|
||||
float|int|string $value,
|
||||
$digitsLeft = 3,
|
||||
$digitsRight = 0,
|
||||
$onlyDown = false,
|
||||
@ -588,7 +588,7 @@ class Util
|
||||
*
|
||||
* @return int|float The numerical part of the expression (for example 8)
|
||||
*/
|
||||
public static function extractValueFromFormattedSize($formattedSize)
|
||||
public static function extractValueFromFormattedSize(string|int $formattedSize): int|float
|
||||
{
|
||||
$returnValue = -1;
|
||||
|
||||
@ -848,7 +848,7 @@ class Util
|
||||
array $fieldsMeta,
|
||||
array $row,
|
||||
$forceUnique = false,
|
||||
$restrictToTable = false,
|
||||
string|bool $restrictToTable = false,
|
||||
array $expressions = []
|
||||
): array {
|
||||
$primaryKey = '';
|
||||
@ -1391,7 +1391,7 @@ class Util
|
||||
*
|
||||
* @return string|bool Title for the $cfg value
|
||||
*/
|
||||
public static function getTitleForTarget($target)
|
||||
public static function getTitleForTarget($target): string|bool
|
||||
{
|
||||
$mapping = [
|
||||
'structure' => __('Structure'),
|
||||
@ -2347,7 +2347,7 @@ class Util
|
||||
*
|
||||
* @return mixed Searched value
|
||||
*/
|
||||
public static function getValueByKey(array $array, $path, $default = null)
|
||||
public static function getValueByKey(array $array, string|array $path, $default = null)
|
||||
{
|
||||
if (is_string($path)) {
|
||||
$path = explode('.', $path);
|
||||
|
||||
@ -27,10 +27,8 @@ class FormatConverter
|
||||
* Transforms a binary to an IP
|
||||
*
|
||||
* @param mixed $buffer Data to transform
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
public static function binaryToIp($buffer, bool $isBinary)
|
||||
public static function binaryToIp($buffer, bool $isBinary): false|string
|
||||
{
|
||||
if (strpos($buffer, '0x') !== 0) {
|
||||
return $isBinary ? bin2hex($buffer) : $buffer;
|
||||
@ -67,10 +65,8 @@ class FormatConverter
|
||||
* Transforms an IP to a long
|
||||
*
|
||||
* @param string $buffer Data to transform
|
||||
*
|
||||
* @return int|string
|
||||
*/
|
||||
public static function ipToLong(string $buffer)
|
||||
public static function ipToLong(string $buffer): int|string
|
||||
{
|
||||
$ipLong = ip2long($buffer);
|
||||
if ($ipLong === false) {
|
||||
|
||||
@ -135,7 +135,7 @@ class ZipExtension
|
||||
*
|
||||
* @return string|false the file name of the first file that matches the given regular expression
|
||||
*/
|
||||
public function findFile($file, $regex)
|
||||
public function findFile($file, $regex): string|false
|
||||
{
|
||||
if ($this->zip === null) {
|
||||
return false;
|
||||
@ -187,7 +187,7 @@ class ZipExtension
|
||||
*
|
||||
* @return string|false data on success, false otherwise
|
||||
*/
|
||||
public function extract($file, $entry)
|
||||
public function extract($file, $entry): string|false
|
||||
{
|
||||
if ($this->zip === null) {
|
||||
return false;
|
||||
@ -216,7 +216,7 @@ class ZipExtension
|
||||
*
|
||||
* @return string|bool the ZIP file contents, or false if there was an error.
|
||||
*/
|
||||
public function createFile($data, $name, $time = 0)
|
||||
public function createFile(array|string $data, array|string $name, $time = 0): string|bool
|
||||
{
|
||||
$datasec = []; // Array to store compressed data
|
||||
$ctrlDir = []; // Central directory
|
||||
|
||||
@ -9779,9 +9779,6 @@
|
||||
<code>$paths['aPath_clean'][4]</code>
|
||||
<code>$paths['aPath_clean'][4]</code>
|
||||
</MixedArrayAccess>
|
||||
<MixedArrayOffset>
|
||||
<code>$hiddenCounts[$db]</code>
|
||||
</MixedArrayOffset>
|
||||
<MixedAssignment>
|
||||
<code>$db</code>
|
||||
<code>$item</code>
|
||||
@ -11035,6 +11032,8 @@
|
||||
<code>$do_relation</code>
|
||||
</ParamNameMismatch>
|
||||
<PossiblyFalseReference>
|
||||
<code>fetchAssoc</code>
|
||||
<code>getFieldNames</code>
|
||||
<code>numFields</code>
|
||||
</PossiblyFalseReference>
|
||||
<PossiblyInvalidArrayOffset>
|
||||
|
||||
@ -11,6 +11,7 @@ use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Server\Privileges\AccountLocking;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\Stubs\DummyResult;
|
||||
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
|
||||
use PHPUnit\Framework\MockObject\Stub;
|
||||
|
||||
@ -60,7 +61,7 @@ class AccountLockControllerTest extends AbstractTestCase
|
||||
public function testWithValidAccount(): void
|
||||
{
|
||||
$this->dbiStub->method('getVersion')->willReturn(100402);
|
||||
$this->dbiStub->method('tryQuery')->willReturn(true);
|
||||
$this->dbiStub->method('tryQuery')->willReturn($this->createStub(DummyResult::class));
|
||||
|
||||
($this->controller)($this->requestStub);
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Server\Privileges\AccountLocking;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\Stubs\DummyResult;
|
||||
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
|
||||
use PHPUnit\Framework\MockObject\Stub;
|
||||
|
||||
@ -60,7 +61,7 @@ class AccountUnlockControllerTest extends AbstractTestCase
|
||||
public function testWithValidAccount(): void
|
||||
{
|
||||
$this->dbiStub->method('getVersion')->willReturn(100402);
|
||||
$this->dbiStub->method('tryQuery')->willReturn(true);
|
||||
$this->dbiStub->method('tryQuery')->willReturn($this->createStub(DummyResult::class));
|
||||
|
||||
($this->controller)($this->requestStub);
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ use PhpMyAdmin\Database\CentralColumns;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Dbal\Connection;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\Stubs\DummyResult;
|
||||
use PhpMyAdmin\Types;
|
||||
|
||||
use function array_slice;
|
||||
@ -151,7 +152,7 @@ class CentralColumnsTest extends AbstractTestCase
|
||||
->will($this->returnValue(['id', 'col1', 'col2']));
|
||||
$dbi->expects($this->any())
|
||||
->method('tryQuery')
|
||||
->will($this->returnValue(true));
|
||||
->will($this->returnValue($this->createStub(DummyResult::class)));
|
||||
$dbi->expects($this->any())
|
||||
->method('getTables')
|
||||
->will(
|
||||
|
||||
@ -862,7 +862,7 @@ class InsertEditTest extends AbstractTestCase
|
||||
);
|
||||
|
||||
$column['True_Type'] = '';
|
||||
$foreigners['f'] = true;
|
||||
$foreigners['f'] = ['something'/* What should the mocked value actually be? */];
|
||||
$foreignData['foreign_link'] = '';
|
||||
$this->assertEquals(
|
||||
'4',
|
||||
|
||||
@ -11,6 +11,7 @@ use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Normalization;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\Stubs\DbiDummy;
|
||||
use PhpMyAdmin\Tests\Stubs\DummyResult;
|
||||
use PhpMyAdmin\Transformations;
|
||||
use PhpMyAdmin\Types;
|
||||
use stdClass;
|
||||
@ -118,7 +119,7 @@ class NormalizationTest extends AbstractTestCase
|
||||
->will($this->returnValueMap($map));
|
||||
$dbi->expects($this->any())
|
||||
->method('tryQuery')
|
||||
->will($this->returnValue(true));
|
||||
->will($this->returnValue($this->createStub(DummyResult::class)));
|
||||
$dbi->expects($this->any())
|
||||
->method('fetchResult')
|
||||
->will($this->returnValue([0]));
|
||||
|
||||
@ -6,6 +6,7 @@ namespace PhpMyAdmin\Tests\Server\Privileges;
|
||||
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Server\Privileges\AccountLocking;
|
||||
use PhpMyAdmin\Tests\Stubs\DummyResult;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Throwable;
|
||||
|
||||
@ -26,7 +27,7 @@ class AccountLockingTest extends TestCase
|
||||
$dbi->expects($this->once())
|
||||
->method('tryQuery')
|
||||
->with($this->equalTo('ALTER USER \'test.user\'@\'test.host\' ACCOUNT LOCK;'))
|
||||
->willReturn(true);
|
||||
->willReturn($this->createStub(DummyResult::class));
|
||||
$dbi->expects($this->never())->method('getError');
|
||||
|
||||
$accountLocking = new AccountLocking($dbi);
|
||||
@ -85,7 +86,7 @@ class AccountLockingTest extends TestCase
|
||||
$dbi->expects($this->once())
|
||||
->method('tryQuery')
|
||||
->with($this->equalTo('ALTER USER \'test.user\'@\'test.host\' ACCOUNT UNLOCK;'))
|
||||
->willReturn(true);
|
||||
->willReturn($this->createStub(DummyResult::class));
|
||||
$dbi->expects($this->never())->method('getError');
|
||||
|
||||
$accountLocking = new AccountLocking($dbi);
|
||||
|
||||
@ -193,10 +193,8 @@ class DbiDummy implements DbiExtension
|
||||
*
|
||||
* @param string $query query to run
|
||||
* @param int $options query options
|
||||
*
|
||||
* @return DummyResult|false
|
||||
*/
|
||||
public function realQuery(string $query, Connection $connection, int $options)
|
||||
public function realQuery(string $query, Connection $connection, int $options): DummyResult|false
|
||||
{
|
||||
$query = trim((string) preg_replace('/ */', ' ', str_replace("\n", ' ', $query)));
|
||||
$filoQuery = $this->findFiloQuery($query);
|
||||
@ -324,7 +322,7 @@ class DbiDummy implements DbiExtension
|
||||
*
|
||||
* @return ResultInterface|false false when empty results / result set when not empty
|
||||
*/
|
||||
public function storeResult(Connection $connection)
|
||||
public function storeResult(Connection $connection): ResultInterface|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -395,10 +393,9 @@ class DbiDummy implements DbiExtension
|
||||
/**
|
||||
* returns the number of rows affected by last query
|
||||
*
|
||||
* @return int|string
|
||||
* @psalm-return int|numeric-string
|
||||
*/
|
||||
public function affectedRows(Connection $connection)
|
||||
public function affectedRows(Connection $connection): int|string
|
||||
{
|
||||
return $GLOBALS['cached_affected_rows'] ?? 0;
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ namespace PhpMyAdmin\Tests;
|
||||
|
||||
use PhpMyAdmin\ConfigStorage\RelationParameters;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Tests\Stubs\DummyResult;
|
||||
use PhpMyAdmin\Transformations;
|
||||
|
||||
/**
|
||||
@ -236,7 +237,7 @@ class TransformationsTest extends AbstractTestCase
|
||||
->getMock();
|
||||
$dbi->expects($this->any())
|
||||
->method('tryQuery')
|
||||
->will($this->returnValue(true));
|
||||
->will($this->returnValue($this->createStub(DummyResult::class)));
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
|
||||
// Case 1 : no configuration storage
|
||||
|
||||
@ -9,6 +9,7 @@ use PhpMyAdmin\ConfigStorage\RelationParameters;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Dbal\Connection;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Tests\Stubs\DummyResult;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
|
||||
@ -201,7 +202,7 @@ class UserPreferencesTest extends AbstractNetworkTestCase
|
||||
$dbi->expects($this->once())
|
||||
->method('tryQuery')
|
||||
->with($query2, Connection::TYPE_CONTROL)
|
||||
->will($this->returnValue(true));
|
||||
->will($this->returnValue($this->createStub(DummyResult::class)));
|
||||
|
||||
$dbi->expects($this->any())
|
||||
->method('quoteString')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user