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 .= '' - . htmlspecialchars($column->getCardinality()) + . htmlspecialchars((string) $column->getCardinality()) . ''; $r .= '' - . htmlspecialchars($column->getCollation()) + . htmlspecialchars((string) $column->getCollation()) . ''; $r .= '' . htmlspecialchars($column->getNull(true)) diff --git a/libraries/classes/IndexColumn.php b/libraries/classes/IndexColumn.php index 00a2b7baba..2e0dc2d4c1 100644 --- a/libraries/classes/IndexColumn.php +++ b/libraries/classes/IndexColumn.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; /** diff --git a/libraries/classes/InsertEdit.php b/libraries/classes/InsertEdit.php index 676184ebe3..1080335bd8 100644 --- a/libraries/classes/InsertEdit.php +++ b/libraries/classes/InsertEdit.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\DatabaseInterface; @@ -587,7 +589,7 @@ class InsertEdit ) { $foreigner = $this->relation->searchColumnInForeigners($foreigners, $column['Field']); if (mb_strstr($column['True_Type'], 'enum')) { - if (mb_strlen($column['Type']) > 20) { + if (mb_strlen((string) $column['Type']) > 20) { $nullify_code = '1'; } else { $nullify_code = '2'; diff --git a/libraries/classes/IpAllowDeny.php b/libraries/classes/IpAllowDeny.php index 0e41a42df1..423a85fdb0 100644 --- a/libraries/classes/IpAllowDeny.php +++ b/libraries/classes/IpAllowDeny.php @@ -6,6 +6,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Core; diff --git a/libraries/classes/Language.php b/libraries/classes/Language.php index 93080f3a45..119a66bba3 100644 --- a/libraries/classes/Language.php +++ b/libraries/classes/Language.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\LanguageManager; diff --git a/libraries/classes/LanguageManager.php b/libraries/classes/LanguageManager.php index 2ecc9f136c..7afca15591 100644 --- a/libraries/classes/LanguageManager.php +++ b/libraries/classes/LanguageManager.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Core; diff --git a/libraries/classes/Linter.php b/libraries/classes/Linter.php index 53dd207b1e..ca819a76df 100644 --- a/libraries/classes/Linter.php +++ b/libraries/classes/Linter.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\SqlParser\Lexer; diff --git a/libraries/classes/ListAbstract.php b/libraries/classes/ListAbstract.php index 17ddb0f96f..3002d2053a 100644 --- a/libraries/classes/ListAbstract.php +++ b/libraries/classes/ListAbstract.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use ArrayObject; diff --git a/libraries/classes/ListDatabase.php b/libraries/classes/ListDatabase.php index ab44de963a..abdc8a4b21 100644 --- a/libraries/classes/ListDatabase.php +++ b/libraries/classes/ListDatabase.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\ListAbstract; diff --git a/libraries/classes/Logging.php b/libraries/classes/Logging.php index 1ad9b1bda4..711f828244 100644 --- a/libraries/classes/Logging.php +++ b/libraries/classes/Logging.php @@ -7,6 +7,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Core; diff --git a/libraries/classes/Menu.php b/libraries/classes/Menu.php index 4e34ac8f01..e68649aead 100644 --- a/libraries/classes/Menu.php +++ b/libraries/classes/Menu.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\DatabaseInterface; diff --git a/libraries/classes/Message.php b/libraries/classes/Message.php index e0538721b2..d0946c61d5 100644 --- a/libraries/classes/Message.php +++ b/libraries/classes/Message.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Sanitize; @@ -418,12 +420,12 @@ class Message /** * set string (does not take effect if raw message is set) * - * @param string $string string to set - * @param boolean $sanitize whether to sanitize $string or not + * @param string $string string to set + * @param boolean|int $sanitize whether to sanitize $string or not * * @return void */ - public function setString(string $string, bool $sanitize = true): void + public function setString(string $string, $sanitize = true): void { if ($sanitize) { $string = Message::sanitize($string); @@ -460,7 +462,7 @@ class Message if ($param instanceof Message) { $this->params[] = $param; } else { - $this->params[] = htmlspecialchars($param); + $this->params[] = htmlspecialchars((string) $param); } } @@ -570,11 +572,11 @@ class Message * set all params at once, usually used in conjunction with string * * @param array|string $params parameters to set - * @param boolean $sanitize whether to sanitize params + * @param bool|int $sanitize whether to sanitize params * * @return void */ - public function setParams($params, bool $sanitize = false): void + public function setParams($params, $sanitize = false): void { if ($sanitize) { $params = Message::sanitize($params); @@ -621,7 +623,7 @@ class Message return $message; } - return htmlspecialchars($message); + return htmlspecialchars((string) $message); } /** diff --git a/libraries/classes/Mime.php b/libraries/classes/Mime.php index c42293e397..165180f732 100644 --- a/libraries/classes/Mime.php +++ b/libraries/classes/Mime.php @@ -6,6 +6,8 @@ * @package PhpMyAdmin * @todo Maybe we could try to use fileinfo module if loaded */ +declare(strict_types=1); + namespace PhpMyAdmin; /** diff --git a/libraries/classes/MultSubmits.php b/libraries/classes/MultSubmits.php index 2ccdba3ad6..69b931a2db 100644 --- a/libraries/classes/MultSubmits.php +++ b/libraries/classes/MultSubmits.php @@ -7,6 +7,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Operations; diff --git a/libraries/classes/Normalization.php b/libraries/classes/Normalization.php index 9fc4332e56..3e56c902e5 100644 --- a/libraries/classes/Normalization.php +++ b/libraries/classes/Normalization.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Index; diff --git a/libraries/classes/OpenDocument.php b/libraries/classes/OpenDocument.php index 77104683db..ca867beee7 100644 --- a/libraries/classes/OpenDocument.php +++ b/libraries/classes/OpenDocument.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\ZipExtension; diff --git a/libraries/classes/Operations.php b/libraries/classes/Operations.php index d7277edb8b..20e705908c 100644 --- a/libraries/classes/Operations.php +++ b/libraries/classes/Operations.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Charsets; diff --git a/libraries/classes/OutputBuffering.php b/libraries/classes/OutputBuffering.php index a38839b750..fa6c6b4b82 100644 --- a/libraries/classes/OutputBuffering.php +++ b/libraries/classes/OutputBuffering.php @@ -4,6 +4,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; /** diff --git a/libraries/classes/ParseAnalyze.php b/libraries/classes/ParseAnalyze.php index c30af3e2c6..f8fa3d831b 100644 --- a/libraries/classes/ParseAnalyze.php +++ b/libraries/classes/ParseAnalyze.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Response; diff --git a/libraries/classes/Partition.php b/libraries/classes/Partition.php index 2ebfdb05a9..d270935cbe 100644 --- a/libraries/classes/Partition.php +++ b/libraries/classes/Partition.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\SubPartition; diff --git a/libraries/classes/Pdf.php b/libraries/classes/Pdf.php index 8ab3f1bf99..edc402830e 100644 --- a/libraries/classes/Pdf.php +++ b/libraries/classes/Pdf.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Core; diff --git a/libraries/classes/Plugins.php b/libraries/classes/Plugins.php index b125bceab8..d16335ca12 100644 --- a/libraries/classes/Plugins.php +++ b/libraries/classes/Plugins.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertySubgroup; @@ -179,10 +181,10 @@ class Plugins /* Possibly replace localised texts */ if (!preg_match_all( '/(str[A-Z][A-Za-z0-9]*)/', - $GLOBALS['cfg'][$section][$opt], + (string) $GLOBALS['cfg'][$section][$opt], $matches )) { - return htmlspecialchars($GLOBALS['cfg'][$section][$opt]); + return htmlspecialchars((string) $GLOBALS['cfg'][$section][$opt]); } $val = $GLOBALS['cfg'][$section][$opt]; diff --git a/libraries/classes/RecentFavoriteTable.php b/libraries/classes/RecentFavoriteTable.php index 8f65dbe4e4..ccc12a9ab0 100644 --- a/libraries/classes/RecentFavoriteTable.php +++ b/libraries/classes/RecentFavoriteTable.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\DatabaseInterface; diff --git a/libraries/classes/Relation.php b/libraries/classes/Relation.php index 2f182cb9bc..42eb1afce4 100644 --- a/libraries/classes/Relation.php +++ b/libraries/classes/Relation.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Core; @@ -112,7 +114,7 @@ class Relation $messages['enabled'] = '' . __('Enabled') . ''; $messages['disabled'] = '' . __('Disabled') . ''; - if (strlen($cfgRelation['db']) == 0) { + if (strlen((string) $cfgRelation['db']) == 0) { $retval .= __('Configuration of pmadb…') . ' ' . $messages['error'] . Util::showDocu('setup', 'linked-tables') diff --git a/libraries/classes/RelationCleanup.php b/libraries/classes/RelationCleanup.php index 0f2d022525..1cbd4b8726 100644 --- a/libraries/classes/RelationCleanup.php +++ b/libraries/classes/RelationCleanup.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Relation; diff --git a/libraries/classes/Replication.php b/libraries/classes/Replication.php index 7f9b6b538d..6883e4f474 100644 --- a/libraries/classes/Replication.php +++ b/libraries/classes/Replication.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Core; diff --git a/libraries/classes/ReplicationGui.php b/libraries/classes/ReplicationGui.php index 3a90a8eadc..fd6f5b52cf 100644 --- a/libraries/classes/ReplicationGui.php +++ b/libraries/classes/ReplicationGui.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Core; diff --git a/libraries/classes/Response.php b/libraries/classes/Response.php index 4594e464fb..719b749034 100644 --- a/libraries/classes/Response.php +++ b/libraries/classes/Response.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Core; diff --git a/libraries/classes/Sanitize.php b/libraries/classes/Sanitize.php index e8ee32d5d2..0345e615a2 100644 --- a/libraries/classes/Sanitize.php +++ b/libraries/classes/Sanitize.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Core; @@ -167,7 +169,7 @@ class Sanitize public static function sanitize($message, $escape = false, $safe = false) { if (!$safe) { - $message = strtr($message, array('<' => '<', '>' => '>')); + $message = strtr((string) $message, array('<' => '<', '>' => '>')); } /* Interpret bb code */ @@ -262,7 +264,7 @@ class Sanitize */ public static function jsFormat($a_string = '', $add_backquotes = true) { - $a_string = htmlspecialchars($a_string); + $a_string = htmlspecialchars((string) $a_string); $a_string = self::escapeJsString($a_string); // Needed for inline javascript to prevent some browsers // treating it as a anchor @@ -290,7 +292,7 @@ class Sanitize return preg_replace( '@ '', '\\' => '\\\\', diff --git a/libraries/classes/SavedSearches.php b/libraries/classes/SavedSearches.php index 968abf4a4c..a70edf7c07 100644 --- a/libraries/classes/SavedSearches.php +++ b/libraries/classes/SavedSearches.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Message; diff --git a/libraries/classes/Scripts.php b/libraries/classes/Scripts.php index 481ebff198..43abab8dff 100644 --- a/libraries/classes/Scripts.php +++ b/libraries/classes/Scripts.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Header; diff --git a/libraries/classes/Session.php b/libraries/classes/Session.php index 45799d4bb9..483d66a76c 100644 --- a/libraries/classes/Session.php +++ b/libraries/classes/Session.php @@ -7,6 +7,8 @@ * * @see https://secure.php.net/session */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Config; diff --git a/libraries/classes/Sql.php b/libraries/classes/Sql.php index cb029e55c8..339f70ebdb 100644 --- a/libraries/classes/Sql.php +++ b/libraries/classes/Sql.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Bookmark; diff --git a/libraries/classes/SqlQueryForm.php b/libraries/classes/SqlQueryForm.php index a7a11c3670..b955e9e3df 100644 --- a/libraries/classes/SqlQueryForm.php +++ b/libraries/classes/SqlQueryForm.php @@ -10,6 +10,8 @@ * @usedby tbl_tracking.php * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Bookmark; diff --git a/libraries/classes/StorageEngine.php b/libraries/classes/StorageEngine.php index 3513a7e77a..590ad83d82 100644 --- a/libraries/classes/StorageEngine.php +++ b/libraries/classes/StorageEngine.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Engines\Bdb; @@ -109,7 +111,7 @@ class StorageEngine $storage_engines = $GLOBALS['dbi']->fetchResult('SHOW STORAGE ENGINES', 'Engine'); if ($GLOBALS['dbi']->getVersion() >= 50708) { - $disabled = Util::cacheGet( + $disabled = (string) Util::cacheGet( 'disabled_storage_engines', function () { return $GLOBALS['dbi']->fetchValue( @@ -146,8 +148,8 @@ class StorageEngine $selected = null, $offerUnavailableEngines = false, $addEmpty = false ) { - $selected = mb_strtolower($selected); - $output = ''; + $fields .= ''; } } @@ -214,7 +216,7 @@ class Url $params['lang'] = $GLOBALS['lang']; } - $query = http_build_query($params, null, $separator); + $query = http_build_query($params, '', $separator); if ($divider != '?' || strlen($query) > 0) { return $divider . $query; diff --git a/libraries/classes/UserPassword.php b/libraries/classes/UserPassword.php index 133cc35ab5..c38b490a3e 100644 --- a/libraries/classes/UserPassword.php +++ b/libraries/classes/UserPassword.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Core; diff --git a/libraries/classes/UserPreferences.php b/libraries/classes/UserPreferences.php index 76723fcd75..2aa92c85ce 100644 --- a/libraries/classes/UserPreferences.php +++ b/libraries/classes/UserPreferences.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Config\ConfigFile; diff --git a/libraries/classes/Util.php b/libraries/classes/Util.php index c31c3c7fcc..97baba2fbc 100644 --- a/libraries/classes/Util.php +++ b/libraries/classes/Util.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Core; @@ -844,7 +846,7 @@ class Util } // '0' is also empty for php :-( - if (strlen($a_name) > 0 && $a_name !== '*') { + if (strlen((string) $a_name) > 0 && $a_name !== '*') { return '`' . str_replace('`', '``', $a_name) . '`'; } @@ -1343,7 +1345,7 @@ class Util //number_format is not multibyte safe, str_replace is safe if ($digits_left === 0) { $value = number_format( - $value, + (float) $value, $digits_right, /* l10n: Decimal separator */ __('.'), @@ -1395,7 +1397,7 @@ class Util * This gives us the right SI prefix already, * but $digits_left parameter not incorporated */ - $d = floor(log10($value) / 3); + $d = floor(log10((float) $value) / 3); /* * Lowering the SI prefix by 1 gives us an additional 3 zeros * So if we have 3,6,9,12.. free digits ($digits_left - $cur_digits) @@ -1449,6 +1451,8 @@ class Util { $return_value = -1; + $formatted_size = (string) $formatted_size; + if (preg_match('/^[0-9]+GB$/', $formatted_size)) { $return_value = mb_substr($formatted_size, 0, -2) * pow(1024, 3); @@ -1526,17 +1530,17 @@ class Util $date = preg_replace( '@%[aA]@', - $day_of_week[(int)strftime('%w', $timestamp)], + $day_of_week[(int)strftime('%w', (int) $timestamp)], $format ); $date = preg_replace( '@%[bB]@', - $month[(int)strftime('%m', $timestamp)-1], + $month[(int) strftime('%m', (int) $timestamp)-1], $date ); /* Fill in AM/PM */ - $hours = (int)date('H', $timestamp); + $hours = (int) date('H', (int) $timestamp); if ($hours >= 12) { $am_pm = _pgettext('AM/PM indication in time', 'PM'); } else { @@ -1544,11 +1548,11 @@ class Util } $date = preg_replace('@%[pP]@', $am_pm, $date); - $ret = strftime($date, $timestamp); + $ret = strftime($date, (int) $timestamp); // Some OSes such as Win8.1 Traditional Chinese version did not produce UTF-8 // output here. See https://github.com/phpmyadmin/phpmyadmin/issues/10598 if (mb_detect_encoding($ret, 'UTF-8', true) != 'UTF-8') { - $ret = date('Y-m-d H:i:s', $timestamp); + $ret = date('Y-m-d H:i:s', (int) $timestamp); } return $ret; @@ -2401,10 +2405,10 @@ class Util * * @return string html link to default db page */ - public static function getDbLink($database = null) + public static function getDbLink($database = '') { - if (strlen($database) === 0) { - if (strlen($GLOBALS['db']) === 0) { + if (strlen((string) $database) === 0) { + if (strlen((string) $GLOBALS['db']) === 0) { return ''; } $database = $GLOBALS['db']; @@ -2894,7 +2898,7 @@ class Util if (substr($ndbver, 0, 4) == 'ndb-') { $ndbver = substr($ndbver, 4); } - return version_compare($ndbver, 7.3, '>='); + return version_compare($ndbver, '7.3', '>='); } return false; @@ -3211,7 +3215,7 @@ class Util } /* Do the replacement */ - return strtr(strftime($string), $replace); + return strtr((string) strftime($string), $replace); } /** @@ -3508,7 +3512,7 @@ class Util $funcs['IsEmpty'] = array('params' => 1, 'type' => 'int'); $funcs['IsSimple'] = array('params' => 1, 'type' => 'int'); - $geom_type = trim(mb_strtolower($geom_type)); + $geom_type = trim(mb_strtolower((string) $geom_type)); if ($display && $geom_type != 'geometry' && $geom_type != 'multipoint') { $funcs[] = array('display' => '--------'); } diff --git a/libraries/classes/VersionInformation.php b/libraries/classes/VersionInformation.php index 4633471274..3d5dcdfb95 100644 --- a/libraries/classes/VersionInformation.php +++ b/libraries/classes/VersionInformation.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use PhpMyAdmin\Util; diff --git a/libraries/classes/ZipExtension.php b/libraries/classes/ZipExtension.php index f88307117e..27885774bf 100644 --- a/libraries/classes/ZipExtension.php +++ b/libraries/classes/ZipExtension.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin; use ZipArchive; From b6435e9ed2ef4d3396cfd1e96e9e4653714c6a4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Mon, 14 May 2018 21:57:19 -0300 Subject: [PATCH 2/5] Enable strict mode in Config 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/Config/ConfigFile.php | 2 ++ libraries/classes/Config/Descriptions.php | 2 ++ libraries/classes/Config/Form.php | 8 +++++--- libraries/classes/Config/FormDisplay.php | 2 ++ libraries/classes/Config/FormDisplayTemplate.php | 8 +++++--- libraries/classes/Config/Forms/BaseForm.php | 2 ++ libraries/classes/Config/Forms/BaseFormList.php | 2 ++ libraries/classes/Config/Forms/Page/BrowseForm.php | 2 ++ libraries/classes/Config/Forms/Page/DbStructureForm.php | 2 ++ libraries/classes/Config/Forms/Page/EditForm.php | 2 ++ libraries/classes/Config/Forms/Page/ExportForm.php | 2 ++ libraries/classes/Config/Forms/Page/ImportForm.php | 2 ++ libraries/classes/Config/Forms/Page/NaviForm.php | 2 ++ libraries/classes/Config/Forms/Page/PageFormList.php | 2 ++ libraries/classes/Config/Forms/Page/SqlForm.php | 2 ++ .../classes/Config/Forms/Page/TableStructureForm.php | 2 ++ libraries/classes/Config/Forms/Setup/ConfigForm.php | 2 ++ libraries/classes/Config/Forms/Setup/ExportForm.php | 2 ++ libraries/classes/Config/Forms/Setup/FeaturesForm.php | 2 ++ libraries/classes/Config/Forms/Setup/ImportForm.php | 2 ++ libraries/classes/Config/Forms/Setup/MainForm.php | 2 ++ libraries/classes/Config/Forms/Setup/NaviForm.php | 2 ++ libraries/classes/Config/Forms/Setup/ServersForm.php | 2 ++ libraries/classes/Config/Forms/Setup/SetupFormList.php | 2 ++ libraries/classes/Config/Forms/Setup/SqlForm.php | 2 ++ libraries/classes/Config/Forms/User/ExportForm.php | 2 ++ libraries/classes/Config/Forms/User/FeaturesForm.php | 2 ++ libraries/classes/Config/Forms/User/ImportForm.php | 2 ++ libraries/classes/Config/Forms/User/MainForm.php | 2 ++ libraries/classes/Config/Forms/User/NaviForm.php | 2 ++ libraries/classes/Config/Forms/User/SqlForm.php | 2 ++ libraries/classes/Config/Forms/User/UserFormList.php | 2 ++ libraries/classes/Config/PageSettings.php | 2 ++ libraries/classes/Config/ServerConfigChecks.php | 2 ++ libraries/classes/Config/Validator.php | 2 ++ 35 files changed, 76 insertions(+), 6 deletions(-) diff --git a/libraries/classes/Config/ConfigFile.php b/libraries/classes/Config/ConfigFile.php index 2cb0c6c088..918bbc4450 100644 --- a/libraries/classes/Config/ConfigFile.php +++ b/libraries/classes/Config/ConfigFile.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin\Config; use PhpMyAdmin\Config; diff --git a/libraries/classes/Config/Descriptions.php b/libraries/classes/Config/Descriptions.php index 12a47130c1..58c9f4f2c6 100644 --- a/libraries/classes/Config/Descriptions.php +++ b/libraries/classes/Config/Descriptions.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin\Config; use PhpMyAdmin\Sanitize; diff --git a/libraries/classes/Config/Form.php b/libraries/classes/Config/Form.php index f7c670fa31..a9b724294d 100644 --- a/libraries/classes/Config/Form.php +++ b/libraries/classes/Config/Form.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin\Config; use PhpMyAdmin\Config\ConfigFile; @@ -81,7 +83,7 @@ class Form $key = ltrim( mb_substr( $option_name, - mb_strrpos($option_name, '/') + (int) mb_strrpos($option_name, '/') ), '/' ); @@ -184,7 +186,7 @@ class Form $this->fields = array(); foreach ($paths as $path) { $key = ltrim( - mb_substr($path, mb_strrpos($path, '/')), + mb_substr($path, (int) mb_strrpos($path, '/')), '/' ); $this->fields[$key] = $path; @@ -201,7 +203,7 @@ class Form { $cf = $this->_configFile; foreach ($this->fields as $name => $path) { - if (mb_strpos($name, ':group:') === 0) { + if (mb_strpos((string) $name, ':group:') === 0) { $this->_fieldsTypes[$name] = 'group'; continue; } diff --git a/libraries/classes/Config/FormDisplay.php b/libraries/classes/Config/FormDisplay.php index 9cc114da6e..981f771f86 100644 --- a/libraries/classes/Config/FormDisplay.php +++ b/libraries/classes/Config/FormDisplay.php @@ -12,6 +12,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin\Config; use PhpMyAdmin\Config\ConfigFile; diff --git a/libraries/classes/Config/FormDisplayTemplate.php b/libraries/classes/Config/FormDisplayTemplate.php index 28ce77d94a..bcf0198e1a 100644 --- a/libraries/classes/Config/FormDisplayTemplate.php +++ b/libraries/classes/Config/FormDisplayTemplate.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin\Config; use PhpMyAdmin\Sanitize; @@ -263,7 +265,7 @@ class FormDisplayTemplate break; case 'number_text': $htmlOutput .= ''; + . ' value="' . htmlspecialchars((string) $value) . '" />'; break; case 'checkbox': $htmlOutput .= ' Date: Mon, 14 May 2018 22:18:16 -0300 Subject: [PATCH 3/5] Enable strict mode in Controllers 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/Controllers/Controller.php | 2 ++ .../Controllers/Database/DatabaseStructureController.php | 2 ++ libraries/classes/Controllers/DatabaseController.php | 2 ++ .../classes/Controllers/Server/ServerBinlogController.php | 2 ++ .../classes/Controllers/Server/ServerCollationsController.php | 1 + .../classes/Controllers/Server/ServerDatabasesController.php | 1 + .../classes/Controllers/Server/ServerEnginesController.php | 1 + .../classes/Controllers/Server/ServerPluginsController.php | 1 + .../classes/Controllers/Server/ServerVariablesController.php | 1 + libraries/classes/Controllers/Table/TableChartController.php | 2 ++ .../Controllers/Table/TableGisVisualizationController.php | 2 ++ .../classes/Controllers/Table/TableIndexesController.php | 2 ++ .../classes/Controllers/Table/TableRelationController.php | 2 ++ libraries/classes/Controllers/Table/TableSearchController.php | 2 ++ .../classes/Controllers/Table/TableStructureController.php | 4 +++- libraries/classes/Controllers/TableController.php | 2 ++ 16 files changed, 28 insertions(+), 1 deletion(-) diff --git a/libraries/classes/Controllers/Controller.php b/libraries/classes/Controllers/Controller.php index 24df284cb2..3dd212d2b1 100644 --- a/libraries/classes/Controllers/Controller.php +++ b/libraries/classes/Controllers/Controller.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin\Controllers */ +declare(strict_types=1); + namespace PhpMyAdmin\Controllers; use PhpMyAdmin\DatabaseInterface; diff --git a/libraries/classes/Controllers/Database/DatabaseStructureController.php b/libraries/classes/Controllers/Database/DatabaseStructureController.php index b394714093..f3fb5877d6 100644 --- a/libraries/classes/Controllers/Database/DatabaseStructureController.php +++ b/libraries/classes/Controllers/Database/DatabaseStructureController.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin\Controllers */ +declare(strict_types=1); + namespace PhpMyAdmin\Controllers\Database; use PhpMyAdmin\Charsets; diff --git a/libraries/classes/Controllers/DatabaseController.php b/libraries/classes/Controllers/DatabaseController.php index af0ffc10b6..c7220e9f0c 100644 --- a/libraries/classes/Controllers/DatabaseController.php +++ b/libraries/classes/Controllers/DatabaseController.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin\Controllers */ +declare(strict_types=1); + namespace PhpMyAdmin\Controllers; /** diff --git a/libraries/classes/Controllers/Server/ServerBinlogController.php b/libraries/classes/Controllers/Server/ServerBinlogController.php index e496a2ac58..22dcbe199e 100644 --- a/libraries/classes/Controllers/Server/ServerBinlogController.php +++ b/libraries/classes/Controllers/Server/ServerBinlogController.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin\Controllers */ +declare(strict_types=1); + namespace PhpMyAdmin\Controllers\Server; use PhpMyAdmin\Controllers\Controller; diff --git a/libraries/classes/Controllers/Server/ServerCollationsController.php b/libraries/classes/Controllers/Server/ServerCollationsController.php index cead8ab1ef..4ae7a0893a 100644 --- a/libraries/classes/Controllers/Server/ServerCollationsController.php +++ b/libraries/classes/Controllers/Server/ServerCollationsController.php @@ -6,6 +6,7 @@ * * @package PhpMyAdmin\Controllers */ +declare(strict_types=1); namespace PhpMyAdmin\Controllers\Server; diff --git a/libraries/classes/Controllers/Server/ServerDatabasesController.php b/libraries/classes/Controllers/Server/ServerDatabasesController.php index 800f714339..07529d373b 100644 --- a/libraries/classes/Controllers/Server/ServerDatabasesController.php +++ b/libraries/classes/Controllers/Server/ServerDatabasesController.php @@ -6,6 +6,7 @@ * * @package PhpMyAdmin\Controllers */ +declare(strict_types=1); namespace PhpMyAdmin\Controllers\Server; diff --git a/libraries/classes/Controllers/Server/ServerEnginesController.php b/libraries/classes/Controllers/Server/ServerEnginesController.php index 794060d70b..1f4ffcafec 100644 --- a/libraries/classes/Controllers/Server/ServerEnginesController.php +++ b/libraries/classes/Controllers/Server/ServerEnginesController.php @@ -6,6 +6,7 @@ * * @package PhpMyAdmin\Controllers */ +declare(strict_types=1); namespace PhpMyAdmin\Controllers\Server; diff --git a/libraries/classes/Controllers/Server/ServerPluginsController.php b/libraries/classes/Controllers/Server/ServerPluginsController.php index 0094178405..0fcb83e94b 100644 --- a/libraries/classes/Controllers/Server/ServerPluginsController.php +++ b/libraries/classes/Controllers/Server/ServerPluginsController.php @@ -6,6 +6,7 @@ * * @package PhpMyAdmin\Controllers */ +declare(strict_types=1); namespace PhpMyAdmin\Controllers\Server; diff --git a/libraries/classes/Controllers/Server/ServerVariablesController.php b/libraries/classes/Controllers/Server/ServerVariablesController.php index 58f8b47d8f..da3c8278da 100644 --- a/libraries/classes/Controllers/Server/ServerVariablesController.php +++ b/libraries/classes/Controllers/Server/ServerVariablesController.php @@ -6,6 +6,7 @@ * * @package PhpMyAdmin\Controllers */ +declare(strict_types=1); namespace PhpMyAdmin\Controllers\Server; diff --git a/libraries/classes/Controllers/Table/TableChartController.php b/libraries/classes/Controllers/Table/TableChartController.php index 82bb1c1138..51d84a73e1 100644 --- a/libraries/classes/Controllers/Table/TableChartController.php +++ b/libraries/classes/Controllers/Table/TableChartController.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin\Controllers */ +declare(strict_types=1); + namespace PhpMyAdmin\Controllers\Table; use PhpMyAdmin\Controllers\TableController; diff --git a/libraries/classes/Controllers/Table/TableGisVisualizationController.php b/libraries/classes/Controllers/Table/TableGisVisualizationController.php index 69a9a2a5ae..4e612d3794 100644 --- a/libraries/classes/Controllers/Table/TableGisVisualizationController.php +++ b/libraries/classes/Controllers/Table/TableGisVisualizationController.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin\Controllers */ +declare(strict_types=1); + namespace PhpMyAdmin\Controllers\Table; use PhpMyAdmin\Controllers\TableController; diff --git a/libraries/classes/Controllers/Table/TableIndexesController.php b/libraries/classes/Controllers/Table/TableIndexesController.php index 68bddc65dd..afde49c9ae 100644 --- a/libraries/classes/Controllers/Table/TableIndexesController.php +++ b/libraries/classes/Controllers/Table/TableIndexesController.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin\Controllers */ +declare(strict_types=1); + namespace PhpMyAdmin\Controllers\Table; use PhpMyAdmin\Controllers\TableController; diff --git a/libraries/classes/Controllers/Table/TableRelationController.php b/libraries/classes/Controllers/Table/TableRelationController.php index 9a5c6dc683..0a4f3c801a 100644 --- a/libraries/classes/Controllers/Table/TableRelationController.php +++ b/libraries/classes/Controllers/Table/TableRelationController.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin\Controllers */ +declare(strict_types=1); + namespace PhpMyAdmin\Controllers\Table; use PhpMyAdmin\Controllers\TableController; diff --git a/libraries/classes/Controllers/Table/TableSearchController.php b/libraries/classes/Controllers/Table/TableSearchController.php index 9b79d46753..337e6b6b74 100644 --- a/libraries/classes/Controllers/Table/TableSearchController.php +++ b/libraries/classes/Controllers/Table/TableSearchController.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin\Controllers */ +declare(strict_types=1); + namespace PhpMyAdmin\Controllers\Table; use PhpMyAdmin\Controllers\TableController; diff --git a/libraries/classes/Controllers/Table/TableStructureController.php b/libraries/classes/Controllers/Table/TableStructureController.php index b3101eb4ca..c3a7414643 100644 --- a/libraries/classes/Controllers/Table/TableStructureController.php +++ b/libraries/classes/Controllers/Table/TableStructureController.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin\Controllers */ +declare(strict_types=1); + namespace PhpMyAdmin\Controllers\Table; use PhpMyAdmin\CentralColumns; @@ -917,7 +919,7 @@ class TableStructureController extends TableController ); // if the old column name is part of the remembered sort expression if (mb_strpos( - $sorted_col, + (string) $sorted_col, Util::backquote($_REQUEST['field_orig'][$i]) ) !== false) { // delete the whole remembered sort expression diff --git a/libraries/classes/Controllers/TableController.php b/libraries/classes/Controllers/TableController.php index 60651ab890..0aa6cf566e 100644 --- a/libraries/classes/Controllers/TableController.php +++ b/libraries/classes/Controllers/TableController.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin\Controllers */ +declare(strict_types=1); + namespace PhpMyAdmin\Controllers; /** From 764f7a7ddecdeb36d1e07053c2ea830ff42f9b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Mon, 14 May 2018 22:25:22 -0300 Subject: [PATCH 4/5] Enable strict mode in Database 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/Database/DatabaseList.php | 2 ++ libraries/classes/Database/Designer.php | 2 ++ libraries/classes/Database/Designer/Common.php | 4 +++- libraries/classes/Database/MultiTableQuery.php | 2 ++ libraries/classes/Database/Qbe.php | 2 ++ libraries/classes/Database/Search.php | 2 ++ 6 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libraries/classes/Database/DatabaseList.php b/libraries/classes/Database/DatabaseList.php index cc383eec77..3215866853 100644 --- a/libraries/classes/Database/DatabaseList.php +++ b/libraries/classes/Database/DatabaseList.php @@ -6,6 +6,8 @@ * @package PhpMyAdmin * */ +declare(strict_types=1); + namespace PhpMyAdmin\Database; use PhpMyAdmin\ListDatabase; diff --git a/libraries/classes/Database/Designer.php b/libraries/classes/Database/Designer.php index 185f35cc37..c0cec8f68c 100644 --- a/libraries/classes/Database/Designer.php +++ b/libraries/classes/Database/Designer.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin\Database; use PhpMyAdmin\DatabaseInterface; diff --git a/libraries/classes/Database/Designer/Common.php b/libraries/classes/Database/Designer/Common.php index 45a9cf403a..51903ce0a1 100644 --- a/libraries/classes/Database/Designer/Common.php +++ b/libraries/classes/Database/Designer/Common.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin-Designer */ +declare(strict_types=1); + namespace PhpMyAdmin\Database\Designer; use PhpMyAdmin\DatabaseInterface; @@ -75,7 +77,7 @@ class Common ); $GLOBALS['designer']['TABLE_TYPE'][$i] = mb_strtoupper( - $one_table['ENGINE'] + (string) $one_table['ENGINE'] ); $DF = $this->relation->getDisplayField($GLOBALS['db'], $one_table['TABLE_NAME']); diff --git a/libraries/classes/Database/MultiTableQuery.php b/libraries/classes/Database/MultiTableQuery.php index a1b1f745db..a8c491ce6e 100644 --- a/libraries/classes/Database/MultiTableQuery.php +++ b/libraries/classes/Database/MultiTableQuery.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin\Database; use PhpMyAdmin\DatabaseInterface; diff --git a/libraries/classes/Database/Qbe.php b/libraries/classes/Database/Qbe.php index e2f326ce29..7c03cb5019 100644 --- a/libraries/classes/Database/Qbe.php +++ b/libraries/classes/Database/Qbe.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin\Database; use PhpMyAdmin\Core; diff --git a/libraries/classes/Database/Search.php b/libraries/classes/Database/Search.php index 23db54359e..903dbed300 100644 --- a/libraries/classes/Database/Search.php +++ b/libraries/classes/Database/Search.php @@ -5,6 +5,8 @@ * * @package PhpMyAdmin */ +declare(strict_types=1); + namespace PhpMyAdmin\Database; use PhpMyAdmin\Template; From aa8ab162a4481b9c8bbaefa313ed06614d7496b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Tue, 15 May 2018 01:36:23 -0300 Subject: [PATCH 5/5] Enable strict mode in Dbi 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/Dbi/DbiDummy.php | 2 ++ libraries/classes/Dbi/DbiExtension.php | 2 ++ libraries/classes/Dbi/DbiMysqli.php | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libraries/classes/Dbi/DbiDummy.php b/libraries/classes/Dbi/DbiDummy.php index 35cd9a0e3c..2614b26a0f 100644 --- a/libraries/classes/Dbi/DbiDummy.php +++ b/libraries/classes/Dbi/DbiDummy.php @@ -10,6 +10,8 @@ * @package PhpMyAdmin-DBI * @subpackage Dummy */ +declare(strict_types=1); + namespace PhpMyAdmin\Dbi; require_once 'libraries/dbi/dbi_dummy.inc.php'; diff --git a/libraries/classes/Dbi/DbiExtension.php b/libraries/classes/Dbi/DbiExtension.php index b1b9ffae6c..27787b695e 100644 --- a/libraries/classes/Dbi/DbiExtension.php +++ b/libraries/classes/Dbi/DbiExtension.php @@ -4,6 +4,8 @@ * * @package PhpMyAdmin-DBI */ +declare(strict_types=1); + namespace PhpMyAdmin\Dbi; /** diff --git a/libraries/classes/Dbi/DbiMysqli.php b/libraries/classes/Dbi/DbiMysqli.php index d53efd878e..616e5e3378 100644 --- a/libraries/classes/Dbi/DbiMysqli.php +++ b/libraries/classes/Dbi/DbiMysqli.php @@ -6,6 +6,8 @@ * @package PhpMyAdmin-DBI * @subpackage MySQLi */ +declare(strict_types=1); + namespace PhpMyAdmin\Dbi; use PhpMyAdmin\DatabaseInterface; @@ -112,7 +114,7 @@ class DbiMysqli implements DbiExtension $password, '', $server['port'], - $server['socket'], + (string) $server['socket'], $client_flags );