Fix some PHPStan level 2 errors
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
eb533f3a0d
commit
7ac1d21c70
@ -349,6 +349,7 @@ class StructureController extends AbstractController
|
||||
$db = &$this->db;
|
||||
$table = &$this->table;
|
||||
$url_params = [];
|
||||
$db_is_system_schema = false;
|
||||
include_once ROOT_PATH . 'libraries/tbl_common.inc.php';
|
||||
$this->_db_is_system_schema = $db_is_system_schema;
|
||||
$this->_url_query = Url::getCommonRaw([
|
||||
|
||||
@ -832,8 +832,7 @@ class NavigationTree
|
||||
$keySeparatorLength
|
||||
)
|
||||
);
|
||||
|
||||
if ($newChild instanceof NodeDatabase
|
||||
if ($child instanceof NodeDatabase
|
||||
&& $child->getHiddenCount() > 0
|
||||
) {
|
||||
$newChild->setHiddenCount($child->getHiddenCount());
|
||||
|
||||
@ -52,6 +52,8 @@ global $db, $table, $clause_is_unique, $from_prefix, $goto,
|
||||
$multSubmits = new MultSubmits();
|
||||
$template = new Template();
|
||||
|
||||
$action = $action ?? '';
|
||||
|
||||
/**
|
||||
* Prepares the work and runs some other scripts if required
|
||||
*/
|
||||
|
||||
@ -68,6 +68,8 @@ $form_params = [
|
||||
'db' => $db,
|
||||
];
|
||||
|
||||
$action = $action ?? '';
|
||||
|
||||
if ($action == Url::getFromRoute('/table/create')) {
|
||||
$form_params['reload'] = 1;
|
||||
} else {
|
||||
|
||||
@ -6,34 +6,17 @@ parameters:
|
||||
reportUnmatchedIgnoredErrors: true
|
||||
inferPrivatePropertyTypeFromConstructor: true
|
||||
ignoreErrors:
|
||||
- '#NodeTrans::__construct\(\) does not call parent constructor#'
|
||||
- '#PHPUnit\\Framework\\MockObject#'
|
||||
- '#Call to an undefined method PhpMyAdmin\\Navigation\\Nodes\\Node\:\:getHiddenCount#'
|
||||
- '#Variable \$http_response_header in isset\(\) always exists and is not nullable#'
|
||||
- '#Call to an undefined method PHPUnit\\Framework\\MockObject\\MockObject#'
|
||||
- '#Access to an undefined property PHPUnit\\Framework\\MockObject\\MockObject#'
|
||||
-
|
||||
message: '#Undefined variable: \$action#'
|
||||
path: %currentWorkingDirectory%/libraries/mult_submits.inc.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: '#Undefined variable: \$action#'
|
||||
path: %currentWorkingDirectory%/libraries/tbl_columns_definition_form.inc.php
|
||||
-
|
||||
message: '#Undefined variable: \$cfg#'
|
||||
path: %currentWorkingDirectory%/test/classes/ConfigTest.php
|
||||
-
|
||||
message: '#Undefined variable: \$cfg#'
|
||||
path: %currentWorkingDirectory%/test/classes/PmaTestCase.php
|
||||
-
|
||||
message: '#Undefined variable: \$cfg#'
|
||||
path: %currentWorkingDirectory%/test/bootstrap-phpstan.php
|
||||
-
|
||||
message: '#Undefined variable: \$db_is_system_schema#'
|
||||
path: %currentWorkingDirectory%/libraries/classes/Controllers/Table/StructureController.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: '#Variable \$pdo might not be defined#'
|
||||
path: %currentWorkingDirectory%/test/classes/EnvironmentTest.php
|
||||
-
|
||||
message: '#Function uploadprogress_get_info not found#'
|
||||
path: %currentWorkingDirectory%/libraries/classes/Plugins/Import/Upload/UploadProgress.php
|
||||
|
||||
@ -18,10 +18,13 @@ if (! defined('ROOT_PATH')) {
|
||||
define('PHPMYADMIN', true);
|
||||
define('TESTSUITE', true);
|
||||
|
||||
$cfg = [];
|
||||
|
||||
include_once ROOT_PATH . 'examples/signon-script.php';
|
||||
require_once ROOT_PATH . 'libraries/config.default.php';
|
||||
require_once ROOT_PATH . 'libraries/vendor_config.php';
|
||||
require_once AUTOLOAD_FILE;
|
||||
|
||||
$GLOBALS['cfg'] = $cfg;
|
||||
$GLOBALS['server'] = 0;
|
||||
$GLOBALS['PMA_Config'] = new Config();
|
||||
|
||||
@ -394,8 +394,8 @@ class ConfigTest extends PmaTestCase
|
||||
|
||||
$this->object->default_source = $prevDefaultSource;
|
||||
|
||||
$cfg = [];
|
||||
include $this->object->default_source;
|
||||
|
||||
$loadedConf = $cfg;
|
||||
unset($cfg);
|
||||
|
||||
|
||||
@ -61,9 +61,13 @@ class EnvironmentTest extends TestCase
|
||||
}
|
||||
|
||||
// Check id MySQL server is 5 version
|
||||
$serverVersion = '0.0.0';
|
||||
if (isset($pdo)) {
|
||||
$serverVersion = $pdo->getAttribute(constant('PDO::ATTR_SERVER_VERSION'));
|
||||
}
|
||||
preg_match(
|
||||
'/^(\d+)?\.(\d+)?\.(\*|\d+)/',
|
||||
$pdo->getAttribute(constant('PDO::ATTR_SERVER_VERSION')),
|
||||
$serverVersion,
|
||||
$version_parts
|
||||
);
|
||||
$this->assertEquals(5, $version_parts[1]);
|
||||
|
||||
@ -9,7 +9,7 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Tests;
|
||||
|
||||
use PhpMyAdmin\Response;
|
||||
use PHPUnit\Framework\MockObject\MockBuilder;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionProperty;
|
||||
|
||||
@ -37,6 +37,7 @@ class PmaTestCase extends TestCase
|
||||
*/
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
$cfg = [];
|
||||
require ROOT_PATH . 'libraries/config.default.php';
|
||||
$GLOBALS['cfg'] = $cfg;
|
||||
}
|
||||
@ -46,13 +47,13 @@ class PmaTestCase extends TestCase
|
||||
*
|
||||
* @param mixed[] ...$param parameter for header method
|
||||
*
|
||||
* @return MockBuilder
|
||||
* @return MockObject
|
||||
*/
|
||||
public function mockResponse(...$param)
|
||||
{
|
||||
$this->restoreInstance = Response::getInstance();
|
||||
|
||||
$mockResponse = $this->getMockBuilder('PhpMyAdmin\Response')
|
||||
$mockResponse = $this->getMockBuilder(Response::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods([
|
||||
'header',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user