Skip to content

Commit

Permalink
Reverting some of the changes
Browse files Browse the repository at this point in the history
  • Loading branch information
visto9259 committed Aug 8, 2024
1 parent b36cc81 commit 3a1a537
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 20 deletions.
10 changes: 4 additions & 6 deletions src/Rbac/Role/HierarchicalRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

namespace Rbac\Role;

use Traversable;

/**
* Simple implementation for a hierarchical role
*/
Expand All @@ -19,20 +17,20 @@ class HierarchicalRole extends Role implements HierarchicalRoleInterface
/**
* @var array|RoleInterface[]
*/
protected array $children = [];
protected $children = [];

/**
* {@inheritDoc}
*/
public function hasChildren(): bool
public function hasChildren()
{
return !empty($this->children);
}

/**
* {@inheritDoc}
*/
public function getChildren(): Traversable|array
public function getChildren()
{
return $this->children;
}
Expand All @@ -42,7 +40,7 @@ public function getChildren(): Traversable|array
*
* @param RoleInterface $child
*/
public function addChild(RoleInterface $child): void
public function addChild(RoleInterface $child)
{
$this->children[$child->getName()] = $child;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Rbac/Role/HierarchicalRoleInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ interface HierarchicalRoleInterface extends RoleInterface
*
* @return bool
*/
public function hasChildren(): bool;
public function hasChildren();

/**
* Get child roles
*
* @return array|RoleInterface[]|Traversable
*/
public function getChildren(): array|Traversable;
public function getChildren();
}
14 changes: 7 additions & 7 deletions src/Rbac/Role/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@ class Role implements RoleInterface
/**
* @var string
*/
protected string $name;
protected $name;

/**
* @var string[]
*/
protected array $permissions = [];
protected $permissions = [];

/**
* Constructor
*
* @param string $name
*/
public function __construct(string $name)
public function __construct($name)
{
$this->name = (string) $name;
}

/**
* {@inheritDoc}
*/
public function getName(): string
public function getName()
{
return $this->name;
}
Expand All @@ -48,18 +48,18 @@ public function getName(): string
*
* @param string $permission
*/
public function addPermission(string $permission): void
public function addPermission($permission)
{
$this->permissions[(string) $permission] = $permission;
}

/**
* Checks if a permission exists for this role
*
* @param mixed $permission
* @param string $permission
* @return bool
*/
public function hasPermission(mixed $permission): bool
public function hasPermission($permission)
{
return isset($this->permissions[(string) $permission]);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Rbac/Role/RoleInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ interface RoleInterface
*
* @return string
*/
public function getName(): string;
public function getName();

/**
* Checks if a permission exists for this role (it does not check child roles)
*
* @param mixed $permission
* @return bool
*/
public function hasPermission(mixed $permission): bool;
public function hasPermission($permission);
}
2 changes: 1 addition & 1 deletion src/Rbac/Traversal/Strategy/GeneratorStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GeneratorStrategy implements TraversalStrategyInterface
* @param RoleInterface[]|Traversable $roles
* @return Generator
*/
public function getRolesIterator($roles): Generator
public function getRolesIterator($roles)
{
foreach ($roles as $role) {
yield $role;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class RecursiveRoleIteratorStrategy implements TraversalStrategyInterface
* @param RoleInterface[] $roles
* @return RecursiveIteratorIterator
*/
public function getRolesIterator($roles): RecursiveIteratorIterator
public function getRolesIterator($roles)
{
return new RecursiveIteratorIterator(
new RecursiveRoleIterator($roles),
Expand Down
2 changes: 1 addition & 1 deletion src/Rbac/Traversal/Strategy/TraversalStrategyInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ interface TraversalStrategyInterface
* @param RoleInterface[]|Traversable
* @return Traversable
*/
public function getRolesIterator($roles): Traversable;
public function getRolesIterator($roles);
}

0 comments on commit 3a1a537

Please sign in to comment.