From 6cf8ee083175a0a077b47103a3e32fdd76c669b6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?=
Date: Mon, 14 May 2018 21:31:13 -0300
Subject: [PATCH 1/5] Enable strict mode in some classes
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Maurício Meneghini Fauth
---
libraries/classes/Advisor.php | 12 +++++----
libraries/classes/Bookmark.php | 2 ++
libraries/classes/BrowseForeigners.php | 8 +++---
libraries/classes/CentralColumns.php | 30 +++++++++++----------
libraries/classes/Charsets.php | 2 ++
libraries/classes/CheckUserPrivileges.php | 2 ++
libraries/classes/Config.php | 8 +++---
libraries/classes/Console.php | 2 ++
libraries/classes/Core.php | 16 +++++++-----
libraries/classes/CreateAddField.php | 2 ++
libraries/classes/DatabaseInterface.php | 30 +++++++++++----------
libraries/classes/Encoding.php | 2 ++
libraries/classes/Error.php | 2 ++
libraries/classes/ErrorHandler.php | 2 ++
libraries/classes/ErrorReport.php | 2 ++
libraries/classes/Export.php | 10 +++++--
libraries/classes/File.php | 8 +++---
libraries/classes/FileListing.php | 2 ++
libraries/classes/Font.php | 2 ++
libraries/classes/Footer.php | 2 ++
libraries/classes/Header.php | 2 ++
libraries/classes/Import.php | 26 +++++++++---------
libraries/classes/Index.php | 6 +++--
libraries/classes/IndexColumn.php | 2 ++
libraries/classes/InsertEdit.php | 4 ++-
libraries/classes/IpAllowDeny.php | 2 ++
libraries/classes/Language.php | 2 ++
libraries/classes/LanguageManager.php | 2 ++
libraries/classes/Linter.php | 2 ++
libraries/classes/ListAbstract.php | 2 ++
libraries/classes/ListDatabase.php | 2 ++
libraries/classes/Logging.php | 2 ++
libraries/classes/Menu.php | 2 ++
libraries/classes/Message.php | 16 +++++++-----
libraries/classes/Mime.php | 2 ++
libraries/classes/MultSubmits.php | 2 ++
libraries/classes/Normalization.php | 2 ++
libraries/classes/OpenDocument.php | 2 ++
libraries/classes/Operations.php | 2 ++
libraries/classes/OutputBuffering.php | 2 ++
libraries/classes/ParseAnalyze.php | 2 ++
libraries/classes/Partition.php | 2 ++
libraries/classes/Pdf.php | 2 ++
libraries/classes/Plugins.php | 6 +++--
libraries/classes/RecentFavoriteTable.php | 2 ++
libraries/classes/Relation.php | 4 ++-
libraries/classes/RelationCleanup.php | 2 ++
libraries/classes/Replication.php | 2 ++
libraries/classes/ReplicationGui.php | 2 ++
libraries/classes/Response.php | 2 ++
libraries/classes/Sanitize.php | 8 +++---
libraries/classes/SavedSearches.php | 2 ++
libraries/classes/Scripts.php | 2 ++
libraries/classes/Session.php | 2 ++
libraries/classes/Sql.php | 2 ++
libraries/classes/SqlQueryForm.php | 2 ++
libraries/classes/StorageEngine.php | 8 +++---
libraries/classes/SubPartition.php | 2 ++
libraries/classes/SysInfo.php | 2 ++
libraries/classes/SysInfoBase.php | 2 ++
libraries/classes/SysInfoLinux.php | 2 ++
libraries/classes/SysInfoSunOS.php | 2 ++
libraries/classes/SysInfoWINNT.php | 2 ++
libraries/classes/SystemDatabase.php | 2 ++
libraries/classes/Table.php | 8 +++---
libraries/classes/Template.php | 2 ++
libraries/classes/Theme.php | 2 ++
libraries/classes/ThemeManager.php | 2 ++
libraries/classes/Tracker.php | 8 +++---
libraries/classes/Tracking.php | 2 ++
libraries/classes/Transformations.php | 2 ++
libraries/classes/TwoFactor.php | 4 ++-
libraries/classes/Types.php | 2 ++
libraries/classes/Url.php | 12 +++++----
libraries/classes/UserPassword.php | 2 ++
libraries/classes/UserPreferences.php | 2 ++
libraries/classes/Util.php | 32 +++++++++++++----------
libraries/classes/VersionInformation.php | 2 ++
libraries/classes/ZipExtension.php | 2 ++
79 files changed, 272 insertions(+), 108 deletions(-)
diff --git a/libraries/classes/Advisor.php b/libraries/classes/Advisor.php
index 128c328347..0244830d46 100644
--- a/libraries/classes/Advisor.php
+++ b/libraries/classes/Advisor.php
@@ -6,6 +6,8 @@
*
* @package PhpMyAdmin
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
use Exception;
@@ -76,7 +78,7 @@ class Advisor
'ADVISOR_timespanFormat',
function (){},
function ($arguments, $seconds) {
- return self::timespanFormat($seconds);
+ return self::timespanFormat((int) $seconds);
}
);
$this->expression->register(
@@ -635,13 +637,13 @@ class Advisor
*
* This function is used when evaluating advisory_rules.txt
*
- * @param double $value the value to format
- * @param int $limes the sensitiveness
- * @param int $comma the number of decimals to retain
+ * @param double|string $value the value to format
+ * @param int $limes the sensitiveness
+ * @param int $comma the number of decimals to retain
*
* @return string the formatted value with unit
*/
- public static function formatByteDown(float $value, int $limes = 6, int $comma = 0): string
+ public static function formatByteDown($value, int $limes = 6, int $comma = 0): string
{
return implode(' ', Util::formatByteDown($value, $limes, $comma));
}
diff --git a/libraries/classes/Bookmark.php b/libraries/classes/Bookmark.php
index d2e27c1c95..bd472fb564 100644
--- a/libraries/classes/Bookmark.php
+++ b/libraries/classes/Bookmark.php
@@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
use PhpMyAdmin\DatabaseInterface;
diff --git a/libraries/classes/BrowseForeigners.php b/libraries/classes/BrowseForeigners.php
index beaea55e31..7fbec3b871 100644
--- a/libraries/classes/BrowseForeigners.php
+++ b/libraries/classes/BrowseForeigners.php
@@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
use PhpMyAdmin\Template;
@@ -58,7 +60,7 @@ class BrowseForeigners
* @param integer $indexByDescription index by description
* @param string $current_value current value on the edit form
*
- * @return string $html the generated html
+ * @return array $html the generated html
*/
private function getHtmlForOneKey(
int $horizontal_count,
@@ -68,7 +70,7 @@ class BrowseForeigners
array $descriptions,
int $indexByDescription,
string $current_value
- ): string {
+ ): array {
$horizontal_count++;
$output = '';
@@ -184,7 +186,7 @@ class BrowseForeigners
if (isset($_REQUEST['rownumber'])) {
$output .= '';
+ . htmlspecialchars((string) $_REQUEST['rownumber']) . '" />';
}
$filter_value = (isset($_REQUEST['foreign_filter'])
? htmlspecialchars($_REQUEST['foreign_filter'])
diff --git a/libraries/classes/CentralColumns.php b/libraries/classes/CentralColumns.php
index 14eefe784b..117042dd14 100644
--- a/libraries/classes/CentralColumns.php
+++ b/libraries/classes/CentralColumns.php
@@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
use PhpMyAdmin\Charsets;
@@ -167,7 +169,7 @@ class CentralColumns
$query, null, null, DatabaseInterface::CONNECT_CONTROL
);
if (isset($res[0])) {
- return $res[0];
+ return (int) $res[0];
}
return 0;
@@ -260,16 +262,16 @@ class CentralColumns
if (isset($def['Attribute'])) {
$attribute = $def['Attribute'];
};
- $collation = isset($def['Collation'])?$def['Collation']:"";
- $isNull = ($def['Null'] == "NO")?0:1;
- $extra = isset($def['Extra'])?$def['Extra']:"";
- $default = isset($def['Default'])?$def['Default']:"";
+ $collation = isset($def['Collation']) ? $def['Collation'] : "";
+ $isNull = ($def['Null'] == "NO") ? '0' : '1';
+ $extra = isset($def['Extra']) ? $def['Extra'] : "";
+ $default = isset($def['Default']) ? $def['Default'] : "";
$insQuery = 'INSERT INTO '
. Util::backquote($central_list_table) . ' '
. 'VALUES ( \'' . $this->dbi->escapeString($db) . '\' ,'
. '\'' . $this->dbi->escapeString($column) . '\',\''
. $this->dbi->escapeString($type) . '\','
- . '\'' . $this->dbi->escapeString($length) . '\',\''
+ . '\'' . $this->dbi->escapeString((string) $length) . '\',\''
. $this->dbi->escapeString($collation) . '\','
. '\'' . $this->dbi->escapeString($isNull) . '\','
. '\'' . implode(',', array($extra, $attribute))
@@ -288,7 +290,7 @@ class CentralColumns
* @param string $table if $isTable is false, then table name to
* which columns belong
*
- * @return true|PhpMyAdmin\Message
+ * @return true|\PhpMyAdmin\Message
*/
public function syncUniqueColumns(
array $field_select,
@@ -396,7 +398,7 @@ class CentralColumns
* selected list of columns to remove from central list
* @param bool $isTable if passed array is of tables or columns
*
- * @return true|PhpMyAdmin\Message
+ * @return true|\PhpMyAdmin\Message
*/
public function deleteColumnsFromList(
array $field_select,
@@ -481,7 +483,7 @@ class CentralColumns
* @param string $db current database
* @param array $selected_tables list of selected tables.
*
- * @return true|PhpMyAdmin\Message
+ * @return true|\PhpMyAdmin\Message
*/
public function makeConsistentWithList(
string $db,
@@ -515,9 +517,9 @@ class CentralColumns
$query .= ' ' . $column['col_extra'];
if ($column['col_default']) {
if ($column['col_default'] != 'CURRENT_TIMESTAMP'
- || $column['col_default'] != 'current_timestamp()') {
+ && $column['col_default'] != 'current_timestamp()') {
$query .= ' DEFAULT \'' . $this->dbi->escapeString(
- $column['col_default']
+ (string) $column['col_default']
) . '\'';
} else {
$query .= ' DEFAULT ' . $this->dbi->escapeString(
@@ -596,7 +598,7 @@ class CentralColumns
* @param string $col_extra new column extra property
* @param string $col_default new column default value
*
- * @return true|PhpMyAdmin\Message
+ * @return true|\PhpMyAdmin\Message
*/
public function updateOneColumn(
string $db,
@@ -653,7 +655,7 @@ class CentralColumns
/**
* Update Multiple column in central columns list if a chnage is requested
*
- * @return true|PhpMyAdmin\Message
+ * @return true|\PhpMyAdmin\Message
*/
public function updateMultipleColumn()
{
@@ -1008,7 +1010,7 @@ class CentralColumns
'column_number' => $row_num,
'ci' => 3,
'ci_offset' => 0,
- 'type_upper' => mb_strtoupper($row['col_default']),
+ 'type_upper' => mb_strtoupper((string) $row['col_default']),
'column_meta' => $meta,
'char_editing' => $this->charEditing,
)
diff --git a/libraries/classes/Charsets.php b/libraries/classes/Charsets.php
index d79773e392..93cd33474b 100644
--- a/libraries/classes/Charsets.php
+++ b/libraries/classes/Charsets.php
@@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
use PhpMyAdmin\DatabaseInterface;
diff --git a/libraries/classes/CheckUserPrivileges.php b/libraries/classes/CheckUserPrivileges.php
index 75ee66a5b6..fef595bbad 100644
--- a/libraries/classes/CheckUserPrivileges.php
+++ b/libraries/classes/CheckUserPrivileges.php
@@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
use PhpMyAdmin\DatabaseInterface;
diff --git a/libraries/classes/Config.php b/libraries/classes/Config.php
index e179d6d2ac..40a1b16a34 100644
--- a/libraries/classes/Config.php
+++ b/libraries/classes/Config.php
@@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
use DirectoryIterator;
@@ -146,7 +148,7 @@ class Config
}
// enable output-buffering (if set to 'auto')
- if (strtolower($this->get('OBGzip')) == 'auto') {
+ if (strtolower((string) $this->get('OBGzip')) == 'auto') {
$this->set('OBGzip', true);
}
}
@@ -704,7 +706,7 @@ class Config
$user2 = array(
'name' => trim($user[1]),
'email' => trim($user[2]),
- 'date' => date('Y-m-d H:i:s', $user[3]));
+ 'date' => date('Y-m-d H:i:s', (int) $user[3]));
if (isset($user[4])) {
$user2['date'] .= $user[4];
}
@@ -1668,7 +1670,7 @@ class Config
}
}
- return $server;
+ return (int) $server;
}
/**
diff --git a/libraries/classes/Console.php b/libraries/classes/Console.php
index 19ec2b6abc..40756b7ffd 100644
--- a/libraries/classes/Console.php
+++ b/libraries/classes/Console.php
@@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
use PhpMyAdmin\Bookmark;
diff --git a/libraries/classes/Core.php b/libraries/classes/Core.php
index b0dae17906..b7a251fdf3 100644
--- a/libraries/classes/Core.php
+++ b/libraries/classes/Core.php
@@ -7,6 +7,8 @@
*
* @package PhpMyAdmin
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
use PhpMyAdmin\DatabaseInterface;
@@ -224,7 +226,7 @@ class Core
if ($type === 'length' || $type === 'scalar') {
$is_scalar = is_scalar($var);
if ($is_scalar && $type === 'length') {
- return strlen($var) > 0;
+ return strlen((string) $var) > 0;
}
return $is_scalar;
}
@@ -492,11 +494,11 @@ class Core
public static function getenv(string $var_name): string
{
if (isset($_SERVER[$var_name])) {
- return $_SERVER[$var_name];
+ return (string) $_SERVER[$var_name];
}
if (isset($_ENV[$var_name])) {
- return $_ENV[$var_name];
+ return (string) $_ENV[$var_name];
}
if (getenv($var_name)) {
@@ -783,7 +785,7 @@ class Core
// We do not want these to be present
$blocked = array('user', 'pass', 'port');
foreach ($blocked as $part) {
- if (isset($arr[$part]) && strlen($arr[$part]) != 0) {
+ if (isset($arr[$part]) && strlen((string) $arr[$part]) != 0) {
return false;
}
}
@@ -1008,11 +1010,11 @@ class Core
/**
* Gets the "true" IP address of the current user
*
- * @return string the ip of the user
+ * @return string|bool the ip of the user
*
* @access private
*/
- public static function getIp(): string
+ public static function getIp()
{
/* Get the address of user */
if (empty($_SERVER['REMOTE_ADDR'])) {
@@ -1190,7 +1192,7 @@ class Core
* things behave slightly unexpectedly, for example
* round(1.2, 2) returns 1.199999999999999956.
*/
- ini_set('precision', 14);
+ ini_set('precision', '14');
/**
* check timezone setting
diff --git a/libraries/classes/CreateAddField.php b/libraries/classes/CreateAddField.php
index 47da956c01..883bfb7558 100644
--- a/libraries/classes/CreateAddField.php
+++ b/libraries/classes/CreateAddField.php
@@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
use PhpMyAdmin\Core;
diff --git a/libraries/classes/DatabaseInterface.php b/libraries/classes/DatabaseInterface.php
index 8c4ae09da4..0a25d45998 100644
--- a/libraries/classes/DatabaseInterface.php
+++ b/libraries/classes/DatabaseInterface.php
@@ -5,6 +5,8 @@
*
* @package PhpMyAdmin-DBI
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
use PhpMyAdmin\Core;
@@ -233,12 +235,12 @@ class DatabaseInterface
* Caches table data so Table does not require to issue
* SHOW TABLE STATUS again
*
- * @param array $tables information for tables of some databases
- * @param string $table table name
+ * @param array $tables information for tables of some databases
+ * @param string|bool $table table name
*
* @return void
*/
- private function _cacheTableData(array $tables, string $table): void
+ private function _cacheTableData(array $tables, $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
@@ -270,11 +272,11 @@ class DatabaseInterface
* @param string $query Query text
* @param mixed $link link type
* @param object|boolean $result Query result
- * @param integer $time Time to execute query
+ * @param integer|float $time Time to execute query
*
* @return void
*/
- private function _dbgQuery(string $query, $link, $result, int $time): void
+ private function _dbgQuery(string $query, $link, $result, $time): void
{
$dbgInfo = array();
$error_message = $this->getError($link);
@@ -1723,12 +1725,12 @@ class DatabaseInterface
/**
* Returns row or element of a row
*
- * @param array $row Row to process
- * @param string|null $value Which column to return
+ * @param array $row Row to process
+ * @param string|null|int $value Which column to return
*
* @return mixed
*/
- private function _fetchValue(array $row, ?string $value)
+ private function _fetchValue(array $row, $value)
{
if (is_null($value)) {
return $row;
@@ -2368,9 +2370,9 @@ class DatabaseInterface
/**
* Returns value for lower_case_table_names variable
*
- * @return string
+ * @return string|bool
*/
- public function getLowerCaseNames(): string
+ public function getLowerCaseNames()
{
if (is_null($this->_lower_case_table_names)) {
$this->_lower_case_table_names = $this->fetchValue(
@@ -2696,9 +2698,9 @@ class DatabaseInterface
*
* @param integer $link link type
*
- * @return string type of connection used
+ * @return string|bool type of connection used
*/
- public function getHostInfo($link = DatabaseInterface::CONNECT_USER): string
+ public function getHostInfo($link = DatabaseInterface::CONNECT_USER)
{
if (! isset($this->_links[$link])) {
return false;
@@ -2711,9 +2713,9 @@ class DatabaseInterface
*
* @param integer $link link type
*
- * @return integer version of the MySQL protocol used
+ * @return int|bool version of the MySQL protocol used
*/
- public function getProtoInfo($link = DatabaseInterface::CONNECT_USER): int
+ public function getProtoInfo($link = DatabaseInterface::CONNECT_USER)
{
if (! isset($this->_links[$link])) {
return false;
diff --git a/libraries/classes/Encoding.php b/libraries/classes/Encoding.php
index dc36fbc9ea..27e8f68c2d 100644
--- a/libraries/classes/Encoding.php
+++ b/libraries/classes/Encoding.php
@@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
use PhpMyAdmin\Config\ConfigFile;
diff --git a/libraries/classes/Error.php b/libraries/classes/Error.php
index 1f8f565b36..d15a0ef069 100644
--- a/libraries/classes/Error.php
+++ b/libraries/classes/Error.php
@@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
use Exception;
diff --git a/libraries/classes/ErrorHandler.php b/libraries/classes/ErrorHandler.php
index 0af45d8823..cc6d3ae059 100644
--- a/libraries/classes/ErrorHandler.php
+++ b/libraries/classes/ErrorHandler.php
@@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
use PhpMyAdmin\Error;
diff --git a/libraries/classes/ErrorReport.php b/libraries/classes/ErrorReport.php
index 7aaae9f0b7..9b8868c1e2 100644
--- a/libraries/classes/ErrorReport.php
+++ b/libraries/classes/ErrorReport.php
@@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
use PhpMyAdmin\Relation;
diff --git a/libraries/classes/Export.php b/libraries/classes/Export.php
index 439af4d9d8..71859651b1 100644
--- a/libraries/classes/Export.php
+++ b/libraries/classes/Export.php
@@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
use PhpMyAdmin\Core;
@@ -157,7 +159,11 @@ class Export
);
}
if ($GLOBALS['save_on_server'] && mb_strlen($line) > 0) {
- $write_result = @fwrite($GLOBALS['file_handle'], $line);
+ if (! is_null($GLOBALS['file_handle'])) {
+ $write_result = @fwrite($GLOBALS['file_handle'], $line);
+ } else {
+ $write_result = false;
+ }
// Here, use strlen rather than mb_strlen to get the length
// in bytes to compare against the number of bytes written.
if (! $write_result
@@ -518,7 +524,7 @@ class Export
foreach ($_REQUEST as $name => $value) {
if (!is_array($value)) {
- $back_button .= '&' . urlencode($name) . '=' . urlencode($value);
+ $back_button .= '&' . urlencode((string) $name) . '=' . urlencode((string) $value);
}
}
$back_button .= '&repopulate=1">' . __('Back') . ' ]
';
diff --git a/libraries/classes/File.php b/libraries/classes/File.php
index e2936a031a..86c53983f2 100644
--- a/libraries/classes/File.php
+++ b/libraries/classes/File.php
@@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
use PhpMyAdmin\Core;
@@ -158,12 +160,12 @@ class File
/**
* accessor
*
- * @param string $name file name
+ * @param string|null $name file name
*
* @return void
* @access public
*/
- public function setName(string $name): void
+ public function setName(?string $name): void
{
$this->_name = trim($name);
}
@@ -483,7 +485,7 @@ class File
{
// suppress warnings from being displayed, but not from being logged
// any file access outside of open_basedir will issue a warning
- return @is_readable($this->getName());
+ return @is_readable((string) $this->getName());
}
/**
diff --git a/libraries/classes/FileListing.php b/libraries/classes/FileListing.php
index a628f23d42..090fc9e421 100644
--- a/libraries/classes/FileListing.php
+++ b/libraries/classes/FileListing.php
@@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
/**
diff --git a/libraries/classes/Font.php b/libraries/classes/Font.php
index a9867410c1..c435fdaf71 100644
--- a/libraries/classes/Font.php
+++ b/libraries/classes/Font.php
@@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
/**
diff --git a/libraries/classes/Footer.php b/libraries/classes/Footer.php
index 80a6bee42b..cbfc1dfac2 100644
--- a/libraries/classes/Footer.php
+++ b/libraries/classes/Footer.php
@@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
use PhpMyAdmin\Config;
diff --git a/libraries/classes/Header.php b/libraries/classes/Header.php
index 973e8d5233..5173e857de 100644
--- a/libraries/classes/Header.php
+++ b/libraries/classes/Header.php
@@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
use PhpMyAdmin\Config;
diff --git a/libraries/classes/Import.php b/libraries/classes/Import.php
index a731888bee..4632d0fee8 100644
--- a/libraries/classes/Import.php
+++ b/libraries/classes/Import.php
@@ -5,6 +5,8 @@
*
* @package PhpMyAdmin-Import
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
use PhpMyAdmin\Encoding;
@@ -332,7 +334,7 @@ class Import
*/
public function lookForUse(?string $buffer, ?string $db, ?bool $reload): array
{
- if (preg_match('@^[\s]*USE[[:space:]]+([\S]+)@i', $buffer, $match)) {
+ if (preg_match('@^[\s]*USE[[:space:]]+([\S]+)@i', (string) $buffer, $match)) {
$db = trim($match[1]);
$db = trim($db, ';'); // for example, USE abc;
@@ -582,24 +584,24 @@ class Import
/**
* Obtains the size of the given cell
*
- * @param string $last_cumulative_size Last cumulative column size
- * @param int $last_cumulative_type Last cumulative column type
- * (NONE or VARCHAR or DECIMAL or INT or BIGINT)
- * @param int $curr_type Type of the current cell
- * (NONE or VARCHAR or DECIMAL or INT or BIGINT)
- * @param string $cell The current cell
+ * @param string|int $last_cumulative_size Last cumulative column size
+ * @param int $last_cumulative_type Last cumulative column type
+ * (NONE or VARCHAR or DECIMAL or INT or BIGINT)
+ * @param int $curr_type Type of the current cell
+ * (NONE or VARCHAR or DECIMAL or INT or BIGINT)
+ * @param string $cell The current cell
*
- * @return string Size of the given cell in the type-appropriate format
+ * @return string|int Size of the given cell in the type-appropriate format
* @access public
*
* @todo Handle the error cases more elegantly
*/
public function detectSize(
- string $last_cumulative_size,
+ $last_cumulative_size,
int $last_cumulative_type,
int $curr_type,
string $cell
- ): string {
+ ) {
$curr_size = mb_strlen($cell);
/**
@@ -803,7 +805,7 @@ class Import
* Else, we call it varchar for simplicity
*/
- if (! strcmp('NULL', $cell)) {
+ if (! strcmp('NULL', (string) $cell)) {
if ($last_cumulative_type === null || $last_cumulative_type == self::NONE) {
return self::NONE;
}
@@ -918,7 +920,7 @@ class Import
/* Check to ensure that all types are valid */
$len = count($types);
for ($n = 0; $n < $len; ++$n) {
- if (! strcmp(self::NONE, $types[$n])) {
+ if (! strcmp((string) self::NONE, (string) $types[$n])) {
$types[$n] = self::VARCHAR;
$sizes[$n] = '10';
}
diff --git a/libraries/classes/Index.php b/libraries/classes/Index.php
index c971e5b363..b31bf1eb5c 100644
--- a/libraries/classes/Index.php
+++ b/libraries/classes/Index.php
@@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
+declare(strict_types=1);
+
namespace PhpMyAdmin;
use PhpMyAdmin\IndexColumn;
@@ -803,10 +805,10 @@ class Index
}
$r .= '';
$r .= '