Skip to content

Commit bfa34e5

Browse files
authored
phpstan level 8 (#559)
1 parent 30b940e commit bfa34e5

File tree

5 files changed

+12
-2
lines changed

5 files changed

+12
-2
lines changed

phpstan.neon

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: 7
2+
level: 8
33
paths:
44
- resources
55
- webroot
@@ -19,6 +19,8 @@ parameters:
1919
- '#array\|bool supplied for foreach, only iterables are supported#'
2020
- '#Cannot access offset \S+ on \S+\|bool#'
2121
- '#ldap_get_entries expects LDAP\\Result, array\|LDAP\\Result given#'
22+
- '#array_key_exists expects array, array\|null given#'
23+
- '#array\|null supplied for foreach, only iterables are supported#'
2224
paths:
2325
- resources/lib/phpopenldaper
2426
- messages:

resources/lib/UnityHTTPD.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ public static function getPostData(string $key): string
243243
return $_POST[$key];
244244
}
245245

246-
/* returns null if not found and not $die_if_not_found */
246+
/**
247+
* @return ($die_if_not_found is true ? string : string|null)
248+
*/
247249
public static function getQueryParameter(string $key, bool $die_if_not_found = true): ?string
248250
{
249251
if (!array_key_exists($key, $_GET)) {

resources/lib/UnityLDAP.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace UnityWebPortal\lib;
44

5+
use RuntimeException;
56
use UnityWebPortal\lib\exceptions\EntryNotFoundException;
67
use PHPOpenLDAPer\LDAPConn;
78
use PHPOpenLDAPer\LDAPEntry;
@@ -147,6 +148,9 @@ private function getCustomIDMappings(): array
147148
}
148149
$output_map = [];
149150
foreach ($output as [$uid, $uidNumber_str]) {
151+
if ($uidNumber_str === null) {
152+
throw new RuntimeException("uidNumber_str is null");
153+
}
150154
$output_map[$uid] = digits2int($uidNumber_str);
151155
}
152156
return $output_map;

test/functional/PIRemoveUserTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public function testRemoveUser($methodName)
5858
break;
5959
}
6060
}
61+
assert($memberToDelete !== null);
6162
$this->assertNotEquals($pi->uid, $memberToDelete->uid);
6263
$this->assertTrue($memberToDelete->getFlag(UserFlag::QUALIFIED));
6364
$this->assertTrue($piGroup->memberUIDExists($memberToDelete->uid));

test/phpunit-bootstrap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ function switchUser(
558558

559559
function switchBackUser(bool $validate = false)
560560
{
561+
assert($this->last_user_nickname !== null);
561562
$this->switchUser($this->last_user_nickname, validate: $validate);
562563
}
563564

0 commit comments

Comments
 (0)