Skip to content
This repository has been archived by the owner on Sep 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #54 from vyskocilpavel/fix_ecs
Browse files Browse the repository at this point in the history
fix: fix ECS
vyskocilpavel authored Jun 8, 2022
2 parents ce8d13e + 1ccc75c commit a953aa6
Showing 14 changed files with 107 additions and 116 deletions.
51 changes: 21 additions & 30 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -2,43 +2,34 @@

declare(strict_types=1);

use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
use PhpCsFixer\Fixer\FunctionNotation\FunctionTypehintSpaceFixer;
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [
return static function (ECSConfig $ecsConfig): void {
$ecsConfig->paths([
__DIR__ . '/ecs.php',
__DIR__ . '/config-templates',
__DIR__ . '/dictionaries',
__DIR__ . '/lib',
__DIR__ . '/themes',
__DIR__ . '/www',
__DIR__ . '/composer.json',
]);
$parameters->set(Option::PARALLEL, true);
$parameters->set(Option::SKIP, [NotOperatorWithSuccessorSpaceFixer::class, FunctionTypehintSpaceFixer::class]);
$containerConfigurator->import(SetList::PHP_CS_FIXER);
$containerConfigurator->import(SetList::CLEAN_CODE);
$containerConfigurator->import(SetList::SYMPLIFY);
$containerConfigurator->import(SetList::ARRAY);
$containerConfigurator->import(SetList::COMMON);
$containerConfigurator->import(SetList::COMMENTS);
$containerConfigurator->import(SetList::CONTROL_STRUCTURES);
$containerConfigurator->import(SetList::DOCBLOCK);
$containerConfigurator->import(SetList::NAMESPACES);
$containerConfigurator->import(SetList::PHPUNIT);
$containerConfigurator->import(SetList::SPACES);
$containerConfigurator->import(SetList::STRICT);
$containerConfigurator->import(SetList::SYMFONY);
$containerConfigurator->import(SetList::PSR_12);

$services = $containerConfigurator->services();
$services->set(ArraySyntaxFixer::class)
->call('configure', [[
'syntax' => 'short',
]])
;
$ecsConfig->sets([
SetList::CLEAN_CODE,
SetList::SYMPLIFY,
SetList::ARRAY,
SetList::COMMON,
SetList::COMMENTS,
SetList::CONTROL_STRUCTURES,
SetList::DOCBLOCK,
SetList::NAMESPACES,
SetList::PHPUNIT,
SetList::SPACES,
SetList::STRICT,
SetList::PSR_12,
]);

$ecsConfig->skip([NotOperatorWithSuccessorSpaceFixer::class, FunctionTypehintSpaceFixer::class]);
};
14 changes: 7 additions & 7 deletions lib/Auth/Process/ComputeLoA.php
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ public function process(&$request)
}

