Skip to content

Commit 185bc49

Browse files
committed
update libs
1 parent 5847b9e commit 185bc49

File tree

4 files changed

+41
-9
lines changed

4 files changed

+41
-9
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"license": "MIT",
44
"description": "",
55
"require": {
6-
"php": ">=8.1",
6+
"php": ">=8.3",
77
"phpunit/phpunit": "*"
88
},
99
"keywords": ["rbac", "permissions"],
@@ -21,7 +21,7 @@
2121
}
2222
},
2323
"require-dev": {
24-
"vimeo/psalm": "^5.15",
25-
"psalm/plugin-symfony": "^5.0"
24+
"vimeo/psalm": "^6.11",
25+
"psalm/plugin-symfony": "^5.2"
2626
}
2727
}

src/entities/Permission.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111
namespace mstodulski\RbacWithPermissions\entities;
1212

1313
use mstodulski\RbacWithPermissions\interfaces\PermissionInterface;
14+
use Override;
1415

16+
/**
17+
* psalm notice: https://psalm.dev/361
18+
* wyjaśnienie: psalm nie wie tego, że ta klasa może być nadpisana w projekcie używającym tej biblioteki
19+
* @psalm-suppress ClassMustBeFinal
20+
*/
1521
class Permission implements PermissionInterface
1622
{
1723
/** @var ?Permission|?PermissionInterface */
@@ -25,6 +31,7 @@ public function setCode(string $code): void
2531
$this->code = $code;
2632
}
2733

34+
#[Override]
2835
public function getCode(): string
2936
{
3037
return $this->code;
@@ -40,6 +47,7 @@ public function setName(string $name): void
4047
$this->name = $name;
4148
}
4249

50+
#[Override]
4351
public function getParent(): ?PermissionInterface
4452
{
4553
return $this->parent;

src/entities/Role.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212

1313
use mstodulski\RbacWithPermissions\interfaces\PermissionInterface;
1414
use mstodulski\RbacWithPermissions\interfaces\RoleInterface;
15+
use Override;
1516

17+
/**
18+
* psalm notice: https://psalm.dev/361
19+
* wyjaśnienie: psalm nie wie tego, że ta klasa może być nadpisana w projekcie używającym tej biblioteki
20+
* @psalm-suppress ClassMustBeFinal
21+
*/
1622
class Role implements RoleInterface
1723
{
1824
private string $code = '';
@@ -24,6 +30,7 @@ class Role implements RoleInterface
2430
private bool $hasAllPermissions = false;
2531
public mixed $children = null;
2632

33+
#[Override]
2734
public function getCode(): string
2835
{
2936
return $this->code;
@@ -44,6 +51,7 @@ public function setName(string $name): void
4451
$this->name = $name;
4552
}
4653

54+
#[Override]
4755
public function getParent(): ?RoleInterface
4856
{
4957
return $this->parent;
@@ -54,6 +62,7 @@ public function setParent(?RoleInterface $parent): void
5462
$this->parent = $parent;
5563
}
5664

65+
#[Override]
5766
public function getPermissions(): array
5867
{
5968
return $this->permissions;
@@ -69,6 +78,7 @@ public function addPermission(PermissionInterface $permission): void
6978
$this->permissions[$permission->getCode()] = $permission;
7079
}
7180

81+
#[Override]
7282
public function isHasAllPermissions(): bool
7383
{
7484
return $this->hasAllPermissions;

src/services/Authorization.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
use mstodulski\RbacWithPermissions\interfaces\PermissionInterface;
1616
use mstodulski\RbacWithPermissions\interfaces\RoleInterface;
1717

18+
/**
19+
* psalm notice: https://psalm.dev/361
20+
* wyjaśnienie: psalm nie wie tego, że ta klasa może być nadpisana w projekcie używającym tej biblioteki
21+
* @psalm-suppress ClassMustBeFinal
22+
*/
1823
class Authorization {
1924

2025
private array $roles = [];
@@ -106,10 +111,14 @@ public function getAllSubRolesAndPermissionsForRole(RoleInterface $role): array
106111
return [$rolesArray, $permissionsArray];
107112
}
108113

109-
private function getSubPermissionsForPermissions(array &$permissionsArray, array $permissionsTree = null) : void
114+
/**
115+
* @param array<array-key, string> $permissionsArray
116+
* @param null|array<array-key, PermissionInterface> $permissionsTree
117+
* @return void
118+
*/
119+
private function getSubPermissionsForPermissions(array &$permissionsArray, ?array $permissionsTree = null) : void
110120
{
111-
if (!empty($permissionsTree)) {
112-
/** @var PermissionInterface $permission */
121+
if (is_array($permissionsTree) && count($permissionsTree) > 0) {
113122
foreach ($permissionsTree as $permission) {
114123
if (in_array($permission->getCode(), $permissionsArray)) {
115124
/** @var Permission $permission */
@@ -129,10 +138,15 @@ private function getSubPermissionsForPermissions(array &$permissionsArray, array
129138
}
130139
}
131140

132-
private function getSubRolesCodes(array &$rolesArray, array &$permissionsArray, array $rolesTree = null) : void
141+
/**
142+
* @param array<array-key, string> $rolesArray
143+
* @param array<array-key, mixed|string> $permissionsArray
144+
* @param null|array<array-key, RoleInterface> $rolesTree
145+
* @return void
146+
*/
147+
private function getSubRolesCodes(array &$rolesArray, array &$permissionsArray, ?array $rolesTree = null) : void
133148
{
134-
if (!empty($rolesTree)) {
135-
/** @var RoleInterface $role */
149+
if (is_array($rolesTree) && count($rolesTree) > 0) {
136150
foreach ($rolesTree as $role) {
137151
if (in_array($role->getCode(), $rolesArray)) {
138152
foreach ($role->getPermissions() as $permission) {

0 commit comments

Comments
 (0)