Skip to content
Snippets Groups Projects
Unverified Commit 5d6cda42 authored by Dominik František Bučík's avatar Dominik František Bučík Committed by GitHub
Browse files

Merge pull request #77 from CESNET/renovate/symplify-easy-coding-standard-11.x

chore(deps): update dependency symplify/easy-coding-standard to v11
parents 0442880f 9c7b08a3
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,6 @@ ...@@ -37,6 +37,6 @@
}, },
"require-dev": { "require-dev": {
"squizlabs/php_codesniffer": "*", "squizlabs/php_codesniffer": "*",
"symplify/easy-coding-standard": "^10.0" "symplify/easy-coding-standard": "^11.0"
} }
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "bef79151cb81a54212518f52b3354fbe", "content-hash": "c6cf0239d2544ae5fb18d3e67487d9e8",
"packages": [ "packages": [
{ {
"name": "gettext/gettext", "name": "gettext/gettext",
...@@ -5004,16 +5004,16 @@ ...@@ -5004,16 +5004,16 @@
}, },
{ {
"name": "symplify/easy-coding-standard", "name": "symplify/easy-coding-standard",
"version": "10.3.3", "version": "11.0.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symplify/easy-coding-standard.git", "url": "https://github.com/symplify/easy-coding-standard.git",
"reference": "c93878b3c052321231519b6540e227380f90be17" "reference": "ee347cd02e2aea9f706fc3f67ea0fc19cc0ca606"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symplify/easy-coding-standard/zipball/c93878b3c052321231519b6540e227380f90be17", "url": "https://api.github.com/repos/symplify/easy-coding-standard/zipball/ee347cd02e2aea9f706fc3f67ea0fc19cc0ca606",
"reference": "c93878b3c052321231519b6540e227380f90be17", "reference": "ee347cd02e2aea9f706fc3f67ea0fc19cc0ca606",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -5043,7 +5043,7 @@ ...@@ -5043,7 +5043,7 @@
], ],
"description": "Prefixed scoped version of ECS package", "description": "Prefixed scoped version of ECS package",
"support": { "support": {
"source": "https://github.com/symplify/easy-coding-standard/tree/10.3.3" "source": "https://github.com/symplify/easy-coding-standard/tree/11.0.8"
}, },
"funding": [ "funding": [
{ {
...@@ -5055,7 +5055,7 @@ ...@@ -5055,7 +5055,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2022-06-13T14:03:37+00:00" "time": "2022-07-05T11:49:37+00:00"
} }
], ],
"aliases": [], "aliases": [],
......
...@@ -6,12 +6,10 @@ use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer; ...@@ -6,12 +6,10 @@ use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use PhpCsFixer\Fixer\FunctionNotation\FunctionTypehintSpaceFixer; use PhpCsFixer\Fixer\FunctionNotation\FunctionTypehintSpaceFixer;
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer; use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig; use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList; use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
return static function (ECSConfig $ecsConfig): void { return static function (ECSConfig $ecsConfig): void {
$parameters = $ecsConfig->parameters(); $ecsConfig->paths([
$parameters->set(Option::PATHS, [
__DIR__ . '/ecs.php', __DIR__ . '/ecs.php',
__DIR__ . '/config-templates', __DIR__ . '/config-templates',
__DIR__ . '/hooks', __DIR__ . '/hooks',
...@@ -20,12 +18,13 @@ return static function (ECSConfig $ecsConfig): void { ...@@ -20,12 +18,13 @@ return static function (ECSConfig $ecsConfig): void {
__DIR__ . '/templates', __DIR__ . '/templates',
__DIR__ . '/www', __DIR__ . '/www',
]); ]);
$parameters->set(Option::PARALLEL, true);
$parameters->set(Option::SKIP, [NotOperatorWithSuccessorSpaceFixer::class, FunctionTypehintSpaceFixer::class]); $ecsConfig->parallel();
$ecsConfig->skip([NotOperatorWithSuccessorSpaceFixer::class, FunctionTypehintSpaceFixer::class]);
$ecsConfig->sets( $ecsConfig->sets(
[ [
SetList::PHP_CS_FIXER,
SetList::CLEAN_CODE, SetList::CLEAN_CODE,
SetList::SYMPLIFY, SetList::SYMPLIFY,
SetList::ARRAY, SetList::ARRAY,
...@@ -37,7 +36,6 @@ return static function (ECSConfig $ecsConfig): void { ...@@ -37,7 +36,6 @@ return static function (ECSConfig $ecsConfig): void {
SetList::PHPUNIT, SetList::PHPUNIT,
SetList::SPACES, SetList::SPACES,
SetList::STRICT, SetList::STRICT,
SetList::SYMFONY,
SetList::PSR_12, SetList::PSR_12,
] ]
); );
......
...@@ -12,7 +12,7 @@ use SimpleSAML\Module\proxystatistics\DatabaseCommand; ...@@ -12,7 +12,7 @@ use SimpleSAML\Module\proxystatistics\DatabaseCommand;
*/ */
function proxystatistics_hook_cron(&$croninfo) function proxystatistics_hook_cron(&$croninfo)
{ {
if ('daily' !== $croninfo['tag']) { if ($croninfo['tag'] !== 'daily') {
Logger::debug('cron [proxystatistics]: Skipping cron in cron tag [' . $croninfo['tag'] . '] '); Logger::debug('cron [proxystatistics]: Skipping cron in cron tag [' . $croninfo['tag'] . '] ');
return; return;
......
...@@ -70,7 +70,7 @@ class Config ...@@ -70,7 +70,7 @@ class Config
public static function getInstance(): self public static function getInstance(): self
{ {
if (null === self::$instance) { if (self::$instance === null) {
self::$instance = new self(); self::$instance = new self();
} }
...@@ -116,7 +116,7 @@ class Config ...@@ -116,7 +116,7 @@ class Config
public function getRequiredAuthSource() public function getRequiredAuthSource()
{ {
return$this->requiredAuthSource; return $this->requiredAuthSource;
} }
public function getKeepPerUser() public function getKeepPerUser()
......
...@@ -13,6 +13,7 @@ use SimpleSAML\Logger; ...@@ -13,6 +13,7 @@ use SimpleSAML\Logger;
class DatabaseCommand class DatabaseCommand
{ {
public const TABLE_SUM = 'statistics_sums'; public const TABLE_SUM = 'statistics_sums';
private const DEBUG_PREFIX = 'proxystatistics:DatabaseCommand - '; private const DEBUG_PREFIX = 'proxystatistics:DatabaseCommand - ';
private const TABLE_PER_USER = 'statistics_per_user'; private const TABLE_PER_USER = 'statistics_per_user';
...@@ -87,7 +88,7 @@ class DatabaseCommand ...@@ -87,7 +88,7 @@ class DatabaseCommand
$ids[$tableId] = $this->getEntityDbIdFromEntityIdentifier($table, $entities[$side], $tableId); $ids[$tableId] = $this->getEntityDbIdFromEntityIdentifier($table, $entities[$side], $tableId);
} }
if (false === $this->writeLogin($date, $ids, $userId)) { if ($this->writeLogin($date, $ids, $userId) === false) {
Logger::error(self::DEBUG_PREFIX . 'login record has not been inserted (data \'' . json_encode([ Logger::error(self::DEBUG_PREFIX . 'login record has not been inserted (data \'' . json_encode([
'user' => $userId, 'user' => $userId,
'ids' => $ids, 'ids' => $ids,
...@@ -171,7 +172,7 @@ class DatabaseCommand ...@@ -171,7 +172,7 @@ class DatabaseCommand
'day' 'day'
) . '), EXTRACT(DAY FROM ' . $this->escape_col('day') . '), '; ) . '), EXTRACT(DAY FROM ' . $this->escape_col('day') . '), ';
foreach ($ids as $id) { foreach ($ids as $id) {
$query .= (null === $id ? '0' : $id) . ','; $query .= ($id === null ? '0' : $id) . ',';
} }
$query .= 'SUM(logins), COUNT(DISTINCT ' . $this->escape_col('user') . ') ' $query .= 'SUM(logins), COUNT(DISTINCT ' . $this->escape_col('user') . ') '
. 'FROM ' . $this->tables[self::TABLE_PER_USER] . ' ' . 'FROM ' . $this->tables[self::TABLE_PER_USER] . ' '
...@@ -221,7 +222,7 @@ class DatabaseCommand ...@@ -221,7 +222,7 @@ class DatabaseCommand
$written = $this->conn->write($query, $params); $written = $this->conn->write($query, $params);
if (is_bool($written) && !$written) { if (is_bool($written) && !$written) {
Logger::warning(self::DEBUG_PREFIX . $msg . ' failed'); Logger::warning(self::DEBUG_PREFIX . $msg . ' failed');
} elseif (0 === $written) { } elseif ($written === 0) {
Logger::warning(self::DEBUG_PREFIX . $msg . ' completed, but updated 0 rows.'); Logger::warning(self::DEBUG_PREFIX . $msg . ' completed, but updated 0 rows.');
} else { } else {
Logger::info(self::DEBUG_PREFIX . $msg . ' completed and updated ' . $written . ' rows.'); Logger::info(self::DEBUG_PREFIX . $msg . ' completed and updated ' . $written . ' rows.');
...@@ -272,7 +273,7 @@ class DatabaseCommand ...@@ -272,7 +273,7 @@ class DatabaseCommand
return false; return false;
} }
if (0 === $written) { if ($written === 0) {
Logger::debug(self::DEBUG_PREFIX . 'login entry has been inserted, but has updated 0 rows.'); Logger::debug(self::DEBUG_PREFIX . 'login entry has been inserted, but has updated 0 rows.');
return false; return false;
...@@ -287,23 +288,23 @@ class DatabaseCommand ...@@ -287,23 +288,23 @@ class DatabaseCommand
Config::MODE_IDP => [], Config::MODE_IDP => [],
Config::MODE_SP => [], Config::MODE_SP => [],
]; ];
if (Config::MODE_IDP !== $this->mode && Config::MODE_MULTI_IDP !== $this->mode) { if ($this->mode !== Config::MODE_IDP && $this->mode !== Config::MODE_MULTI_IDP) {
$entities[Config::MODE_IDP][self::KEY_ID] = $this->getIdpIdentifier($request); $entities[Config::MODE_IDP][self::KEY_ID] = $this->getIdpIdentifier($request);
$entities[Config::MODE_IDP][self::KEY_NAME] = $this->getIdpName($request); $entities[Config::MODE_IDP][self::KEY_NAME] = $this->getIdpName($request);
} }
if (Config::MODE_SP !== $this->mode) { if ($this->mode !== Config::MODE_SP) {
$entities[Config::MODE_SP][self::KEY_ID] = $this->getSpIdentifier($request); $entities[Config::MODE_SP][self::KEY_ID] = $this->getSpIdentifier($request);
$entities[Config::MODE_SP][self::KEY_NAME] = $this->getSpName($request); $entities[Config::MODE_SP][self::KEY_NAME] = $this->getSpName($request);
} }
if (Config::MODE_PROXY !== $this->mode && Config::MODE_MULTI_IDP !== $this->mode) { if ($this->mode !== Config::MODE_PROXY && $this->mode !== Config::MODE_MULTI_IDP) {
$entities[$this->mode] = $this->config->getSideInfo($this->mode); $entities[$this->mode] = $this->config->getSideInfo($this->mode);
if (empty($entities[$this->mode][self::KEY_ID]) || empty($entities[$this->mode][self::KEY_NAME])) { if (empty($entities[$this->mode][self::KEY_ID]) || empty($entities[$this->mode][self::KEY_NAME])) {
Logger::error(self::DEBUG_PREFIX . 'Invalid configuration (id, name) for ' . $this->mode); Logger::error(self::DEBUG_PREFIX . 'Invalid configuration (id, name) for ' . $this->mode);
} }
} }
if (Config::MODE_MULTI_IDP === $this->mode) { if ($this->mode === Config::MODE_MULTI_IDP) {
$entities[Config::MODE_IDP] = $this->config->getSideInfo(Config::MODE_IDP); $entities[Config::MODE_IDP] = $this->config->getSideInfo(Config::MODE_IDP);
if (empty($entities[Config::MODE_IDP][self::KEY_ID]) || empty($entities[Config::MODE_IDP][self::KEY_NAME])) { if (empty($entities[Config::MODE_IDP][self::KEY_ID]) || empty($entities[Config::MODE_IDP][self::KEY_NAME])) {
Logger::error(self::DEBUG_PREFIX . 'Invalid configuration (id, name) for ' . $this->mode); Logger::error(self::DEBUG_PREFIX . 'Invalid configuration (id, name) for ' . $this->mode);
...@@ -346,7 +347,7 @@ class DatabaseCommand ...@@ -346,7 +347,7 @@ class DatabaseCommand
$table = self::TABLE_SIDES[$side]; $table = self::TABLE_SIDES[$side];
$column = self::TABLE_IDS[$table]; $column = self::TABLE_IDS[$table];
$part = $column; $part = $column;
if (null === $value) { if ($value === null) {
$part .= '=0'; $part .= '=0';
} else { } else {
$part .= '=:id'; $part .= '=:id';
...@@ -363,8 +364,8 @@ class DatabaseCommand ...@@ -363,8 +364,8 @@ class DatabaseCommand
private function addDaysRange($days, &$query, &$params, $not = false) private function addDaysRange($days, &$query, &$params, $not = false)
{ {
if (0 !== $days) { // 0 = all time if ($days !== 0) { // 0 = all time
if (false === stripos($query, 'WHERE')) { if (stripos($query, 'WHERE') === false) {
$query .= 'WHERE'; $query .= 'WHERE';
} else { } else {
$query .= 'AND'; $query .= 'AND';
...@@ -408,7 +409,7 @@ class DatabaseCommand ...@@ -408,7 +409,7 @@ class DatabaseCommand
{ {
$columns = ['day']; $columns = ['day'];
foreach ($ids as $id) { foreach ($ids as $id) {
if (null !== $id) { if ($id !== null) {
$columns[] = $id; $columns[] = $id;
} }
} }
...@@ -460,12 +461,12 @@ class DatabaseCommand ...@@ -460,12 +461,12 @@ class DatabaseCommand
private function isPgsql(): bool private function isPgsql(): bool
{ {
return 'pgsql' === $this->conn->getDriver(); return $this->conn->getDriver() === 'pgsql';
} }
private function isMysql(): bool private function isMysql(): bool
{ {
return 'mysql' === $this->conn->getDriver(); return $this->conn->getDriver() === 'mysql';
} }
private function unknownDriver() private function unknownDriver()
......
...@@ -141,13 +141,13 @@ class Templates ...@@ -141,13 +141,13 @@ class Templates
'SP' => 'id="tab-3" href="' . self::getFullUrl('serviceProviders.php') . '?lastDays=' . $lastDays . '"', 'SP' => 'id="tab-3" href="' . self::getFullUrl('serviceProviders.php') . '?lastDays=' . $lastDays . '"',
]; ];
$mode = $config->getMode(); $mode = $config->getMode();
if (Config::MODE_PROXY !== $mode) { if ($mode !== Config::MODE_PROXY) {
$t->data['tabsAttributes'][$mode] = 'class="hidden" ' . $t->data['tabsAttributes'][$mode]; $t->data['tabsAttributes'][$mode] = 'class="hidden" ' . $t->data['tabsAttributes'][$mode];
} }
$t->data['header'] = $t->t('{proxystatistics:stats:statistics_header}'); $t->data['header'] = $t->t('{proxystatistics:stats:statistics_header}');
$instanceName = Configuration::getInstance()->getString(self::INSTANCE_NAME, null); $instanceName = Configuration::getInstance()->getString(self::INSTANCE_NAME, null);
if (null !== $instanceName) { if ($instanceName !== null) {
$t->data['header'] = $instanceName . ' ' . $t->data['header']; $t->data['header'] = $instanceName . ' ' . $t->data['header'];
} else { } else {
Logger::warning( Logger::warning(
...@@ -192,7 +192,7 @@ class Templates ...@@ -192,7 +192,7 @@ class Templates
'!side_on' => $t->t('{proxystatistics:stats:chart_legend_side_on_' . $side . '}'), '!side_on' => $t->t('{proxystatistics:stats:chart_legend_side_on_' . $side . '}'),
] ]
); );
if (Config::MODE_SP === $side && Config::MODE_SP !== $mode) { if ($side === Config::MODE_SP && $mode !== Config::MODE_SP) {
echo ' '; echo ' ';
echo $t->t( echo $t->t(
'{proxystatistics:stats:first_access_only}', '{proxystatistics:stats:first_access_only}',
...@@ -211,7 +211,7 @@ class Templates ...@@ -211,7 +211,7 @@ class Templates
$mode = Config::getInstance()->getMode(); $mode = Config::getInstance()->getMode();
$t->data['mode'] = $mode; $t->data['mode'] = $mode;
$t->data['summaryGraphs'] = []; $t->data['summaryGraphs'] = [];
if (Config::MODE_PROXY === $mode || Config::MODE_MULTI_IDP === $mode) { if ($mode === Config::MODE_PROXY || $mode === Config::MODE_MULTI_IDP) {
foreach (Config::SIDES as $side) { foreach (Config::SIDES as $side) {
$t->data['summaryGraphs'][$side] = []; $t->data['summaryGraphs'][$side] = [];
$t->data['summaryGraphs'][$side]['Providers'] = 'col-md-6 graph'; $t->data['summaryGraphs'][$side]['Providers'] = 'col-md-6 graph';
......
...@@ -37,7 +37,7 @@ $file = fopen($identityProvidersFileName, 'r'); ...@@ -37,7 +37,7 @@ $file = fopen($identityProvidersFileName, 'r');
while (!feof($file)) { while (!feof($file)) {
$line = fgetcsv($file); $line = fgetcsv($file);
if (null !== $line) { if ($line !== null) {
$lineInsert = 'INSERT INTO ' . $tableName . '(year, month, day, sourceIdp, service, count) ' . $lineInsert = 'INSERT INTO ' . $tableName . '(year, month, day, sourceIdp, service, count) ' .
'VALUES(' . $line[0] . ', ' . $line[1] . ', ' . $line[2] . ', "' . $line[3] . '","" , ' . $line[4] . ');' . 'VALUES(' . $line[0] . ', ' . $line[1] . ', ' . $line[2] . ', "' . $line[3] . '","" , ' . $line[4] . ');' .
PHP_EOL; PHP_EOL;
...@@ -52,7 +52,7 @@ $file = fopen($serviceProvidersFileName, 'r'); ...@@ -52,7 +52,7 @@ $file = fopen($serviceProvidersFileName, 'r');
while (!feof($file)) { while (!feof($file)) {
$line = fgetcsv($file); $line = fgetcsv($file);
if (null !== $line) { if ($line !== null) {
$lineInsert = 'INSERT INTO ' . $tableName . '(year, month, day, sourceIdp, service, count) ' . $lineInsert = 'INSERT INTO ' . $tableName . '(year, month, day, sourceIdp, service, count) ' .
'VALUES(' . $line[0] . ', ' . $line[1] . ', ' . $line[2] . ', "", "' . $line[3] . '", ' . $line[4] . ');' . 'VALUES(' . $line[0] . ', ' . $line[1] . ', ' . $line[2] . ', "", "' . $line[3] . '", ' . $line[4] . ');' .
PHP_EOL; PHP_EOL;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment