Upgrade PHPStan to version 0.12.0

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
Maurício Meneghini Fauth 2019-12-07 20:26:39 -03:00
parent f97d957f00
commit 351e34ecf5
16 changed files with 97 additions and 48 deletions

View File

@ -86,8 +86,8 @@
"facebook/webdriver": "^1.7.1",
"phpmyadmin/coding-standard": "^1.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.11.5",
"phpstan/phpstan-phpunit": "^0.11.2",
"phpstan/phpstan": "^0.12.0",
"phpstan/phpstan-phpunit": "^0.12.0",
"phpunit/phpunit": "^7.5 || ^8.0",
"pragmarx/google2fa-qrcode": "^1.0.1",
"samyoul/u2f-php-server": "^1.1",

View File

@ -773,6 +773,7 @@ class Config
*/
public function loadDefaults(): bool
{
/** @var array<string,mixed> $cfg */
$cfg = [];
if (! @file_exists($this->default_source)) {
$this->error_config_default_file = true;

View File

@ -107,7 +107,6 @@ class Console
} else {
$welcomeMessage = __('No bookmarks');
}
unset($count_bookmarks, $private_message, $shared_message);
return $template->render('console/bookmark_content', [
'welcome_message' => $welcomeMessage,
'bookmarks' => $bookmarks,

View File

@ -1035,6 +1035,7 @@ class StructureController extends AbstractController
}
if ($this->isShowStats) {
/** @var int $tblsize */
$tblsize = $current_table['Data_length']
+ $current_table['Index_length'];
$sum_size += $tblsize;
@ -1093,6 +1094,7 @@ class StructureController extends AbstractController
}
if ($this->isShowStats) {
/** @var int $tblsize */
$tblsize = $current_table['Data_length']
+ $current_table['Index_length'];
$sum_size += $tblsize;

View File

@ -234,8 +234,8 @@ class SearchController extends AbstractController
}
/**
* No selection criteria received -> display the selection form
*/
* No selection criteria received -> display the selection form
*/
if (! isset($_POST['columnsToDisplay'])
&& ! isset($_POST['displayAllColumns'])
) {
@ -264,10 +264,8 @@ class SearchController extends AbstractController
);
/**
* Handle AJAX request for data row on point select
*
* @var boolean Object containing parameters for the POST request
*/
* Handle AJAX request for data row on point select
*/
if (isset($_POST['get_data_row'])
&& $_POST['get_data_row'] == true
) {
@ -276,11 +274,9 @@ class SearchController extends AbstractController
return;
}
/**
* Handle AJAX request for changing field information
* (value,collation,operators,field values) in input form
*
* @var boolean Object containing parameters for the POST request
*/
* Handle AJAX request for changing field information
* (value,collation,operators,field values) in input form
*/
if (isset($_POST['change_tbl_info'])
&& $_POST['change_tbl_info'] == true
) {

View File

@ -4116,11 +4116,9 @@ class Results
array $analyzed_sql_results,
$is_limited_display = false
) {
/**
* The statement this table is built for.
* @var SelectStatement
*/
// The statement this table is built for.
if (isset($analyzed_sql_results['statement'])) {
/** @var SelectStatement $statement */
$statement = $analyzed_sql_results['statement'];
} else {
$statement = null;

View File

@ -521,6 +521,7 @@ class GisVisualization
} elseif ($format == 'ol') {
return $this->asOl();
}
return '';
}
/**

View File

@ -364,5 +364,6 @@ abstract class AuthenticationPlugin
if (! defined('TESTSUITE')) {
exit;
}
return;
}
}

View File

@ -218,6 +218,7 @@ abstract class ExportPlugin
*/
public function getTableDefStandIn($db, $view, $crlf, $aliases = [])
{
return '';
}
/**
@ -230,6 +231,7 @@ abstract class ExportPlugin
*/
protected function getTriggers($db, $table)
{
return '';
}
/**

View File

@ -223,5 +223,6 @@ class RelationStatsDia
</dia:connections>
</dia:object>'
);
return;
}
}

View File

@ -786,8 +786,6 @@ class PdfRelationSchema extends ExportRelationSchema
&& isset($this->diagram->PMA_links['doc'][$foreigner['foreign_table']][$foreigner['foreign_field']])
) {
$links[6] = $this->diagram->PMA_links['doc'][$foreigner['foreign_table']][$foreigner['foreign_field']];
} else {
unset($links[6]);
}
$this->diagram->row($diagram_row, $links);
} // end foreach

View File

@ -434,7 +434,6 @@ unset(
$warning_messages,
$total_affected_rows,
$last_messages,
$last_message,
$row_skipped,
$insert_errors
);
@ -454,11 +453,11 @@ if ($response->isAjax() && ! isset($_POST['ajax_page_request'])) {
if (isset($_POST['rel_fields_list']) && $_POST['rel_fields_list'] != '') {
$map = $relation->getForeigners($db, $table, '', 'both');
/** @var array<int,array> $relation_fields */
$relation_fields = [];
parse_str($_POST['rel_fields_list'], $relation_fields);
// loop for each relation cell
/** @var array $relation_fields */
foreach ($relation_fields as $cell_index => $curr_rel_field) {
foreach ($curr_rel_field as $relation_field => $relation_field_value) {
$where_comparison = "='" . $relation_field_value . "'";

View File

@ -44,7 +44,7 @@ foreach ($request_params as $one_request_param) {
}
$response = Response::getInstance();
global $db, $table, $clause_is_unique, $from_prefix, $goto,
global $db, $table, $clause_is_unique, $from_prefix, $goto, $message,
$mult_btn, $original_sql_query, $query_type, $reload,
$selected, $selected_fld, $selected_recent_table, $sql_query,
$submit_mult, $table_type, $to_prefix, $url_query, $pmaThemeImage;

67
phpstan-baseline.neon Normal file
View File

@ -0,0 +1,67 @@
parameters:
ignoreErrors:
-
message: "#^Instantiated class PhpMyAdmin\\\\Config\\\\Forms\\\\BaseForm is abstract\\.$#"
count: 1
path: libraries/classes/Controllers/Setup/FormController.php
-
message: "#^Function uploadprogress_get_info not found\\.$#"
count: 1
path: libraries/classes/Plugins/Import/Upload/UploadProgress.php
-
message: "#^Instantiated class COM not found\\.$#"
count: 1
path: libraries/classes/SysInfoWINNT.php
-
message: "#^Call to method ConnectServer\\(\\) on an unknown class COM\\.$#"
count: 1
path: libraries/classes/SysInfoWINNT.php
-
message: "#^Variable \\$http_response_header in isset\\(\\) always exists and is not nullable\\.$#"
count: 1
path: libraries/classes/Utils/HttpRequest.php
-
message: "#^Method PhpMyAdmin\\\\Controllers\\\\Server\\\\SqlController\\:\\:index\\(\\) invoked with 2 parameters, 0 required\\.$#"
count: 1
path: libraries/entry_points/database/sql.php
-
message: "#^Call to an undefined method PhpMyAdmin\\\\Controllers\\\\Database\\\\SearchController\\:\\:indexAction\\(\\)\\.$#"
count: 1
path: libraries/entry_points/table/find_replace.php
-
message: "#^Call to an undefined method PhpMyAdmin\\\\Controllers\\\\Database\\\\SearchController\\:\\:indexAction\\(\\)\\.$#"
count: 1
path: libraries/entry_points/table/select.php
-
message: "#^Method PhpMyAdmin\\\\Controllers\\\\Server\\\\SqlController\\:\\:index\\(\\) invoked with 2 parameters, 0 required\\.$#"
count: 1
path: libraries/entry_points/table/sql.php
-
message: "#^Call to an undefined method PhpMyAdmin\\\\Controllers\\\\Database\\\\StructureController\\:\\:indexAction\\(\\)\\.$#"
count: 1
path: libraries/entry_points/table/structure.php
-
message: "#^Call to an undefined method PhpMyAdmin\\\\Controllers\\\\Database\\\\SearchController\\:\\:indexAction\\(\\)\\.$#"
count: 1
path: libraries/entry_points/table/zoom_select.php
-
message: "#^Access to private property PhpMyAdmin\\\\DatabaseInterface&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\:\\:\\$_table_cache\\.$#"
count: 1
path: test/classes/TableTest.php
-
message: "#^Instantiated class Sami\\\\Sami not found\\.$#"
count: 1
path: test/sami-config.php

View File

@ -1,31 +1,14 @@
includes:
- phpstan-baseline.neon
parameters:
level: 2
paths:
- %rootDir%/../../../
bootstrap: %rootDir%/../../../test/bootstrap-phpstan.php
- .
bootstrap: test/bootstrap-phpstan.php
reportUnmatchedIgnoredErrors: true
inferPrivatePropertyTypeFromConstructor: true
ignoreErrors:
-
message: "#^Access to private property PhpMyAdmin\\\\DatabaseInterface&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\:\\:\\$_table_cache\\.$#"
path: %currentWorkingDirectory%/test/classes/TableTest.php
-
message: '#PhpMyAdmin\\Twig\\I18n\\NodeTrans::__construct\(\) does not call parent constructor from Twig_Extensions_Node_Trans#'
path: %currentWorkingDirectory%/libraries/classes/Twig/I18n/NodeTrans.php
-
message: '#Variable \$http_response_header in isset\(\) always exists and is not nullable#'
path: %currentWorkingDirectory%/libraries/classes/Utils/HttpRequest.php
-
message: '#Instantiated class Sami\\Sami not found#'
path: %currentWorkingDirectory%/test/sami-config.php
-
message: '#Function uploadprogress_get_info not found#'
path: %currentWorkingDirectory%/libraries/classes/Plugins/Import/Upload/UploadProgress.php
-
message: '#(Instantiated class COM not found|Call to method ConnectServer\(\) on an unknown class COM)#'
path: %currentWorkingDirectory%/libraries/classes/SysInfoWINNT.php
excludes_analyse:
- %rootDir%/../../../tmp/*
- %rootDir%/../../../vendor/*
- %rootDir%/../../../node_modules/*
- %rootDir%/../../../examples/openid.php
- tmp/*
- vendor/*
- node_modules/*
- examples/openid.php

View File

@ -394,6 +394,7 @@ class ConfigTest extends PmaTestCase
$this->object->default_source = $prevDefaultSource;
/** @var array<string,mixed> $cfg */
$cfg = [];
include $this->object->default_source;
$loadedConf = $cfg;