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

Commit 00c9122

Browse files
committed
is_null() changed to === null
1 parent b2fd417 commit 00c9122

File tree

11 files changed

+59
-56
lines changed

11 files changed

+59
-56
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ All notable changes to this project will be documented in this file.
6464
#### Changed
6565
- RpcConnector now stores cookie into file
6666
- Set CONNECTTIMEOUT and TIMEOUT in RpcConnector
67+
- is_null() changed to === null
6768
- Use new object perunFacility in LDAP to search information about facility
6869
- Configuration for warning on DS is now in module_perun.php
6970

lib/AdapterLdap.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class AdapterLdap extends Adapter
3535

3636
public function __construct($configFileName = null)
3737
{
38-
if (is_null($configFileName)) {
38+
if ($configFileName === null) {
3939
$configFileName = self::DEFAULT_CONFIG_FILE_NAME;
4040
}
4141

@@ -66,7 +66,7 @@ public function getPerunUser($idpEntityId, $uids)
6666
"(|$query)",
6767
["perunUserId", "displayName", "cn", "givenName", "sn", "preferredMail", "mail"]
6868
);
69-
if (is_null($user)) {
69+
if ($user === null) {
7070
return $user;
7171
}
7272

@@ -166,7 +166,7 @@ public function getGroupByName($vo, $name)
166166
"(&(objectClass=perunGroup)(perunUniqueGroupName=$name))",
167167
["perunGroupId", "cn", "perunUniqueGroupName", "perunVoId", "description"]
168168
);
169-
if (is_null($group)) {
169+
if ($group === null) {
170170
throw new Exception(
171171
"Group with name: $name in VO: " . $vo->getName() . " does not exists in Perun LDAP."
172172
);
@@ -187,7 +187,8 @@ public function getVoByShortName($voShortName)
187187
"(&(objectClass=perunVo)(o=$voShortName))",
188188
["perunVoId", "o", "description"]
189189
);
190-
if (is_null($vo)) {
190+
191+
if ($vo === null) {
191192
throw new Exception("Vo with name: $vo does not exists in Perun LDAP.");
192193
}
193194

@@ -201,7 +202,8 @@ public function getVoById($id)
201202
"(&(objectClass=perunVo)(perunVoId=$id))",
202203
["o", "description"]
203204
);
204-
if (is_null($vo)) {
205+
206+
if ($vo === null) {
205207
throw new Exception("Vo with id: $id does not exists in Perun LDAP.");
206208
}
207209

@@ -291,7 +293,7 @@ public function getUsersGroupsOnFacility($spEntityId, $userId)
291293
);
292294
Logger::debug("Resources - " . var_export($resources, true));
293295

294-
if (is_null($resources)) {
296+
if ($resources === null) {
295297
throw new Exception(
296298
"Service with spEntityId: " . $spEntityId . " hasn't assigned any resource."
297299
);

lib/AdapterRpc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class AdapterRpc extends Adapter
3434

3535
public function __construct($configFileName = null)
3636
{
37-
if (is_null($configFileName)) {
37+
if ($configFileName === null) {
3838
$configFileName = self::DEFAULT_CONFIG_FILE_NAME;
3939
}
4040

@@ -375,7 +375,7 @@ public function getMemberByUser($user, $vo)
375375
'user' => $user->getId(),
376376
'vo' => $vo->getId(),
377377
]);
378-
if (is_null($member)) {
378+
if ($member === null) {
379379
throw new Exception(
380380
"Member for User with name " . $user->getName() . " and Vo with shortName " .
381381
$vo->getShortName() . "does not exist in Perun!"

lib/Auth/Process/ForceAup.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function process(&$request)
125125
foreach ($facilities as $facility) {
126126
$facilityAups = $this->adapter->getFacilityAttribute($facility, $this->perunFacilityReqAupsAttr);
127127

128-
if (!is_null($facilityAups)) {
128+
if ($facilityAups !== null) {
129129
foreach ($facilityAups as $facilityAup) {
130130
array_push($requiredAups, $facilityAup);
131131
}
@@ -136,7 +136,7 @@ public function process(&$request)
136136
$this->perunFacilityVoShortNames
137137
);
138138

139-
if (!is_null($facilityVoShortNames)) {
139+
if ($facilityVoShortNames !== null) {
140140
foreach ($facilityVoShortNames as $facilityVoShortName) {
141141
array_push($voShortNames, $facilityVoShortName);
142142
}
@@ -163,7 +163,7 @@ public function process(&$request)
163163
[$this->perunUserAupAttr]
164164
)[$this->perunUserAupAttr];
165165

166-
if (is_null($userAups)) {
166+
if ($userAups === null) {
167167
$userAups = [];
168168
}
169169

lib/Auth/Process/PerunAttributes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function process(&$request)
9797
$sspAttr = $this->attrMap[$attrName];
9898

9999
// convert $attrValue into array
100-
if (is_null($attrValue)) {
100+
if ($attrValue === null) {
101101
$value = [];
102102
} elseif (is_string($attrValue) || is_numeric($attrValue)) {
103103
$value = [$attrValue];

lib/Auth/Process/PerunIdentity.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public function process(&$request)
216216

217217
$groups = $this->adapter->getUsersGroupsOnFacility($this->spEntityId, $user->getId());
218218

219-
if ($this->checkGroupMembership && (is_null($groups) || empty($groups))) {
219+
if ($this->checkGroupMembership && ($groups === null || empty($groups))) {
220220
if ($this->allowRegistrationToGroups) {
221221
$vosForRegistration = $this->getVosForRegistration($user);
222222

@@ -262,11 +262,11 @@ public function process(&$request)
262262
*/
263263
public function register($request, $vosForRegistration, $registerUrL = null, $dynamicRegistration = null)
264264
{
265-
if (is_null($registerUrL)) {
265+
if ($registerUrL === null) {
266266
$registerUrL = $this->registerUrl;
267267
}
268268

269-
if (is_null($dynamicRegistration)) {
269+
if ($dynamicRegistration === null) {
270270
$dynamicRegistration = $this->dynamicRegistration;
271271
}
272272

@@ -305,9 +305,9 @@ public function register($request, $vosForRegistration, $registerUrL = null, $dy
305305
protected function registerDirectly($request, $callback, $registerUrL, $vo = null, $group = null)
306306
{
307307
$params = [];
308-
if (!is_null($vo)) {
308+
if ($vo !== null) {
309309
$params['vo'] = $vo->getShortName();
310-
if (!is_null($group)) {
310+
if ($group !== null) {
311311
$params['group'] = $group->getName();
312312
}
313313
}
@@ -441,7 +441,7 @@ protected function getSPAttributes($spEntityID)
441441
$facilities[0],
442442
$this->facilityCheckGroupMembershipAttr
443443
);
444-
if (!is_null($checkGroupMembership)) {
444+
if ($checkGroupMembership !== null) {
445445
$this->checkGroupMembership = $checkGroupMembership;
446446
}
447447

@@ -457,23 +457,23 @@ protected function getSPAttributes($spEntityID)
457457
$facilities[0],
458458
$this->facilityDynamicRegistrationAttr
459459
);
460-
if (!is_null($dynamicRegistration)) {
460+
if ($dynamicRegistration !== null) {
461461
$this->dynamicRegistration = $dynamicRegistration;
462462
}
463463

464464
$this->registerUrl = $this->rpcAdapter->getFacilityAttribute(
465465
$facilities[0],
466466
$this->facilityRegisterUrlAttr
467467
);
468-
if (is_null($this->registerUrl)) {
468+
if ($this->registerUrl === null) {
469469
$this->registerUrl = $this->defaultRegisterUrl;
470470
}
471471

472472
$allowRegistartionToGroups = $this->rpcAdapter->getFacilityAttribute(
473473
$facilities[0],
474474
$this->facilityAllowRegistrationToGroupsAttr
475475
);
476-
if (!is_null($allowRegistartionToGroups)) {
476+
if ($allowRegistartionToGroups !== null) {
477477
$this->allowRegistrationToGroups = $allowRegistartionToGroups;
478478
}
479479
} catch (\Exception $ex) {
@@ -491,14 +491,14 @@ protected function checkMemberStateDefaultVo($request, $user, $uids)
491491
$status = null;
492492
try {
493493
$vo = $this->adapter->getVoByShortName($this->voShortName);
494-
if (!is_null($user)) {
494+
if ($user !== null) {
495495
$status = $this->adapter->getMemberStatusByUserAndVo($user, $vo);
496496
}
497497
} catch (\Exception $ex) {
498498
throw new Exception('perun:PerunIdentity: ' . $ex);
499499
}
500500

501-
if (is_null($vo)) {
501+
if ($vo === null) {
502502
throw new Exception(
503503
'perun:PerunIdentity: Vo with short name ' . $this->voShortName . ' does not exist.'
504504
);
@@ -516,13 +516,13 @@ protected function checkMemberStateDefaultVo($request, $user, $uids)
516516
}
517517
}
518518

519-
if (is_null($user) || is_null($status) || $status === Member::EXPIRED) {
520-
if (is_null($user)) {
519+
if ($user === null || $status === null || $status === Member::EXPIRED) {
520+
if ($user === null) {
521521
Logger::info(
522522
'Perun user with identity/ies: ' . implode(',', $uids) . ' ' .
523523
'has NOT been found. He is being redirected to register.'
524524
);
525-
} elseif (is_null($status)) {
525+
} elseif ($status === null) {
526526
Logger::info(
527527
'Perun user with identity/ies: ' . implode(',', $uids) . ' ' .
528528
'is NOT member in vo with short name ' . $this->voShortName .

lib/Auth/Process/UpdateUserExtSource.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function process(&$request)
5050
$request['Attributes']['sourceIdPEntityID'][0],
5151
$request['Attributes']['sourceIdPEppn'][0]
5252
);
53-
if (is_null($userExtSource)) {
53+
if ($userExtSource === null) {
5454
throw new Exception(
5555
"sspmod_perun_Auth_Process_UpdateUserExtSource: there is no UserExtSource with ExtSource " .
5656
$request['Attributes']['sourceIdPEntityID'][0] . " and Login " .
@@ -60,7 +60,7 @@ public function process(&$request)
6060

6161
$attributes = $this->adapter->getUserExtSourceAttributes($userExtSource['id'], array_keys($this->attrMap));
6262

63-
if (is_null($attributes)) {
63+
if ($attributes === null) {
6464
throw new Exception(
6565
"sspmod_perun_Auth_Process_UpdateUserExtSource: getting attributes was not successful."
6666
);

lib/Disco.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct(array $metadataSets, $instance)
4747
$id = explode(":", $query['AuthID'])[0];
4848
$state = State::loadState($id, 'saml:sp:sso', true);
4949

50-
if (!is_null($state)) {
50+
if ($state !== null) {
5151
if (isset($state['saml:RequestedAuthnContext']['AuthnContextClassRef'])) {
5252
$this->authnContextClassRef = $state['saml:RequestedAuthnContext']['AuthnContextClassRef'];
5353
$this->removeAuthContextClassRefWithPrefix($state);
@@ -358,7 +358,7 @@ public function removeAuthContextClassRefWithPrefix(&$state)
358358
$conf = Configuration::getConfig(self::CONFIG_FILE_NAME);
359359
$prefix = $conf->getString(self::PROPNAME_PREFIX, null);
360360

361-
if (is_null($prefix)) {
361+
if ($prefix === null) {
362362
return;
363363
}
364364
unset($state['saml:RequestedAuthnContext']['AuthnContextClassRef']);

templates/listOfSps-tpl.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<th><?php echo $this->t('{perun:listOfSps:description}') ?></th>
9797
<?php
9898
foreach ($attributesToShow as $attr) {
99-
if (!is_null($samlServices) && !empty($samlServices)) {
99+
if ($samlServices !== null && !empty($samlServices)) {
100100
echo "<th class='" .
101101
getClass(array_values($samlServices)[0]['facilityAttributes'][$attr]) .
102102
"'>" . array_values($samlServices)[0]['facilityAttributes'][$attr]['displayName']
@@ -109,7 +109,7 @@
109109
<tbody>
110110
<?php
111111
foreach ($allServices as $service) {
112-
if (is_null($service['showOnServiceList']) || is_null($service['showOnServiceList']['value']) ||
112+
if ($service['showOnServiceList'] === null || $service['showOnServiceList']['value'] === null ||
113113
empty($service['showOnServiceList']['value']) ||
114114
!($service['showOnServiceList']['value'])
115115
) {
@@ -142,7 +142,7 @@
142142

143143
function printServiceName($service)
144144
{
145-
if (is_null($service['loginURL']) || is_null($service['loginURL']['value']) ||
145+
if ($service['loginURL'] === null || $service['loginURL']['value'] === null ||
146146
empty($service['loginURL']['value'])
147147
) {
148148
return $service['facility']->getName();
@@ -155,7 +155,7 @@ function printServiceName($service)
155155
function printAttributeValue($attribute, $service, $attr)
156156
{
157157
$value = $attribute['value'];
158-
if ((is_null($value) || empty($value)) && $attribute['type'] != "java.lang.Boolean") {
158+
if (($value === null || empty($value)) && $attribute['type'] != "java.lang.Boolean") {
159159
return "<td class='center'>&horbar;</td>";
160160
}
161161
$string = '';
@@ -168,7 +168,7 @@ function printAttributeValue($attribute, $service, $attr)
168168
} elseif ($attribute['type'] == "java.lang.Integer") {
169169
$string = $value;
170170
} elseif ($attribute['type'] == "java.lang.Boolean") {
171-
if (!is_null($value) && $value) {
171+
if ($value !== null && $value) {
172172
$string = "&#x2714;";
173173
} else {
174174
$string = "&#x2715;";

www/getSpMetadata.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@
2222
$conf = Configuration::getConfig(CONFIG_FILE_NAME);
2323

2424
$proxyIdentifier = $conf->getString(PROXY_IDENTIFIER);
25-
assert(is_null($proxyIdentifier) || empty($proxyIdentifier));
25+
assert($proxyIdentifier === null || empty($proxyIdentifier));
2626

2727
$attributesDefinitions = $conf->getArray(ATTRIBUTES_DEFINITIONS);
28-
assert(is_null($attributesDefinitions) || is_array($attributesDefinitions));
28+
assert($attributesDefinitions === null || is_array($attributesDefinitions));
2929

3030
$perunProxyIdentifierAttr = $conf->getString(PERUN_PROXY_IDENTIFIER_ATTR_NAME);
3131
$perunProxyEntityIDAttr = $conf->getString(PERUN_PROXY_ENTITY_ID_ATTR_NAME);
32-
assert(is_null($perunProxyEntityIDAttr) || empty($perunProxyEntityIDAttr) ||
33-
is_null($perunProxyIdentifierAttr) || empty($perunProxyIdentifierAttr));
32+
assert($perunProxyEntityIDAttr === null || empty($perunProxyEntityIDAttr) ||
33+
$perunProxyIdentifierAttr === null || empty($perunProxyIdentifierAttr));
3434

3535
$absoluteFileName = $conf->getString(ABSOLUTE_FILE_NAME);
36-
assert(is_null($absoluteFileName) || empty($absoluteFileName));
36+
assert($absoluteFileName === null || empty($absoluteFileName));
3737

3838
$rpcAdapter = new AdapterRpc();
3939

@@ -78,25 +78,25 @@
7878
$attribute = $facilityWithAttributes[FACILITY_ATTRIBUTES][$perunAttrName];
7979
if (($attribute['type'] === TYPE_INTEGER) &&
8080
is_numeric($attribute['value']) &&
81-
!is_null($attribute['value'])
81+
$attribute['value'] !== null
8282
) {
8383
$metadataContent .= "\t '" . $metadataAttrName . "' => " . $attribute['value'] . "," . PHP_EOL;
84-
} elseif (($attribute['type'] === TYPE_STRING) && !is_null($attribute['value'])) {
84+
} elseif (($attribute['type'] === TYPE_STRING) && $attribute['value'] !== null) {
8585
$metadataContent .= "\t '" . $metadataAttrName . "' => '" . $attribute['value'] . "'," . PHP_EOL;
8686
} elseif ($attribute['type'] === TYPE_BOOLEAN) {
8787
$metadataContent .= "\t '" . $metadataAttrName . "' => ";
88-
if (is_null($attribute['value']) || $attribute['value'] === 'false') {
88+
if ($attribute['value'] === null || $attribute['value'] === 'false') {
8989
$metadataContent .= "false," . PHP_EOL;
9090
} else {
9191
$metadataContent .= "true," . PHP_EOL;
9292
}
93-
} elseif ($attribute['type'] === TYPE_ARRAY && !is_null($attribute['value'])) {
93+
} elseif ($attribute['type'] === TYPE_ARRAY && $attribute['value'] !== null) {
9494
$metadataContent .= "\t '" . $metadataAttrName . "' => [" . PHP_EOL;
9595
foreach ($attribute['value'] as $value) {
9696
$metadataContent .= "\t\t'" . $value . "'," . PHP_EOL;
9797
}
9898
$metadataContent .= "\t]," . PHP_EOL;
99-
} elseif ($attribute['type'] === TYPE_MAP && !is_null($attribute['value'])) {
99+
} elseif ($attribute['type'] === TYPE_MAP && $attribute['value'] !== null) {
100100
$metadataContent .= "\t '" . $metadataAttrName . "' => [" . PHP_EOL;
101101
foreach ($attribute['value'] as $key => $value) {
102102
$metadataContent .= "\t\t'" . $key . "' => '" . $value . "'," . PHP_EOL;

0 commit comments

Comments
 (0)