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

Commit e59b18a

Browse files
Merge pull request #59 from BaranekD/arrays
Using of short array syntax
2 parents 7cda96e + cf46401 commit e59b18a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+267
-265
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
55
#### Added
66
- Added filter JoinGroupsAndEduPersonEntitlement
77

8+
#### Changed
9+
- Using of short array syntax (from array() to [])
10+
811
#### Fixed
912
- Fixed the problem that IDP filter on WAYF didn't work correctly
1013

config-templates/module_discopower.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Configuration for the DiscoPower module.
44
*/
55

6-
$config = array(
6+
$config = [
77

88
// Which tab should be set as default. 0 is the first tab
99
'defaulttab' => 0,
@@ -12,11 +12,11 @@
1212
* List a set of tags (Tabs) that should be listed in a specific order.
1313
* All other available tabs will be listed after the ones specified below.
1414
*/
15-
'taborder' => array('social, misc'),
15+
'taborder' => ['social, misc'],
1616
/*
1717
* the 'tab' parameter allows you to limit the tabs to a specific list. (excluding unlisted tags)
1818
*
19-
* 'tabs' => array('norway', 'finland'),
19+
* 'tabs' => ['norway', 'finland'],
2020
*/
2121

2222
/*
@@ -42,4 +42,4 @@
4242
*/
4343
'cdc.lifetime' => null,
4444

45-
);
45+
];

config-templates/module_perun.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* copy command (from SimpleSAML base dir)
88
* cp modules/perun/module_perun.php config/
99
*/
10-
$config = array(
10+
$config = [
1111

1212
/**
1313
* base url to rpc with slash at the end.
@@ -99,12 +99,12 @@
9999
* OPTIONAL
100100
* Default: show all received services
101101
*/
102-
'status.shown_services'=> array(
103-
'serviceIdentifier' => array(
102+
'status.shown_services'=> [
103+
'serviceIdentifier' => [
104104
'name' => 'serviceName',
105105
'description' => 'serviceDescription'
106-
),
107-
),
106+
],
107+
],
108108

109109
/**
110110
****************************************
@@ -155,9 +155,9 @@
155155
/**
156156
* Specify list of facility attributes, which will be shown
157157
*/
158-
'listOfSps.attributesDefinitions' => array(
158+
'listOfSps.attributesDefinitions' => [
159159
''
160-
),
160+
],
161161

162162

163-
);
163+
];

config-templates/module_perun_getMetadata.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
$config = array(
3+
$config = [
44
/**
55
* Identifier of Proxy
66
*/
@@ -24,8 +24,8 @@
2424
/**
2525
* List of attributes definitions
2626
*/
27-
'attributesDefinitions' => array(
27+
'attributesDefinitions' => [
2828
// Name of attribute from perun => key which will be used in generated metadata
2929
'perunAttrName' => 'metadataName',
30-
),
31-
);
30+
],
31+
];

config-templates/module_perun_idpListsServiceDB.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* @author Pavel Vyskočil <[email protected]>
77
*/
8-
$config = array(
8+
$config = [
99

1010
/*
1111
* Fill the serverName
@@ -75,4 +75,4 @@
7575
*/
7676
'ssl_ca_path' => '/etc/ssl',
7777

78-
);
78+
];

config-templates/processFilterConfigurations-example.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
Example how to configure PerunIdentity module:
44
```php
5-
24 => array(
5+
24 => [
66
'class' => 'perun:ProxyFilter',
77
'filterSPs' => $perunEntityIds,
8-
'config' => array(
8+
'config' => [
99
'class' => 'perun:PerunIdentity',
10-
'uidsAttr' => array('eduPersonUniqueId', 'eduPersonPrincipalName', 'eduPersonTargetedIDString', 'nameid', 'uid'),
10+
'uidsAttr' => ['eduPersonUniqueId', 'eduPersonPrincipalName', 'eduPersonTargetedIDString', 'nameid', 'uid'],
1111
'voShortName' => 'einfra',
1212
'registerUrlBase' => 'https://perun.cesnet.cz/allfed/registrar',
1313
'registerUrl' => 'https://login.cesnet.cz/register',
@@ -17,8 +17,8 @@ Example how to configure PerunIdentity module:
1717
'facilityDynamicRegistrationAttr' => 'urn:perun:facility:attribute-def:def:dynamicRegistration',
1818
'facilityRegisterUrlAttr' => 'urn:perun:facility:attribute-def:def:registerUrl',
1919
'facilityAllowRegistrationToGroups' => 'urn:perun:facility:attribute-def:def:allowRegistration',
20-
),
21-
),
20+
],
21+
],
2222
```
2323

