1111use function str_replace ;
1212use function var_export ;
1313
14+ /**
15+ * @psalm-suppress ClassMustBeFinal
16+ */
1417class GenericPermission implements PermissionInterface {
1518
1619 protected string $ action = '' ;
@@ -38,7 +41,7 @@ class GenericPermission implements PermissionInterface {
3841 * You must add default values for each parameter the callback accepts.
3942 * @param mixed ...$argsForCallback zero or more arguments to be used to invoke $additionalAssertions
4043 */
41- public function __construct (string $ action , string $ resource , protected bool $ allowActionOnResource = true , callable $ additionalAssertions = null , mixed ...$ argsForCallback ) {
44+ public function __construct (string $ action , string $ resource , protected bool $ allowActionOnResource = true , ? callable $ additionalAssertions = null , mixed ...$ argsForCallback ) {
4245
4346 $ this ->action = Utils::strToLower ($ action );
4447 $ this ->resource = Utils::strToLower ($ resource );
@@ -53,6 +56,7 @@ public function __construct(string $action, string $resource, protected bool $a
5356 *
5457 * @return PermissionsCollectionInterface a new and empty collection that is meant to house one or more instances of PermissionInterface
5558 */
59+ #[\Override]
5660 public static function createCollection (PermissionInterface ...$ permissions ): PermissionsCollectionInterface {
5761
5862 return new GenericPermissionsCollection (...$ permissions );
@@ -65,6 +69,7 @@ public static function createCollection(PermissionInterface ...$permissions): Pe
6569 *
6670 * @return string a string representing an action that can be performed on a resource in the system
6771 */
72+ #[\Override]
6873 public function getAction (): string {
6974
7075 return $ this ->action ;
@@ -80,6 +85,7 @@ public function getAction(): string {
8085 *
8186 * @return string a string value that represents all actions that can be performed on all resources in the system.
8287 */
88+ #[\Override]
8389 public static function getAllActionsIdentifier (): string {
8490
8591 return '* ' ;
@@ -92,6 +98,7 @@ public static function getAllActionsIdentifier(): string {
9298 *
9399 * @return string a string representing a resource in the system
94100 */
101+ #[\Override]
95102 public function getResource (): string {
96103
97104 return $ this ->resource ;
@@ -107,6 +114,7 @@ public function getResource(): string {
107114 *
108115 * @return string a string value that represents all resources in the system.
109116 */
117+ #[\Override]
110118 public static function getAllResourcesIdentifier (): string {
111119
112120 return '* ' ;
@@ -119,6 +127,7 @@ public static function getAllResourcesIdentifier(): string {
119127 *
120128 * @return bool a boolean value indicating whether or not an instance of this class signifies that an action can be performed on a resource.
121129 */
130+ #[\Override]
122131 public function getAllowActionOnResource (): bool {
123132
124133 return $ this ->allowActionOnResource ;
@@ -131,6 +140,7 @@ public function getAllowActionOnResource(): bool {
131140 *
132141 * @return $this
133142 */
143+ #[\Override]
134144 public function setAllowActionOnResource (bool $ allowActionOnResource ): PermissionInterface {
135145
136146 $ this ->allowActionOnResource = $ allowActionOnResource ;
@@ -155,7 +165,8 @@ public function setAllowActionOnResource(bool $allowActionOnResource): Permissio
155165 *
156166 * @return bool return true if an instance of this class signifies that a specified action can be performed on a specified resource, or false otherwise
157167 */
158- public function isAllowed (string $ action , string $ resource , callable $ additionalAssertions = null , mixed ...$ argsForCallback ): bool {
168+ #[\Override]
169+ public function isAllowed (string $ action , string $ resource , ?callable $ additionalAssertions = null , mixed ...$ argsForCallback ): bool {
159170
160171 if ( $ additionalAssertions === null && $ this ->additionalAssertions !== null ) {
161172
@@ -197,6 +208,7 @@ public function isAllowed(string $action, string $resource, callable $additional
197208 *
198209 *
199210 */
211+ #[\Override]
200212 public function isEqualTo (PermissionInterface $ permission ): bool {
201213
202214 return Utils::strSameIgnoreCase ($ this ->getAction (), $ permission ->getAction ())
0 commit comments