Skip to content

Commit

Permalink
PHPstan fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
s3b4stian committed Dec 13, 2023
1 parent e54eb30 commit 89bcfa0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/Linna/Authorization/PermissionExtended.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class PermissionExtended extends Permission
* @param string $name Permission name.
* @param string $description Permission description.
* @param integer $inherited Specify if the permission is inherited from a group.
* @param array<User> $users Users who hold the specific permission.
* @param array<Role> $roles Roles who hold the specific permission.
* @param DateTimeImmutable|null $created Creation datetime.
* @param DateTimeImmutable|null $lastUpdate Last updated datetime.
*/
Expand Down
11 changes: 6 additions & 5 deletions src/Linna/Authorization/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ class Role extends DomainObjectAbstract
/**
* Constructor.
*
* @param string $name The name of the role.
* @param string $description The description of the role.
* @param integer $active Specify is the role is atctive.
* @param array<mixed> $users Users in role.
* @param array<mixed> $permissions Permissions granted by the role.
* @param null|int|string $id Permission id.
* @param string $name The name of the role.
* @param string $description The description of the role.
* @param integer $active Specify is the role is atctive.
* @param DateTimeImmutable|null $created Creation datetime.
* @param DateTimeImmutable|null $lastUpdate Last updated datetime.
*/
public function __construct(
//role id
Expand Down
3 changes: 2 additions & 1 deletion src/Linna/Authorization/UserExtended.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class UserExtended extends User
*/
public function __construct(
/** @var Password Password class for manage password. */
private Password $passwordUtility = new Password(),
Password $passwordUtility = new Password(),

//user id
null|int|string $id = null,
Expand Down Expand Up @@ -82,6 +82,7 @@ public function __construct(
id: $id,
uuid: $uuid,
name: $name,
email: $email,
description: $description,
password: $password,
active: $active,
Expand Down
4 changes: 4 additions & 0 deletions src/Linna/Cache/RedisCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ public function clear(): bool
*/
public function has(string $key): bool
{
//https://github.com/phpredis/phpredis#exists
//PHPstan should not trigger the error because ecists return only a long and
//$this->redis is surely an instance of Redis class
/** @phpstan-ignore-next-line */
if ($this->redis->exists($key) > 0) {
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Linna/Authentication/EnhancedAuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function testGetAttemptsLeftWithSameUser(): void
$sessionId = 'mbvi2lgdpcj6vp3qemh2estei2';
$ipAddress = '192.168.1.2';

for ($i = 0; $i < 4; $i++){
for ($i = 0; $i < 4; $i++) {
$this->storeLoginAttempt($user, $sessionId, $ipAddress);
}

Expand All @@ -151,7 +151,7 @@ public function testGetAttemptsLeftWithSameSession(): void
$sessionId = 'vaqgvpochtif8gh888q6vnlch5';
$ipAddress = '192.168.1.3';

for ($i = 0; $i < 9; $i++){
for ($i = 0; $i < 9; $i++) {
$this->storeLoginAttempt($user, $sessionId, $ipAddress);
}

Expand All @@ -176,7 +176,7 @@ public function testGetAttemptsLeftWithSameIp(): void
$sessionId = '3hto06tko273jjc1se0v1aqvvn';
$ipAddress = '192.168.1.4';

for ($i = 0; $i < 19; $i++){
for ($i = 0; $i < 19; $i++) {
$this->storeLoginAttempt($user, $sessionId, $ipAddress);
}

Expand Down

0 comments on commit 89bcfa0

Please sign in to comment.