2424

@@ -27,12 +27,12 @@ Example how to configure PerunIdentity module:
2727
Example how to enable filter IdPAttribute:
2828

2929
```php
30-
29 => array(
30+
29 => [
3131
'class' => 'perun:IdPAttribute',
32-
'attrMap' => array(
32+
'attrMap' => [
3333
'OrganizationName:en' => 'idp_organizationName',
34-
),
35-
),
34+
],
35+
],
3636
```
3737

3838
'OrganizationName:en' => 'idp_organizationName' means that the $IdPMetadata['Organization']['en'] will be save into
@@ -77,10 +77,10 @@ $request['Attributes']['idp_organizationName']
7777
Example how to enable filter ForceAup:
7878

7979
```php
80-
40 => array(
80+
40 => [
8181
'class' => 'perun:ProxyFilter',
8282
'filterSPs' => $perunEntityIds,
83-
'config' => array(
83+
'config' => [
8484
'class' => 'perun:ForceAup',
8585
'uidAttr' => 'uid',
8686
'interface' => 'rpc',
@@ -89,8 +89,8 @@ Example how to enable filter ForceAup:
8989
'perunVoAupAttr' => 'urn:perun:vo:attribute-def:def:aup',
9090
'perunFacilityReqAupsAttr' => 'urn:perun:facility:attribute-def:def:reqAups',
9191
'facilityVoShortNames' => 'urn:perun:facility:attribute-def:virt:voShortNames'
92-
),
93-
),
92+
],
93+
],
9494
```
9595

9696
3.Fill the attributes and set list of required Aups (attr reqAups) and voShortNames (optional) for each facility

