Merge pull request #14290 from mauriciofauth/strict-types

Enable strict mode in some classes
This commit is contained in:
Maurício Meneghini Fauth 2018-05-15 03:30:57 -03:00 committed by GitHub
commit c8bfcb7fb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
139 changed files with 396 additions and 117 deletions

View File

@ -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));
}

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\DatabaseInterface;

View File

@ -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 .= '<input type="hidden" name="rownumber" value="'
. htmlspecialchars($_REQUEST['rownumber']) . '" />';
. htmlspecialchars((string) $_REQUEST['rownumber']) . '" />';
}
$filter_value = (isset($_REQUEST['foreign_filter'])
? htmlspecialchars($_REQUEST['foreign_filter'])

View File

@ -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,
)

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\DatabaseInterface;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\DatabaseInterface;

View File

@ -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;
}
/**

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config;
use PhpMyAdmin\Config;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config;
use PhpMyAdmin\Sanitize;

View File

@ -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;
}

View File

@ -12,6 +12,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config;
use PhpMyAdmin\Config\ConfigFile;

View File

@ -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 .= '<input type="number" ' . $name_id . $field_class
. ' value="' . htmlspecialchars($value) . '" />';
. ' value="' . htmlspecialchars((string) $value) . '" />';
break;
case 'checkbox':
$htmlOutput .= '<span' . $field_class . '><input type="checkbox" ' . $name_id
@ -283,8 +285,8 @@ class FormDisplayTemplate
}
// escape if necessary
if ($escape) {
$display = htmlspecialchars($opt_value);
$display_value = htmlspecialchars($opt_value_key);
$display = htmlspecialchars((string) $opt_value);
$display_value = htmlspecialchars((string) $opt_value_key);
} else {
$display = $opt_value;
$display_value = $opt_value_key;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms;
use PhpMyAdmin\Config\ConfigFile;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms;
use PhpMyAdmin\Config\ConfigFile;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\Page;
use PhpMyAdmin\Config\Forms\BaseForm;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\Page;
use PhpMyAdmin\Config\Forms\BaseForm;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\Page;
use PhpMyAdmin\Config\Forms\BaseForm;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\Page;
class ExportForm extends \PhpMyAdmin\Config\Forms\User\ExportForm

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\Page;
class ImportForm extends \PhpMyAdmin\Config\Forms\User\ImportForm

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\Page;
class NaviForm extends \PhpMyAdmin\Config\Forms\User\NaviForm

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\Page;
use PhpMyAdmin\Config\Forms\BaseFormList;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\Page;
class SqlForm extends \PhpMyAdmin\Config\Forms\User\SqlForm

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\Page;
use PhpMyAdmin\Config\Forms\BaseForm;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\Setup;
use PhpMyAdmin\Config\Forms\BaseForm;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\Setup;
class ExportForm extends \PhpMyAdmin\Config\Forms\User\ExportForm

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\Setup;
class FeaturesForm extends \PhpMyAdmin\Config\Forms\User\FeaturesForm

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\Setup;
class ImportForm extends \PhpMyAdmin\Config\Forms\User\ImportForm

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\Setup;
class MainForm extends \PhpMyAdmin\Config\Forms\User\MainForm

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\Setup;
class NaviForm extends \PhpMyAdmin\Config\Forms\User\NaviForm

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\Setup;
use PhpMyAdmin\Config\Forms\BaseForm;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\Setup;
use PhpMyAdmin\Config\Forms\BaseFormList;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\Setup;
class SqlForm extends \PhpMyAdmin\Config\Forms\User\SqlForm

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\User;
use PhpMyAdmin\Config\Forms\BaseForm;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\User;
use PhpMyAdmin\Config\Forms\BaseForm;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\User;
use PhpMyAdmin\Config\Forms\BaseForm;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\User;
use PhpMyAdmin\Config\Forms\BaseForm;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\User;
use PhpMyAdmin\Config\Forms\BaseForm;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\User;
use PhpMyAdmin\Config\Forms\BaseForm;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config\Forms\User;
use PhpMyAdmin\Config\Forms\BaseFormList;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config;
use PhpMyAdmin\Config\ConfigFile;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config;
use PhpMyAdmin\Config\ConfigFile;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Config;
use PhpMyAdmin\Config\ConfigFile;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\Bookmark;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin\Controllers
*/
declare(strict_types=1);
namespace PhpMyAdmin\Controllers;
use PhpMyAdmin\DatabaseInterface;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin\Controllers
*/
declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Database;
use PhpMyAdmin\Charsets;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin\Controllers
*/
declare(strict_types=1);
namespace PhpMyAdmin\Controllers;
/**

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin\Controllers
*/
declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Server;
use PhpMyAdmin\Controllers\Controller;

