Skip to content

Commit

Permalink
make phpstan happy 😎
Browse files Browse the repository at this point in the history
  • Loading branch information
bezhanSalleh committed Aug 25, 2023
1 parent a28b9fa commit ee043cc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Resources/RoleResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,14 @@ public static function experimentalGetEntityPermissions(array $entity): array

public static function experimentalSetEntityStateWhenRecordHasPermission(Component $component, Model $record, array $entity) {

if (is_null($record)) {
if (blank($record)) {
return;
}

$component->state(
collect(static::experimentalGetEntityPermissions($entity))
->reduce(function ($permissions, $value, $key) use($record) {
/** @phpstan-ignore-next-line */
if ($record->checkPermissionTo($key)) {
$permissions[] = $key;
}
Expand Down Expand Up @@ -388,12 +389,13 @@ public static function experimentalGetWidgetPermissions(): array

public static function experimentalSetWidgetsStateWhenRecordHasPermission(Component $component, Model $record) {

if (is_null($record)) {
if (blank($record)) {
return;
}

$component->state(
collect(static::experimentalGetWidgetPermissions())
/** @phpstan-ignore-next-line */
->filter(fn($value, $key) => $record->checkPermissionTo($key))
->keys()
->toArray()
Expand All @@ -411,12 +413,13 @@ public static function experimentalGetPagePermissions(): array

public static function experimentalSetPagesStateWhenRecordHasPermission(Component $component, Model $record) {

if (is_null($record)) {
if (blank($record)) {
return;
}

$component->state(
collect(static::experimentalGetPagePermissions())
/** @phpstan-ignore-next-line */
->filter(fn($value, $key) => $record->checkPermissionTo($key))
->keys()
->toArray()
Expand All @@ -434,12 +437,13 @@ public static function experimentalGetCustomPermissions(): array

public static function experimentalSetCustomPermissionsStateWhenRecordHasPermission(Component $component, Model $record)
{
if (is_null($record)) {
if (blank($record)) {
return;
}

$component->state(
collect(static::experimentalGetCustomPermissions())
/** @phpstan-ignore-next-line */
->filter(fn($value, $key) => $record->checkPermissionTo($key))
->keys()
->toArray()
Expand Down

0 comments on commit ee043cc

Please sign in to comment.