Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"web-token/jwt-core": "^2.2"
},
"require-dev": {
"symplify/easy-coding-standard": "^10.0"
"symplify/easy-coding-standard": "^10.2"
},
"suggest": {
"cesnet/simplesamlphp-module-privacyidea": "included privacyIDEA template is for this module"
Expand Down
18 changes: 9 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 18 additions & 28 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

declare(strict_types=1);

use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use PhpCsFixer\Fixer\FunctionNotation\FunctionTypehintSpaceFixer;
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
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__ . '/hooks',
Expand All @@ -20,28 +17,21 @@
__DIR__ . '/themes',
__DIR__ . '/www',
]);
$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);
$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,
]);

$services = $containerConfigurator->services();
$services->set(ArraySyntaxFixer::class)
->call('configure', [[
'syntax' => 'short',
]])
;
$ecsConfig->skip([NotOperatorWithSuccessorSpaceFixer::class, FunctionTypehintSpaceFixer::class]);
};
2 changes: 1 addition & 1 deletion hooks/hook_cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
function perun_hook_cron(&$croninfo)
{
if ('hourly' !== $croninfo['tag']) {
if ($croninfo['tag'] !== 'hourly') {
Logger::debug('cron [perun]: Skipping cron in cron tag [' . $croninfo['tag'] . '] ');

return;
Expand Down
4 changes: 2 additions & 2 deletions lib/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public function getConnector()
*/
public static function getInstance($interface)
{
if (self::RPC === $interface) {
if ($interface === self::RPC) {
return new AdapterRpc();
}
if (self::LDAP === $interface) {
if ($interface === self::LDAP) {
return new AdapterLdap();
}
throw new Exception('Unknown perun interface. Hint: try ' . self::RPC . ' or ' . self::LDAP);
Expand Down
30 changes: 15 additions & 15 deletions lib/AdapterLdap.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class AdapterLdap extends Adapter

public function __construct($configFileName = null)
{
if (null === $configFileName) {
if ($configFileName === null) {
$configFileName = self::DEFAULT_CONFIG_FILE_NAME;
}

Expand Down Expand Up @@ -248,7 +248,7 @@ public function getGroupByName($vo, $name)
'(&(objectClass=perunGroup)(perunUniqueGroupName=' . $name . '))',
['perunGroupId', 'cn', 'perunUniqueGroupName', 'perunVoId', 'uuid', 'description']
);
if (null === $group) {
if ($group === null) {
throw new Exception('Group with name: $name in VO: ' . $vo->getName() . ' does not exists in Perun LDAP.');
}

Expand All @@ -269,7 +269,7 @@ public function getVoByShortName($voShortName)
'(&(objectClass=perunVo)(o=' . $voShortName . '))',
['perunVoId', 'o', 'description']
);
if (null === $vo) {
if ($vo === null) {
throw new Exception('Vo with name: ' . $voShortName . ' does not exists in Perun LDAP.');
}

Expand All @@ -284,7 +284,7 @@ public function getVoById($id)
['o', 'description']
);

if (null === $vo) {
if ($vo === null) {
throw new Exception('Vo with id: ' . $id . ' does not exists in Perun LDAP.');
}

Expand Down Expand Up @@ -480,7 +480,7 @@ public function getUsersGroupsOnFacility($spEntityId, $userId)

public function getUsersGroupsOnSp($facility, $userId)
{
if (null === $facility) {
if ($facility === null) {
return [];
}
$id = $facility->getId();
Expand All @@ -492,7 +492,7 @@ public function getUsersGroupsOnSp($facility, $userId)
);
Logger::debug('Resources - ' . json_encode($resources));

if (null === $resources) {
if ($resources === null) {
throw new Exception('Service with ID: ' . $id . ' hasn\'t assigned any resource.');
}
$resourcesString = '(|';
Expand Down Expand Up @@ -551,20 +551,20 @@ public function isUserInVo($user, $voShortName)
}

$vo = $this->getVoByShortName($voShortName);
if (null === $vo) {
if ($vo === null) {
Logger::debug('isUserInVo - No VO found, returning false');

return false;
}

return Member::VALID === $this->getMemberStatusByUserAndVo($user, $vo);
return $this->getMemberStatusByUserAndVo($user, $vo) === Member::VALID;
}

public function getResourceCapabilities($entityId, $userGroups)
{
$facility = $this->getFacilityByEntityId($entityId);

if (null === $facility) {
if ($facility === null) {
return [];
}

Expand Down Expand Up @@ -620,7 +620,7 @@ public function getFacilityCapabilities($entityId)

private function mapUser($user)
{
if (null === $user) {
if ($user === null) {
return null;
}
if (isset($user['displayName'][0])) {
Expand All @@ -637,19 +637,19 @@ private function mapUser($user)
private function resolveAttrValue($attrsNameTypeMap, $attrsFromLdap, $attr)
{
if (!array_key_exists($attr, $attrsFromLdap)) {
if (self::TYPE_BOOL === $attrsNameTypeMap[$attr][self::TYPE]) {
if ($attrsNameTypeMap[$attr][self::TYPE] === self::TYPE_BOOL) {
return false;
}
if (self::TYPE_MAP === $attrsNameTypeMap[$attr][self::TYPE]
|| self::TYPE_DICTIONARY === $attrsNameTypeMap[$attr][self::TYPE]
if ($attrsNameTypeMap[$attr][self::TYPE] === self::TYPE_MAP
|| $attrsNameTypeMap[$attr][self::TYPE] === self::TYPE_DICTIONARY
) {
return [];
}
} else {
if (self::TYPE_MAP === $attrsNameTypeMap[$attr][self::TYPE]) {
if ($attrsNameTypeMap[$attr][self::TYPE] === self::TYPE_MAP) {
return $attrsFromLdap[$attr];
}
if (self::TYPE_DICTIONARY === $attrsNameTypeMap[$attr][self::TYPE]) {
if ($attrsNameTypeMap[$attr][self::TYPE] === self::TYPE_DICTIONARY) {
return $this->convertToMap($attrsFromLdap[$attr]);
}

Expand Down
24 changes: 12 additions & 12 deletions lib/AdapterRpc.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class AdapterRpc extends Adapter

public function __construct($configFileName = null)
{
if (null === $configFileName) {
if ($configFileName === null) {
$configFileName = self::DEFAULT_CONFIG_FILE_NAME;
}

Expand Down Expand Up @@ -98,10 +98,10 @@ public function getPerunUser($idpEntityId, $uids)

return new User($user['id'], $name);
} catch (PerunException $e) {
if ('UserExtSourceNotExistsException' === $e->getName()) {
if ($e->getName() === 'UserExtSourceNotExistsException') {
continue;
}
if ('ExtSourceNotExistsException' === $e->getName()) {
if ($e->getName() === 'ExtSourceNotExistsException') {
// Because use of original/source entityID as extSourceName
continue;
}
Expand Down Expand Up @@ -205,7 +205,7 @@ public function getSpGroups(string $spEntityId): array
{
$facility = $this->getFacilityByEntityId($spEntityId);

if (null === $facility) {
if ($facility === null) {
return [];
}

Expand Down Expand Up @@ -394,7 +394,7 @@ public function getUsersGroupsOnFacility($spEntityId, $userId)

public function getUsersGroupsOnSp($facility, $userId)
{
if (null === $facility) {
if ($facility === null) {
return [];
}

Expand All @@ -412,7 +412,7 @@ public function getUsersGroupsOnSp($facility, $userId)

foreach ($usersGroupsOnFacility as $usersGroupOnFacility) {
if (isset($usersGroupOnFacility['attributes'][0]['friendlyName']) &&
'voShortName' === $usersGroupOnFacility['attributes'][0]['friendlyName']) {
$usersGroupOnFacility['attributes'][0]['friendlyName'] === 'voShortName') {
$uniqueName = $usersGroupOnFacility['attributes'][0]['value'] . ':' . $usersGroupOnFacility['name'];

array_push($groups, new Group(
Expand Down Expand Up @@ -503,7 +503,7 @@ public function getMemberByUser($user, $vo)
'user' => $user->getId(),
'vo' => $vo->getId(),
]);
if (null === $member) {
if ($member === null) {
throw new Exception(
'Member for User with name ' . $user->getName() . ' and Vo with shortName ' . $vo->getShortName() . 'does not exist in Perun!'
);
Expand All @@ -522,13 +522,13 @@ public function isUserInVo($user, $voShortName)
}

$vo = $this->getVoByShortName($voShortName);
if (null === $vo) {
if ($vo === null) {
Logger::debug('isUserInVo - No VO found, returning false');

return false;
}

return Member::VALID === $this->getMemberStatusByUserAndVo($user, $vo);
return $this->getMemberStatusByUserAndVo($user, $vo) === Member::VALID;
}

/**
Expand Down Expand Up @@ -653,7 +653,7 @@ public function getResourceCapabilities($entityId, $userGroups)
{
$facility = $this->getFacilityByEntityId($entityId);

if (null === $facility) {
if ($facility === null) {
return [];
}

Expand All @@ -677,7 +677,7 @@ public function getResourceCapabilities($entityId, $userGroups)
'attributeName' => 'urn:perun:resource:attribute-def:def:capabilities',
])['value'];

if (null === $resourceCapabilities) {
if ($resourceCapabilities === null) {
continue;
}

Expand All @@ -698,7 +698,7 @@ public function getFacilityCapabilities($entityId)
{
$facility = $this->getFacilityByEntityId($entityId);

if (null === $facility) {
if ($facility === null) {
return [];
}

Expand Down
2 changes: 1 addition & 1 deletion lib/AttributeUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private static function getConfig()
Logger::warning('perun:AttributeUtils: missing or invalid perun_attributes.php config file');
}

if (null === $perunAttributesConfig) {
if ($perunAttributesConfig === null) {
throw new Exception('perun:AttributeUtils: missing or invalid perun_attributes.php config file');
}

Expand Down
Loading