Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Desportes <williamdes@wdes.fr>2018-10-07 23:30:09 +0300
committerWilliam Desportes <williamdes@wdes.fr>2018-11-25 15:57:57 +0300
commitcc2665121d8931b702c08ff12182cde9c452ee43 (patch)
treeaaed934f64b2f9254cf2eab81d206baacb652c6d /libraries
parentca8a424ed8d7035ae87918a3378a5d4eed08b0b6 (diff)
phpstan level 2 - fixes
Signed-off-by: William Desportes <williamdes@wdes.fr>
Diffstat (limited to 'libraries')
-rw-r--r--libraries/classes/CentralColumns.php4
-rw-r--r--libraries/classes/Config.php2
-rw-r--r--libraries/classes/Config/PageSettings.php2
-rw-r--r--libraries/classes/Controllers/Table/TableChartController.php4
-rw-r--r--libraries/classes/Dbi/DbiMysqli.php49
-rw-r--r--libraries/classes/Di/ReflectorItem.php7
-rw-r--r--libraries/classes/Export.php4
-rw-r--r--libraries/classes/Gis/GisFactory.php3
-rw-r--r--libraries/classes/Gis/GisGeometryCollection.php3
-rw-r--r--libraries/classes/InsertEdit.php2
-rw-r--r--libraries/classes/Plugins/Auth/AuthenticationCookie.php7
-rw-r--r--libraries/classes/Plugins/Schema/Dia/RelationStatsDia.php14
-rw-r--r--libraries/classes/Server/Privileges.php4
-rw-r--r--libraries/classes/SysInfo.php4
-rw-r--r--libraries/classes/Table.php2
-rw-r--r--libraries/classes/ThemeManager.php6
-rw-r--r--libraries/classes/Tracking.php2
-rw-r--r--libraries/classes/Util.php2
18 files changed, 66 insertions, 55 deletions
diff --git a/libraries/classes/CentralColumns.php b/libraries/classes/CentralColumns.php
index 6b24a24cf5..e4f38273fa 100644
--- a/libraries/classes/CentralColumns.php
+++ b/libraries/classes/CentralColumns.php
@@ -1048,14 +1048,14 @@ class CentralColumns
* @param int $from starting offset of first result
* @param int $num maximum number of results to return
*
- * @return array list of $num columns present in central columns list
+ * @return int count of $num columns present in central columns list
* starting at offset $from for the given database
*/
public function getColumnsCount(string $db, int $from = 0, int $num = 25): int
{
$cfgCentralColumns = $this->getParams();
if (empty($cfgCentralColumns)) {
- return [];
+ return 0;
}
$pmadb = $cfgCentralColumns['db'];
$this->dbi->selectDb($pmadb, DatabaseInterface::CONNECT_CONTROL);
diff --git a/libraries/classes/Config.php b/libraries/classes/Config.php
index 8c4b562d05..09dbac723c 100644
--- a/libraries/classes/Config.php
+++ b/libraries/classes/Config.php
@@ -718,7 +718,7 @@ class Config
}
} while ($dataline != '');
$message = trim(implode(' ', $commit));
- } elseif (isset($commit_json) && isset($commit_json->author) && isset($commit_json->committer)) {
+ } elseif (isset($commit_json) && isset($commit_json->author) && isset($commit_json->committer) && isset($commit_json->message)) {
$author = [
'name' => $commit_json->author->name,
'email' => $commit_json->author->email,
diff --git a/libraries/classes/Config/PageSettings.php b/libraries/classes/Config/PageSettings.php
index ef21cb0101..a821536852 100644
--- a/libraries/classes/Config/PageSettings.php
+++ b/libraries/classes/Config/PageSettings.php
@@ -113,7 +113,7 @@ class PageSettings
// reload page
$response = Response::getInstance();
Core::sendHeaderLocation(
- $response->getFooter()->getSelfUrl('unencoded')
+ $response->getFooter()->getSelfUrl()
);
exit();
} else {
diff --git a/libraries/classes/Controllers/Table/TableChartController.php b/libraries/classes/Controllers/Table/TableChartController.php
index 4abceb090b..f063c2e007 100644
--- a/libraries/classes/Controllers/Table/TableChartController.php
+++ b/libraries/classes/Controllers/Table/TableChartController.php
@@ -13,6 +13,7 @@ use PhpMyAdmin\Controllers\TableController;
use PhpMyAdmin\Message;
use PhpMyAdmin\Response;
use PhpMyAdmin\SqlParser\Components\Limit;
+use PhpMyAdmin\SqlParser\Statements\SelectStatement;
use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\Table;
use PhpMyAdmin\Template;
@@ -209,6 +210,9 @@ class TableChartController extends TableController
}
$parser = new Parser($this->sql_query);
+ /**
+ * @var SelectStatement $statement
+ */
$statement = $parser->statements[0];
if (empty($statement->limit)) {
$statement->limit = new Limit(
diff --git a/libraries/classes/Dbi/DbiMysqli.php b/libraries/classes/Dbi/DbiMysqli.php
index 1ec1a9187c..b5e6e7a5b1 100644
--- a/libraries/classes/Dbi/DbiMysqli.php
+++ b/libraries/classes/Dbi/DbiMysqli.php
@@ -498,6 +498,7 @@ class DbiMysqli implements DbiExtension
*/
public function fieldLen($result, $i)
{
+ /** @var \stdClass $fieldDefinition */
$fieldDefinition = $result->fetch_field_direct($i);
if ($fieldDefinition !== false) {
return $fieldDefinition->length;
@@ -515,6 +516,7 @@ class DbiMysqli implements DbiExtension
*/
public function fieldName($result, $i)
{
+ /** @var \stdClass $fieldDefinition */
$fieldDefinition = $result->fetch_field_direct($i);
if ($fieldDefinition !== false) {
return $fieldDefinition->name;
@@ -532,30 +534,35 @@ class DbiMysqli implements DbiExtension
*/
public function fieldFlags($result, $i)
{
+ /** @var \stdClass $fieldDefinition */
$fieldDefinition = $result->fetch_field_direct($i);
- $type = $fieldDefinition->type;
- $charsetNumber = $fieldDefinition->charsetnr;
- $fieldDefinitionFlags = $fieldDefinition->flags;
- $flags = [];
- foreach (self::$pma_mysqli_flag_names as $flag => $name) {
- if ($fieldDefinitionFlags & $flag) {
- $flags[] = $name;
+ if ($fieldDefinition !== false) {
+ $type = $fieldDefinition->type;
+ $charsetNumber = $fieldDefinition->charsetnr;
+ $fieldDefinitionFlags = $fieldDefinition->flags;
+ $flags = [];
+ foreach (self::$pma_mysqli_flag_names as $flag => $name) {
+ if ($fieldDefinitionFlags & $flag) {
+ $flags[] = $name;
+ }
}
+ // See https://dev.mysql.com/doc/refman/6.0/en/c-api-datatypes.html:
+ // to determine if a string is binary, we should not use MYSQLI_BINARY_FLAG
+ // but instead the charsetnr member of the MYSQL_FIELD
+ // structure. Watch out: some types like DATE returns 63 in charsetnr
+ // so we have to check also the type.
+ // Unfortunately there is no equivalent in the mysql extension.
+ if (($type == MYSQLI_TYPE_TINY_BLOB || $type == MYSQLI_TYPE_BLOB
+ || $type == MYSQLI_TYPE_MEDIUM_BLOB || $type == MYSQLI_TYPE_LONG_BLOB
+ || $type == MYSQLI_TYPE_VAR_STRING || $type == MYSQLI_TYPE_STRING)
+ && 63 == $charsetNumber
+ ) {
+ $flags[] = 'binary';
+ }
+ return implode(' ', $flags);
+ } else {
+ return '';
}
- // See https://dev.mysql.com/doc/refman/6.0/en/c-api-datatypes.html:
- // to determine if a string is binary, we should not use MYSQLI_BINARY_FLAG
- // but instead the charsetnr member of the MYSQL_FIELD
- // structure. Watch out: some types like DATE returns 63 in charsetnr
- // so we have to check also the type.
- // Unfortunately there is no equivalent in the mysql extension.
- if (($type == MYSQLI_TYPE_TINY_BLOB || $type == MYSQLI_TYPE_BLOB
- || $type == MYSQLI_TYPE_MEDIUM_BLOB || $type == MYSQLI_TYPE_LONG_BLOB
- || $type == MYSQLI_TYPE_VAR_STRING || $type == MYSQLI_TYPE_STRING)
- && 63 == $charsetNumber
- ) {
- $flags[] = 'binary';
- }
- return implode(' ', $flags);
}
/**
diff --git a/libraries/classes/Di/ReflectorItem.php b/libraries/classes/Di/ReflectorItem.php
index 8277543076..0071816511 100644
--- a/libraries/classes/Di/ReflectorItem.php
+++ b/libraries/classes/Di/ReflectorItem.php
@@ -20,7 +20,10 @@ abstract class ReflectorItem implements Item
/** @var Container */
private $_container;
- /** @var \Reflector */
+ /**
+ * A \Reflector
+ * @var \ReflectionClass|\ReflectionMethod|\ReflectionFunction
+ */
private $_reflector;
/**
@@ -74,7 +77,7 @@ abstract class ReflectorItem implements Item
* @param \ReflectionParameter[] $required Arguments
* @param array $params Parameters
*
-*@return array
+ * @return array
*/
private function _resolveArgs($required, array $params = [])
{
diff --git a/libraries/classes/Export.php b/libraries/classes/Export.php
index 4022db6942..735d0cfb13 100644
--- a/libraries/classes/Export.php
+++ b/libraries/classes/Export.php
@@ -1202,7 +1202,7 @@ class Export
$export_type = Core::securePath($export_type);
// get the specific plugin
- /* @var $export_plugin SchemaPlugin */
+ /** @var \PhpMyAdmin\Plugins\SchemaPlugin $export_plugin */
$export_plugin = Plugins::getPlugin(
"schema",
$export_type,
@@ -1210,7 +1210,7 @@ class Export
);
// Check schema export type
- if (! isset($export_plugin)) {
+ if (is_null($export_plugin) || ! is_object($export_plugin)) {
Core::fatalError(__('Bad type!'));
}
diff --git a/libraries/classes/Gis/GisFactory.php b/libraries/classes/Gis/GisFactory.php
index bbf225dcda..353d7e62bf 100644
--- a/libraries/classes/Gis/GisFactory.php
+++ b/libraries/classes/Gis/GisFactory.php
@@ -21,8 +21,7 @@ class GisFactory
*
* @param string $type type of the geometric object
*
- * @return GisGeometry the singleton instance of geometric class
- * of the given type
+ * @return GisMultiPolygon|GisPolygon|GisMultiPoint|GisPoint|GisMultiLineString|GisLineString|GisGeometryCollection|false the singleton instance of geometric class of the given type
*
* @access public
* @static
diff --git a/libraries/classes/Gis/GisGeometryCollection.php b/libraries/classes/Gis/GisGeometryCollection.php
index 618fc13989..a777ae4931 100644
--- a/libraries/classes/Gis/GisGeometryCollection.php
+++ b/libraries/classes/Gis/GisGeometryCollection.php
@@ -404,6 +404,9 @@ class GisGeometryCollection extends GisGeometry
continue;
}
$type = mb_substr($sub_part, 0, $type_pos);
+ /**
+ * @var GisMultiPolygon|GisPolygon|GisMultiPoint|GisPoint|GisMultiLineString|GisLineString $gis_obj
+ */
$gis_obj = GisFactory::factory($type);
if (!$gis_obj) {
continue;
diff --git a/libraries/classes/InsertEdit.php b/libraries/classes/InsertEdit.php
index c3ee295191..deca71156c 100644
--- a/libraries/classes/InsertEdit.php
+++ b/libraries/classes/InsertEdit.php
@@ -2413,7 +2413,7 @@ class InsertEdit
DatabaseInterface::QUERY_STORE
);
if ($dispresult && $this->dbi->numRows($dispresult) > 0) {
- list($dispval) = $this->dbi->fetchRow($dispresult, 0);
+ list($dispval) = $this->dbi->fetchRow($dispresult);
} else {
$dispval = '';
}
diff --git a/libraries/classes/Plugins/Auth/AuthenticationCookie.php b/libraries/classes/Plugins/Auth/AuthenticationCookie.php
index 459eaf9e2a..c278431759 100644
--- a/libraries/classes/Plugins/Auth/AuthenticationCookie.php
+++ b/libraries/classes/Plugins/Auth/AuthenticationCookie.php
@@ -554,12 +554,7 @@ class AuthenticationCookie extends AuthenticationPlugin
'new_token',
$_SESSION[' PMA_token ']
);
- if($user_changed) {
- $response->addJSON(
- 'user_changed',
- 1
- );
- }
+
if (! defined('TESTSUITE')) {
exit;
} else {
diff --git a/libraries/classes/Plugins/Schema/Dia/RelationStatsDia.php b/libraries/classes/Plugins/Schema/Dia/RelationStatsDia.php
index 8e17531b48..c00fd34e41 100644
--- a/libraries/classes/Plugins/Schema/Dia/RelationStatsDia.php
+++ b/libraries/classes/Plugins/Schema/Dia/RelationStatsDia.php
@@ -40,11 +40,11 @@ class RelationStatsDia
/**
* The "PhpMyAdmin\Plugins\Schema\Dia\RelationStatsDia" constructor
*
- * @param Dia $diagram The DIA diagram
- * @param string $master_table The master table name
- * @param string $master_field The relation field in the master table
- * @param string $foreign_table The foreign table name
- * @param string $foreign_field The relation field in the foreign table
+ * @param Dia $diagram The DIA diagram
+ * @param TableStatsDia $master_table The master table name
+ * @param string $master_field The relation field in the master table
+ * @param TableStatsDia $foreign_table The foreign table name
+ * @param string $foreign_field The relation field in the foreign table
*
* @see Relation_Stats_Dia::_getXy
*/
@@ -75,8 +75,8 @@ class RelationStatsDia
* then determines its left and right connection
* points.
*
- * @param string $table The current table name
- * @param string $column The relation column name
+ * @param TableStatsDia $table The current table name
+ * @param string $column The relation column name
*
* @return array Table right,left connection points and key position
*
diff --git a/libraries/classes/Server/Privileges.php b/libraries/classes/Server/Privileges.php
index 3eb0806b7e..370bf34d34 100644
--- a/libraries/classes/Server/Privileges.php
+++ b/libraries/classes/Server/Privileges.php
@@ -1897,7 +1897,7 @@ class Privileges
);
// Table 'mysql'.'user' may not exist for some previous
// versions of MySQL - in that case consider fallback value
- if (isset($row) && $row) {
+ if (is_array($row) && isset($row['plugin'])) {
$authentication_plugin = $row['plugin'];
}
} elseif ($mode == 'change') {
@@ -1907,7 +1907,7 @@ class Privileges
'SELECT `plugin` FROM `mysql`.`user` WHERE '
. '`User` = "' . $username . '" AND `Host` = "' . $hostname . '"'
);
- if (isset($row) && $row && ! empty($row['plugin'])) {
+ if (is_array($row) && isset($row['plugin'])) {
$authentication_plugin = $row['plugin'];
}
} elseif ($serverVersion >= 50702) {
diff --git a/libraries/classes/SysInfo.php b/libraries/classes/SysInfo.php
index 7501b059bf..a474f38f66 100644
--- a/libraries/classes/SysInfo.php
+++ b/libraries/classes/SysInfo.php
@@ -45,7 +45,7 @@ class SysInfo
/**
* Gets sysinfo class mathing current OS
*
- * @return PhpMyAdmin\SysInfoBase|mixed sysinfo class
+ * @return SysInfoBase sysinfo class
*/
public static function get()
{
@@ -54,7 +54,7 @@ class SysInfo
if (in_array($php_os, $supported)) {
$class_name = 'PhpMyAdmin\SysInfo' . $php_os;
- /** @var PhpMyAdmin\SysInfoBase $ret */
+ /** @var SysInfoBase $ret */
$ret = new $class_name();
if ($ret->supported()) {
return $ret;
diff --git a/libraries/classes/Table.php b/libraries/classes/Table.php
index 8d42053c49..92335e0f82 100644
--- a/libraries/classes/Table.php
+++ b/libraries/classes/Table.php
@@ -1005,7 +1005,7 @@ class Table
/**
* Instance used for exporting the current structure of the table.
*
- * @var PhpMyAdmin\Plugins\Export\ExportSql
+ * @var ExportSql $export_sql_plugin
*/
$export_sql_plugin = Plugins::getPlugin(
"export",
diff --git a/libraries/classes/ThemeManager.php b/libraries/classes/ThemeManager.php
index d2649d16da..ed1318b5f1 100644
--- a/libraries/classes/ThemeManager.php
+++ b/libraries/classes/ThemeManager.php
@@ -119,11 +119,11 @@ class ThemeManager
}
/**
- * Returns the singleton Response object
+ * Returns the singleton ThemeManager object
*
- * @return ThemeManager object
+ * @return ThemeManager The instance
*/
- public static function getInstance()
+ public static function getInstance(): ThemeManager
{
if (empty(self::$_instance)) {
self::$_instance = new ThemeManager();
diff --git a/libraries/classes/Tracking.php b/libraries/classes/Tracking.php
index 912240d3d4..90f8e03e86 100644
--- a/libraries/classes/Tracking.php
+++ b/libraries/classes/Tracking.php
@@ -1170,7 +1170,7 @@ class Tracking
* Get HTML for tracked and untracked tables
*
* @param string $db current database
- * @param array $requestDb $_REQUEST['db']
+ * @param string $requestDb $_REQUEST['db']
* @param string $urlQuery url query string
* @param string $pmaThemeImage path to theme's image folder
* @param string $textDir text direction
diff --git a/libraries/classes/Util.php b/libraries/classes/Util.php
index fd17626050..b16acd1c32 100644
--- a/libraries/classes/Util.php
+++ b/libraries/classes/Util.php
@@ -1949,7 +1949,7 @@ class Util
*
* @param resource $handle current query result
* @param integer $fields_cnt number of fields
- * @param array $fields_meta meta information about fields
+ * @param \stdClass[] $fields_meta meta information about fields
* @param array $row current row
* @param boolean $force_unique generate condition only on pk
* or unique