Fix coding standard issues

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
Maurício Meneghini Fauth 2020-05-27 21:07:42 -03:00
parent 2c5f80fc46
commit 199e3d9813
17 changed files with 40 additions and 45 deletions

View File

@ -31,7 +31,7 @@ $AUTH_MAP = [
],
];
// phpcs:disable PSR1.Files.SideEffects
// phpcs:disable PSR1.Files.SideEffects,Squiz.Functions.GlobalFunction
/**
* Simple function to show HTML page with given content.

View File

@ -9,6 +9,8 @@
declare(strict_types=1);
// phpcs:disable Squiz.Functions.GlobalFunction
/**
* This function returns username and password.
*

View File

@ -615,6 +615,7 @@ class FormDisplay
// keep boolean value as boolean
if (! is_bool($value)) {
// phpcs:ignore Generic.PHP.ForbiddenFunctions
settype($value, gettype($vk));
}
@ -699,12 +700,14 @@ class FormDisplay
switch ($type) {
case 'double':
$_POST[$key] = Util::requestString($_POST[$key]);
// phpcs:ignore Generic.PHP.ForbiddenFunctions
settype($_POST[$key], 'float');
break;
case 'boolean':
case 'integer':
if ($_POST[$key] !== '') {
$_POST[$key] = Util::requestString($_POST[$key]);
// phpcs:ignore Generic.PHP.ForbiddenFunctions
settype($_POST[$key], $type);
}
break;

View File

@ -95,6 +95,8 @@ class Plugins
*/
public static function getPlugins($plugin_type, $plugins_dir, $plugin_param)
{
global $skip_import;
$GLOBALS['plugin_param'] = $plugin_param;
$handle = @opendir($plugins_dir);
@ -125,12 +127,12 @@ class Plugins
continue;
}
/** @var bool */
$GLOBALS['skip_import'] = false;
/** @var bool $skip_import */
$skip_import = false;
include_once $plugins_dir . $file;
if ($GLOBALS['skip_import']) {
if ($skip_import) {
continue;
}

View File

@ -11,6 +11,7 @@ use PhpMyAdmin\Plugins\TransformationsPlugin;
use PhpMyAdmin\Url;
use stdClass;
use function array_merge;
use function defined;
use function htmlspecialchars;
/**

View File

@ -1,16 +1,19 @@
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Query;
use PhpMyAdmin\Util;
use function array_shift;
use function count;
use function is_array;
/**
* Handles caching results
*/
class Cache
{
/** @var array Table data cache */
private $tableCache = [];

View File

@ -1,9 +1,12 @@
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Query;
use PhpMyAdmin\Util;
use function implode;
use function is_array;
/**
* Handles generating SQL queries

View File

@ -24,6 +24,7 @@ use function htmlspecialchars;
use function implode;
use function in_array;
use function is_array;
use function is_bool;
use function is_string;
use function ksort;
use function mb_check_encoding;
@ -611,6 +612,7 @@ class Relation
}
}
$this->dbi->freeResult($tableRes);
return $cfgRelation;
}

View File

@ -538,6 +538,7 @@ class Response
*/
public function header($text)
{
// phpcs:ignore SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly
header($text);
}

View File

@ -31,10 +31,10 @@ class NodeTrans extends TransNode
*/
public function __construct(
Node $body,
Node $plural = null,
AbstractExpression $count = null,
Node $context = null,
Node $notes = null,
?Node $plural = null,
?AbstractExpression $count = null,
?Node $context = null,
?Node $notes = null,
$lineno,
$tag = null
) {
@ -66,11 +66,11 @@ class NodeTrans extends TransNode
{
$compiler->addDebugInfo($this);
list($msg, $vars) = $this->compileString($this->getNode('body'));
[$msg, $vars] = $this->compileString($this->getNode('body'));
$msg1 = null;
if ($this->hasNode('plural')) {
list($msg1, $vars1) = $this->compileString($this->getNode('plural'));
[$msg1, $vars1] = $this->compileString($this->getNode('plural'));
$vars = array_merge($vars, $vars1);
}

View File

@ -23,21 +23,21 @@ class MessageExtension extends AbstractExtension
return [
new TwigFilter(
'notice',
function (string $string) {
static function (string $string) {
return Message::notice($string)->getDisplay();
},
['is_safe' => ['html']]
),
new TwigFilter(
'error',
function (string $string) {
static function (string $string) {
return Message::error($string)->getDisplay();
},
['is_safe' => ['html']]
),
new TwigFilter(
'raw_success',
function (string $string) {
static function (string $string) {
return Message::rawSuccess($string)->getDisplay();
},
['is_safe' => ['html']]

View File

@ -21,6 +21,7 @@ class RelationExtension extends AbstractExtension
public function getFunctions()
{
$relation = new Relation($GLOBALS['dbi']);
return [
new TwigFunction(
'foreign_dropdown',

View File

@ -21,6 +21,7 @@ class TransformationsExtension extends AbstractExtension
public function getFunctions()
{
$transformations = new Transformations();
return [
new TwigFunction(
'get_description',

View File

@ -1016,6 +1016,7 @@ class Util
$conditionValue = '= \''
. $GLOBALS['dbi']->escapeString($row) . '\'';
}
return [$conditionValue, $condition];
}
@ -1114,7 +1115,7 @@ class Util
$condition = ' ' . $con_key . ' ';
[$con_val, $condition] = self::getConditionValue(
(! isset($row[$i]) || $row[$i] === null) ? null : $row[$i],
! isset($row[$i]) || $row[$i] === null ? null : $row[$i],
$meta,
$GLOBALS['dbi']->fieldFlags($handle, $i),
$fields_cnt,

View File

@ -22,29 +22,7 @@
<exclude name="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration"/>
<exclude name="Squiz.Arrays.ArrayDeclaration"/>
<exclude name="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces"/>
<exclude name="SlevomatCodingStandard.Commenting.DocCommentSpacing.IncorrectLinesCountBetweenDescriptionAndAnnotations"/>
<exclude name="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.InvalidFormat"/>
<exclude name="SlevomatCodingStandard.ControlStructures.ControlStructureSpacing"/>
<exclude name="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
<exclude name="SlevomatCodingStandard.Functions.StaticClosure"/>
<exclude name="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<exclude name="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFallbackGlobalName"/>
<exclude name="SlevomatCodingStandard.Namespaces.UnusedUses"/>
<exclude name="SlevomatCodingStandard.PHP.ShortList"/>
<exclude name="SlevomatCodingStandard.PHP.UselessParentheses"/>
<exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes"/>
<exclude name="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
</rule>
<rule ref="Generic.PHP.ForbiddenFunctions">
<exclude-pattern>libraries/classes/Config/FormDisplay.php</exclude-pattern>
</rule>
<rule ref="Squiz.Functions.GlobalFunction">
<exclude-pattern>examples/openid.php</exclude-pattern>
<exclude-pattern>examples/signon-script.php</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedMethod">

View File

@ -9,12 +9,11 @@ namespace PhpMyAdmin\Tests;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Index;
use PhpMyAdmin\Query\Cache;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Table;
use PhpMyAdmin\Query\Cache;
use PhpMyAdmin\Tests\Stubs\DbiDummy;
use stdClass;
use ReflectionClass;
/**
* Tests behaviour of Table class
@ -947,9 +946,7 @@ class TableTest extends AbstractTestCase
$dbi->getCache()->cacheTableContent(
['PMA', 'PMA_BookMark'],
[
'ENGINE' => 'MERGE',
]
['ENGINE' => 'MERGE']
);
$tableObj = new Table('PMA_BookMark', 'PMA');
@ -970,9 +967,7 @@ class TableTest extends AbstractTestCase
$dbi->getCache()->cacheTableContent(
['PMA', 'PMA_BookMark'],
[
'ENGINE' => 'MRG_MYISAM',
]
['ENGINE' => 'MRG_MYISAM']
);
$tableObj = new Table('PMA_BookMark', 'PMA');

View File

@ -21,6 +21,7 @@ use function floatval;
use function htmlspecialchars;
use function ini_get;
use function ini_set;
use function str_repeat;
use function str_replace;
use function strlen;
use function trim;
@ -74,6 +75,7 @@ class UtilTest extends AbstractTestCase
/**
* Test for listPHPExtensions
*
* @requires extension mysqli
* @requires extension curl
* @requires extension mbstring