lib/Adapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ abstract public function getMemberStatusByUserAndVo($user, $vo);
182182
*/
183183
protected function removeDuplicateEntities($entities)
184184
{
185-
$removed = array();
186-
$ids = array();
185+
$removed = [];
186+
$ids = [];
187187
foreach ($entities as $entity) {
188188
if (!in_array($entity->getId(), $ids)) {
189189
array_push($ids, $entity->getId());

lib/AdapterLdap.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function getPerunUser($idpEntityId, $uids)
6868
$user = $this->connector->searchForEntity(
6969
"ou=People," . $this->ldapBase,
7070
"(|$query)",
71-
array("perunUserId", "displayName", "cn", "givenName", "sn", "preferredMail", "mail")
71+
["perunUserId", "displayName", "cn", "givenName", "sn", "preferredMail", "mail"]
7272
);
7373
if (is_null($user)) {
7474
return $user;
@@ -90,10 +90,10 @@ public function getMemberGroups($user, $vo)
9090
$userWithMembership = $this->connector->searchForEntity(
9191
"perunUserId=$userId,ou=People," . $this->ldapBase,
9292
"(objectClass=perunUser)",
93-
array("perunUserId", "memberOf")
93+
["perunUserId", "memberOf"]
9494
);
9595

96-
$groups = array();
96+
$groups = [];
9797
foreach ($userWithMembership['memberOf'] as $groupDn) {
9898
$voId = explode('=', explode(',', $groupDn)[1], 2)[1];
9999
if ($voId != $vo->getId()) {
@@ -103,7 +103,7 @@ public function getMemberGroups($user, $vo)
103103
$group = $this->connector->searchForEntity(
104104
$groupDn,
105105
"(objectClass=perunGroup)",
106-
array("perunGroupId", "cn", "perunUniqueGroupName", "perunVoId", "description")
106+
["perunGroupId", "cn", "perunUniqueGroupName", "perunVoId", "description"]
107107
);
108108
array_push(
109109
$groups,
@@ -125,17 +125,17 @@ public function getSpGroups($spEntityId)
125125
$resources = $this->connector->searchForEntities(
126126
$this->ldapBase,
127127
"(&(objectClass=perunResource)(entityID=$spEntityId))",
128-
array("perunResourceId", "assignedGroupId", "perunVoId")
128+
["perunResourceId", "assignedGroupId", "perunVoId"]
129129
);
130130

131-
$groups = array();
131+
$groups = [];
132132
foreach ($resources as $resource) {
133133
if (isset($resource['assignedGroupId'])) {
134134
foreach ($resource['assignedGroupId'] as $groupId) {
135135
$group = $this->connector->searchForEntity(
136136
"perunGroupId=$groupId,perunVoId=" . $resource['perunVoId'][0] . "," . $this->ldapBase,
137137
"(objectClass=perunGroup)",
138-
array("perunGroupId", "cn", "perunUniqueGroupName", "perunVoId", "description")
138+
["perunGroupId", "cn", "perunUniqueGroupName", "perunVoId", "description"]
139139
);
140140
array_push(
141141
$groups,
@@ -161,7 +161,7 @@ public function getGroupByName($vo, $name)
161161
$group = $this->connector->searchForEntity(
162162
"perunVoId=$voId," . $this->ldapBase,
163163
"(&(objectClass=perunGroup)(perunUniqueGroupName=$name))",
164-
array("perunGroupId", "cn", "perunUniqueGroupName", "perunVoId", "description")
164+
["perunGroupId", "cn", "perunUniqueGroupName", "perunVoId", "description"]
165165
);
166166
if (is_null($group)) {
167167
throw new Exception(
@@ -182,7 +182,7 @@ public function getVoByShortName($voShortName)
182182
$vo = $this->connector->searchForEntity(
183183
$this->ldapBase,
184184
"(&(objectClass=perunVo)(o=$voShortName))",
185-
array("perunVoId", "o", "description")
185+
["perunVoId", "o", "description"]
186186
);
187187
if (is_null($vo)) {
188188
throw new Exception("Vo with name: $vo does not exists in Perun LDAP.");
@@ -196,7 +196,7 @@ public function getVoById($id)
196196
$vo = $this->connector->searchForEntity(
197197
$this->ldapBase,
198198
"(&(objectClass=perunVo)(perunVoId=$id))",
199-
array("o", "description")
199+
["o", "description"]
200200
);
201201
if (is_null($vo)) {
202202
throw new Exception("Vo with id: $id does not exists in Perun LDAP.");
@@ -277,7 +277,7 @@ public function getUsersGroupsOnFacility($spEntityId, $userId)
277277
$resources = $this->connector->searchForEntities(
278278
$this->ldapBase,
279279
"(&(objectClass=perunResource)(entityID=$spEntityId))",
280-
array("perunResourceId")
280+
["perunResourceId"]
281281
);
282282
Logger::debug("Resources - " . var_export($resources, true));
283283

@@ -292,11 +292,11 @@ public function getUsersGroupsOnFacility($spEntityId, $userId)
292292
}
293293
$resourcesString .= ")";
294294

295-
$resultGroups = array();
295+
$resultGroups = [];
296296
$groups = $this->connector->searchForEntities(
297297
$this->ldapBase,
298298
"(&(uniqueMember=perunUserId=" . $userId . ", ou=People," . $this->ldapBase . ")" . $resourcesString . ")",
299-
array("perunGroupId", "cn", "perunUniqueGroupName", "perunVoId", "description")
299+
["perunGroupId", "cn", "perunUniqueGroupName", "perunVoId", "description"]
300300
);
301301

302302
foreach ($groups as $group) {
@@ -322,7 +322,7 @@ public function getMemberStatusByUserAndVo($user, $vo)
322322
$this->ldapBase,
323323
"(&(objectClass=perunGroup)(cn=members)(perunVoId=" . $vo->getId() .
324324
")(uniqueMember=perunUserId=" . $user->getId() . ", ou=People," . $this->ldapBase . "))",
325-
array("perunGroupid")
325+
["perunGroupid"]
326326
);
327327

328328
if ($groupId === null || empty($groupId)) {

0 commit comments

Comments
 (0)