1818 */
1919class Permission implements Authorizator
2020{
21+ /** @var array<string, array{parents: array<string, true>, children: array<string, true>}> */
2122 private array $ roles = [];
23+
24+ /** @var array<string, array{parent: ?string, children: array<string, true>}> */
2225 private array $ resources = [];
2326
24- /** Access Control List rules; whitelist (deny everything to all) by default */
27+ /** @var array<string, mixed> Access Control List rules; whitelist (deny everything to all) by default */
2528 private array $ rules = [
2629 'allResources ' => [
2730 'allRoles ' => [
@@ -46,6 +49,7 @@ class Permission implements Authorizator
4649 /**
4750 * Adds a Role to the list. The most recently added parent
4851 * takes precedence over parents that were previously added.
52+ * @param string|string[]|null $parents
4953 * @throws Nette\InvalidArgumentException
5054 * @throws Nette\InvalidStateException
5155 */
@@ -106,6 +110,7 @@ private function checkRole(string $role, bool $exists = true): void
106110
107111 /**
108112 * Returns all Roles.
113+ * @return list<string>
109114 */
110115 public function getRoles (): array
111116 {
@@ -115,6 +120,7 @@ public function getRoles(): array
115120
116121 /**
117122 * Returns existing Role's parents ordered by ascending priority.
123+ * @return list<string>
118124 */
119125 public function getRoleParents (string $ role ): array
120126 {
@@ -267,6 +273,7 @@ private function checkResource(string $resource, bool $exists = true): void
267273
268274 /**
269275 * Returns all Resources.
276+ * @return list<string>
270277 */
271278 public function getResources (): array
272279 {
@@ -365,6 +372,10 @@ public function removeAllResources(): static
365372 /**
366373 * Allows one or more Roles access to [certain $privileges upon] the specified Resource(s).
367374 * If $assertion is provided, then it must return true in order for rule to apply.
375+ * @param string|string[]|null $roles
376+ * @param string|string[]|null $resources
377+ * @param string|string[]|null $privileges
378+ * @param callable(self, ?string, ?string, ?string): bool $assertion
368379 */
369380 public function allow (
370381 string |array |null $ roles = self ::All,
@@ -381,6 +392,10 @@ public function allow(
381392 /**
382393 * Denies one or more Roles access to [certain $privileges upon] the specified Resource(s).
383394 * If $assertion is provided, then it must return true in order for rule to apply.
395+ * @param string|string[]|null $roles
396+ * @param string|string[]|null $resources
397+ * @param string|string[]|null $privileges
398+ * @param callable(self, ?string, ?string, ?string): bool $assertion
384399 */
385400 public function deny (
386401 string |array |null $ roles = self ::All,
@@ -396,6 +411,9 @@ public function deny(
396411
397412 /**
398413 * Removes "allow" permissions from the list in the context of the given Roles, Resources, and privileges.
414+ * @param string|string[]|null $roles
415+ * @param string|string[]|null $resources
416+ * @param string|string[]|null $privileges
399417 */
400418 public function removeAllow (
401419 string |array |null $ roles = self ::All,
@@ -410,6 +428,9 @@ public function removeAllow(
410428
411429 /**
412430 * Removes "deny" restrictions from the list in the context of the given Roles, Resources, and privileges.
431+ * @param string|string[]|null $roles
432+ * @param string|string[]|null $resources
433+ * @param string|string[]|null $privileges
413434 */
414435 public function removeDeny (
415436 string |array |null $ roles = self ::All,
@@ -424,6 +445,10 @@ public function removeDeny(
424445
425446 /**
426447 * Performs operations on Access Control List rules.
448+ * @param string|string[]|null $roles
449+ * @param string|string[]|null $resources
450+ * @param string|string[]|null $privileges
451+ * @param callable(self, ?string, ?string, ?string): bool $assertion
427452 * @throws Nette\InvalidStateException
428453 */
429454 protected function setRule (
@@ -711,6 +736,7 @@ private function getRuleType(?string $resource, ?string $role, ?string $privileg
711736 /**
712737 * Returns the rules associated with a Resource and a Role, or null if no such rules exist.
713738 * If the $create parameter is true, then a rule set is first created and then returned to the caller.
739+ * @return array<string, mixed>|null
714740 */
715741 private function &getRules (?string $ resource , ?string $ role , bool $ create = false ): ?array
716742 {
0 commit comments