View File

@ -6,6 +6,7 @@
*
* @package PhpMyAdmin\Controllers
*/
declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Server;

View File

@ -6,6 +6,7 @@
*
* @package PhpMyAdmin\Controllers
*/
declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Server;

View File

@ -6,6 +6,7 @@
*
* @package PhpMyAdmin\Controllers
*/
declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Server;

View File

@ -6,6 +6,7 @@
*
* @package PhpMyAdmin\Controllers
*/
declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Server;

View File

@ -6,6 +6,7 @@
*
* @package PhpMyAdmin\Controllers
*/
declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Server;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin\Controllers
*/
declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Table;
use PhpMyAdmin\Controllers\TableController;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin\Controllers
*/
declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Table;
use PhpMyAdmin\Controllers\TableController;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin\Controllers
*/
declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Table;
use PhpMyAdmin\Controllers\TableController;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin\Controllers
*/
declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Table;
use PhpMyAdmin\Controllers\TableController;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin\Controllers
*/
declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Table;
use PhpMyAdmin\Controllers\TableController;

View File

@ -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

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin\Controllers
*/
declare(strict_types=1);
namespace PhpMyAdmin\Controllers;
/**

View File

@ -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

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\Core;

View File

@ -6,6 +6,8 @@
* @package PhpMyAdmin
*
*/
declare(strict_types=1);
namespace PhpMyAdmin\Database;
use PhpMyAdmin\ListDatabase;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Database;
use PhpMyAdmin\DatabaseInterface;

View File

@ -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']);

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Database;
use PhpMyAdmin\DatabaseInterface;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Database;
use PhpMyAdmin\Core;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Database;
use PhpMyAdmin\Template;

View File

@ -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;

View File

@ -10,6 +10,8 @@
* @package PhpMyAdmin-DBI
* @subpackage Dummy
*/
declare(strict_types=1);
namespace PhpMyAdmin\Dbi;
require_once 'libraries/dbi/dbi_dummy.inc.php';

View File

@ -4,6 +4,8 @@
*
* @package PhpMyAdmin-DBI
*/
declare(strict_types=1);
namespace PhpMyAdmin\Dbi;
/**

View File

@ -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
);

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\Config\ConfigFile;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use Exception;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\Error;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\Relation;

View File

@ -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 .= '&amp;' . urlencode($name) . '=' . urlencode($value);
$back_button .= '&amp;' . urlencode((string) $name) . '=' . urlencode((string) $value);
}
}
$back_button .= '&amp;repopulate=1">' . __('Back') . '</a> ]</p>';

View File

@ -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());
}
/**

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
/**

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
/**

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\Config;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\Config;

View File

@ -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';
}

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\IndexColumn;
@ -803,10 +805,10 @@ class Index
}
$r .= '</td>';
$r .= '<td>'
. htmlspecialchars($column->getCardinality())
. htmlspecialchars((string) $column->getCardinality())
. '</td>';
$r .= '<td>'
. htmlspecialchars($column->getCollation())
. htmlspecialchars((string) $column->getCollation())
. '</td>';
$r .= '<td>'
. htmlspecialchars($column->getNull(true))

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
/**

View File

@ -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';

View File

@ -6,6 +6,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\Core;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\LanguageManager;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\Core;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\SqlParser\Lexer;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use ArrayObject;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\ListAbstract;

View File

@ -7,6 +7,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\Core;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\DatabaseInterface;

View File

@ -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);
}
/**

View File

@ -6,6 +6,8 @@
* @package PhpMyAdmin
* @todo Maybe we could try to use fileinfo module if loaded
*/
declare(strict_types=1);
namespace PhpMyAdmin;
/**

View File

@ -7,6 +7,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\Operations;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\Index;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\ZipExtension;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\Charsets;

View File

@ -4,6 +4,8 @@
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin;
/**

Some files were not shown because too many files have changed in this diff Show More