foreach ($entityCategoryAttributes as $entityCategoryAttribute) {
if (self::EDUID_IDP_GROUP === substr($entityCategoryAttribute, 0, strlen(self::EDUID_IDP_GROUP))) {
if (substr($entityCategoryAttribute, 0, strlen(self::EDUID_IDP_GROUP)) === self::EDUID_IDP_GROUP) {
$this->entityCategory = substr(
$entityCategoryAttribute,
strlen(self::EDUID_IDP_GROUP),
@@ -97,10 +97,10 @@ public function process(&$request)
*/
private function getLoA()
{
if (null === $this->entityCategory || empty($this->entityCategory)) {
if ($this->entityCategory === null || empty($this->entityCategory)) {
return 0;
}
if (self::UNIVERSITY === $this->entityCategory) {
if ($this->entityCategory === self::UNIVERSITY) {
foreach ($this->eduPersonScopedAffiliation as $affiliation) {
if (preg_match(
'/(^employee@.+\.cz$)|' .
@@ -115,25 +115,25 @@ private function getLoA()
return 2;
}
}
} elseif (self::AVCR === $this->entityCategory) {
} elseif ($this->entityCategory === self::AVCR) {
foreach ($this->eduPersonScopedAffiliation as $affiliation) {
if (preg_match('/^member@.+\.cz$/', $affiliation, $matches)) {
return 2;
}
}
} elseif (self::LIBRARY === $this->entityCategory) {
} elseif ($this->entityCategory === self::LIBRARY) {
foreach ($this->eduPersonScopedAffiliation as $affiliation) {
if (preg_match('/^employee@.+\.cz$/', $affiliation, $matches)) {
return 2;
}
}
} elseif (self::HOSPITAL === $this->entityCategory) {
} elseif ($this->entityCategory === self::HOSPITAL) {
foreach ($this->eduPersonScopedAffiliation as $affiliation) {
if (preg_match('/^employee@.+\.cz$/', $affiliation, $matches)) {
return 2;
}
}
} elseif (self::OTHER === $this->entityCategory) {
} elseif ($this->entityCategory === self::OTHER) {
foreach ($this->eduPersonScopedAffiliation as $affiliation) {
if (preg_match('/(^employee@.+\.cz$)|(^member@.+\.cz$)/', $affiliation, $matches)) {
return 2;
22 changes: 11 additions & 11 deletions lib/Auth/Process/IsCesnetEligible.php
Original file line number Diff line number Diff line change
@@ -85,7 +85,7 @@ public function __construct($config, $reserved)
{
parent::__construct($config, $reserved);
$conf = Configuration::loadFromArray($config);
if (! isset($config[self::RPC_ATTRIBUTE_NAME]) || empty($config[self::RPC_ATTRIBUTE_NAME])) {
if (!isset($config[self::RPC_ATTRIBUTE_NAME]) || empty($config[self::RPC_ATTRIBUTE_NAME])) {
throw new Exception(
'cesnet:IsCesnetEligible - missing mandatory configuration option \'' . self::RPC_ATTRIBUTE_NAME . '\'.'
);
@@ -96,12 +96,12 @@ public function __construct($config, $reserved)
$this->cesnetLdapConnector = (new AdapterLdap(self::CONFIG_FILE_NAME))->getConnector();
$this->rpcAdapter = Adapter::getInstance(Adapter::RPC);

if (isset($config[self::ATTR_NAME]) && ! empty($config[self::ATTR_NAME])) {
if (isset($config[self::ATTR_NAME]) && !empty($config[self::ATTR_NAME])) {
$this->returnAttrName = $config['attrName'];
}

if (isset($config[self::INTERFACE_PROPNAME], $config[self::LDAP_ATTRIBUTE_NAME]) &&
self::LDAP === $config[self::INTERFACE_PROPNAME] && ! empty($config[self::LDAP_ATTRIBUTE_NAME])) {
$config[self::INTERFACE_PROPNAME] === self::LDAP && !empty($config[self::LDAP_ATTRIBUTE_NAME])) {
$this->interface = $config[self::INTERFACE_PROPNAME];
$this->ldapAttrName = $config[self::LDAP_ATTRIBUTE_NAME];
$this->adapter = Adapter::getInstance(Adapter::LDAP);
@@ -117,7 +117,7 @@ public function __construct($config, $reserved)
$conf->getString(self::PERUN_USER_SPONSORING_ORGANIZATIONS_ATTR_NAME, null);
$this->userAffiliationsAttrName = $conf->getString(self::PERUN_USER_AFFILIATIONS_ATTR_NAME, null);

if (! isset($this->userAffiliationsAttrName, $this->userSponsoringOrganizationsAttrName)) {
if (!isset($this->userAffiliationsAttrName, $this->userSponsoringOrganizationsAttrName)) {
Logger::warning(
'cesnet:IsCesnetEligible - One of attributes [' . $this->userAffiliationsAttrName . ', ' .
$this->userSponsoringOrganizationsAttrName . '] wasn\'t set!'
@@ -148,8 +148,8 @@ public function process(&$request)
);
}

if (! empty($user)) {
if (self::LDAP === $this->interface) {
if (!empty($user)) {
if ($this->interface === self::LDAP) {
$attrs = $this->adapter->getUserAttributes($user, [$this->ldapAttrName]);
if (isset($attrs[$this->ldapAttrName][0])) {
$this->cesnetEligibleLastSeenValue = $attrs[$this->ldapAttrName][0];
@@ -162,10 +162,10 @@ public function process(&$request)
}
}

if (! empty($this->eduPersonScopedAffiliation) && $this->isCesnetEligible($user)) {
if (!empty($this->eduPersonScopedAffiliation) && $this->isCesnetEligible($user)) {
$this->cesnetEligibleLastSeenValue = date('Y-m-d H:i:s');

if (! empty($user)) {
if (!empty($user)) {
// Update attribute 'isCesnetEligible' in Perun

$id = uniqid('', true);
@@ -187,7 +187,7 @@ public function process(&$request)
}
}

if (null !== $this->cesnetEligibleLastSeenValue) {
if ($this->cesnetEligibleLastSeenValue !== null) {
$request['Attributes'][$this->returnAttrName] = [$this->cesnetEligibleLastSeenValue];
Logger::debug(
'cesnet:IsCesnetEligible - Attribute ' . $this->returnAttrName . ' was set to value ' .
@@ -196,7 +196,7 @@ public function process(&$request)
}

$request['Attributes']['isCesnetEligible'] = ['false'];
if ((null !== $this->cesnetEligibleLastSeenValue) && $this->cesnetEligibleLastSeenValue > date(
if (($this->cesnetEligibleLastSeenValue !== null) && $this->cesnetEligibleLastSeenValue > date(
'Y-m-d H:i:s',
strtotime('-1 year')
)) {
@@ -306,7 +306,7 @@ private function getAllowedAffiliations($idpEntityIds): array
private function compareAffiliations($userAffiliations, $allowedAffiliations): bool
{
$result = array_intersect($userAffiliations, $allowedAffiliations);
if (! empty($result)) {
if (!empty($result)) {
return true;
}

2 changes: 1 addition & 1 deletion themes/cesnet/default/includes/footer.php
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

use SimpleSAML\Module;

if (! empty($this->data['htmlinject']['htmlContentPost'])) {
if (!empty($this->data['htmlinject']['htmlContentPost'])) {
foreach ($this->data['htmlinject']['htmlContentPost'] as $c) {
echo $c;
}
12 changes: 6 additions & 6 deletions themes/cesnet/default/includes/header.php
Original file line number Diff line number Diff line change
@@ -60,13 +60,13 @@

<?php

if (! empty($jquery)) {
if (!empty($jquery)) {
$version = '1.8';
if (array_key_exists('version', $jquery)) {
$version = $jquery['version'];
}

if ('1.8' === $version) {
if ($version === '1.8') {
if (isset($jquery['core']) && $jquery['core']) {
echo '<script type="text/javascript" src="/' . $this->data['baseurlpath'] .
'resources/jquery-1.8.js"></script>' . "\n"
@@ -91,7 +91,7 @@
'resources/clipboard.min.js"></script>' . "\n";
}

if (! empty($this->data['htmlinject']['htmlContentHead'])) {
if (!empty($this->data['htmlinject']['htmlContentHead'])) {
foreach ($this->data['htmlinject']['htmlContentHead'] as $c) {
echo $c;
}
@@ -132,7 +132,7 @@
$onLoad .= $this->data['onLoad'];
}

if ('' !== $onLoad) {
if ($onLoad !== '') {
$onLoad = ' onload="' . $onLoad . '"';
}

@@ -146,7 +146,7 @@
<?php

$includeLanguageBar = true;
if (isset($this->data['hideLanguageBar']) && true === $this->data['hideLanguageBar']) {
if (isset($this->data['hideLanguageBar']) && $this->data['hideLanguageBar'] === true) {
$includeLanguageBar = false;
}

@@ -266,7 +266,7 @@

<?php

if (! empty($this->data['htmlinject']['htmlContentPre'])) {
if (!empty($this->data['htmlinject']['htmlContentPre'])) {
foreach ($this->data['htmlinject']['htmlContentPre'] as $c) {
echo $c;
}
26 changes: 13 additions & 13 deletions themes/cesnet/perun/disco-tpl.php
Original file line number Diff line number Diff line change
@@ -62,19 +62,19 @@
];
$this->includeAtTemplateBase('includes/header.php');

if (null !== $authContextClassRef) {
if ($authContextClassRef !== null) {
foreach ($authContextClassRef as $value) {
if (URN_CESNET_PROXYIDP_FILTER === substr($value, 0, strlen(URN_CESNET_PROXYIDP_FILTER))) {
if (substr($value, 0, strlen(URN_CESNET_PROXYIDP_FILTER)) === URN_CESNET_PROXYIDP_FILTER) {
$filter = substr($value, strlen(URN_CESNET_PROXYIDP_FILTER), strlen($value));
} elseif (URN_CESNET_PROXYIDP_EFILTER === substr($value, 0, strlen(URN_CESNET_PROXYIDP_EFILTER))) {
} elseif (substr($value, 0, strlen(URN_CESNET_PROXYIDP_EFILTER)) === URN_CESNET_PROXYIDP_EFILTER) {
$efilter = substr($value, strlen(URN_CESNET_PROXYIDP_EFILTER), strlen($value));
} elseif (URN_CESNET_PROXYIDP_IDPENTITYID === substr($value, 0, strlen(URN_CESNET_PROXYIDP_IDPENTITYID))) {
} elseif (substr($value, 0, strlen(URN_CESNET_PROXYIDP_IDPENTITYID)) === URN_CESNET_PROXYIDP_IDPENTITYID) {
$idpEntityId = substr($value, strlen(URN_CESNET_PROXYIDP_IDPENTITYID), strlen($value));
}
}
}

if (null !== $idpEntityId) {
if ($idpEntityId !== null) {
$url = $this->getContinueUrl($idpEntityId);

HTTP::redirectTrustedURL($url);
@@ -83,11 +83,11 @@
$url = $this->getContinueUrlWithoutIdPEntityId();

if ($warningAttributes->isEnabled()) {
if (WarningConfiguration::WARNING_TYPE_INFO === $warningAttributes->getType()) {
if ($warningAttributes->getType() === WarningConfiguration::WARNING_TYPE_INFO) {
echo '<div class="alert alert-info">';
} elseif (WarningConfiguration::WARNING_TYPE_WARNING === $warningAttributes->getType()) {
} elseif ($warningAttributes->getType() === WarningConfiguration::WARNING_TYPE_WARNING) {
echo '<div class="alert alert-warning">';
} elseif (WarningConfiguration::WARNING_TYPE_ERROR === $warningAttributes->getType()) {
} elseif ($warningAttributes->getType() === WarningConfiguration::WARNING_TYPE_ERROR) {
echo '<div class="alert alert-danger">';
}
echo '<h4> <strong>' . $warningAttributes->getTitle() . '</strong> </h4>';
@@ -108,18 +108,18 @@

if ($canContinue &&
(
! $warningAttributes->isEnabled() ||
!$warningAttributes->isEnabled() ||
in_array(
$warningAttributes->getType(),
[WarningConfiguration::WARNING_TYPE_INFO, WarningConfiguration::WARNING_TYPE_WARNING],
true
)
)) {
if (null !== $efilter) {
if ($efilter !== null) {
header('Location: https://ds.eduid.cz/wayf.php' . $url . '&efilter=' . $efilter);
exit;
}
if (null !== $filter) {
if ($filter !== null) {
header('Location: https://ds.eduid.cz/wayf.php' . $url . '&filter=' . $filter);
exit;
}
@@ -133,11 +133,11 @@
header('Location: https://ds.eduid.cz/wayf.php' . $url . '&filter=' . $filter);
exit;
}
if (null !== $defaultEFilter) {
if ($defaultEFilter !== null) {
header('Location: https://ds.eduid.cz/wayf.php' . $url . '&efilter=' . $defaultEFilter);
exit;
}
if (null !== $defaultFilter) {
if ($defaultFilter !== null) {
header('Location: https://ds.eduid.cz/wayf.php' . $url . '&filter=' . $defaultFilter);
exit;
}
8 changes: 4 additions & 4 deletions themes/einfra/core/loginuserpass.php
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@

$this->includeAtTemplateBase('includes/header.php');

if (null !== $this->data['errorcode']) {
if ($this->data['errorcode'] !== null) {
?>
<div class="alert alert-danger">
<span class="glyphicon glyphicon-exclamation-sign"
@@ -45,7 +45,7 @@
<input id="username" <?php echo ($this->data['forceUsername']) ? 'disabled="disabled"' : ''; ?>
type="text" name="username" class="form-control"
<?php
if (! $this->data['forceUsername']) {
if (!$this->data['forceUsername']) {
echo 'tabindex="1"';
}
?> value="<?php echo htmlspecialchars($this->data['username']); ?>"/>
@@ -60,7 +60,7 @@
</div>

<?php
if ($this->data['rememberUsernameEnabled'] && ! $this->data['forceUsername']) {
if ($this->data['rememberUsernameEnabled'] && !$this->data['forceUsername']) {
// display the "remember my username" checkbox?>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
@@ -155,7 +155,7 @@ class="col-sm-2 control-label"><?php echo $this->t('{login:organization}'); ?></

<?php

if (! empty($this->data['links'])) {
if (!empty($this->data['links'])) {
echo '<ul class="links" style="margin-top: 2em">';
foreach ($this->data['links'] as $l) {
echo '<li>' .
2 changes: 1 addition & 1 deletion themes/einfra/default/includes/footer.php
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

use SimpleSAML\Module;

if (! empty($this->data['htmlinject']['htmlContentPost'])) {
if (!empty($this->data['htmlinject']['htmlContentPost'])) {
foreach ($this->data['htmlinject']['htmlContentPost'] as $c) {
echo $c;
}
Loading

0 comments on commit a953aa6

Please sign in to comment.