Skip to content

Commit

Permalink
Fix PHPStan fails
Browse files Browse the repository at this point in the history
  • Loading branch information
oprypkhantc committed Aug 8, 2023
1 parent 18fcf0d commit 775dc9e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 8 deletions.
4 changes: 0 additions & 4 deletions src/Middlewares/AuthorizationFieldMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,15 @@ public function process(QueryFieldDescriptor $queryFieldDescriptor, FieldHandler
$annotations = $queryFieldDescriptor->getMiddlewareAnnotations();

$loggedAnnotation = $annotations->getAnnotationByType(Logged::class);
assert($loggedAnnotation === null || $loggedAnnotation instanceof Logged);
$rightAnnotation = $annotations->getAnnotationByType(Right::class);
assert($rightAnnotation === null || $rightAnnotation instanceof Right);

// Avoid wrapping resolver callback when no annotations are specified.
if (! $loggedAnnotation && ! $rightAnnotation) {
return $fieldHandler->handle($queryFieldDescriptor);
}

$failWith = $annotations->getAnnotationByType(FailWith::class);
assert($failWith === null || $failWith instanceof FailWith);
$hideIfUnauthorized = $annotations->getAnnotationByType(HideIfUnauthorized::class);
assert($hideIfUnauthorized instanceof HideIfUnauthorized || $hideIfUnauthorized === null);

if ($failWith !== null && $hideIfUnauthorized !== null) {
throw IncompatibleAnnotationsException::cannotUseFailWithAndHide();
Expand Down
3 changes: 0 additions & 3 deletions src/Middlewares/AuthorizationInputFieldMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,14 @@ public function process(InputFieldDescriptor $inputFieldDescriptor, InputFieldHa
$annotations = $inputFieldDescriptor->getMiddlewareAnnotations();

$loggedAnnotation = $annotations->getAnnotationByType(Logged::class);
assert($loggedAnnotation === null || $loggedAnnotation instanceof Logged);
$rightAnnotation = $annotations->getAnnotationByType(Right::class);
assert($rightAnnotation === null || $rightAnnotation instanceof Right);

// Avoid wrapping resolver callback when no annotations are specified.
if (! $loggedAnnotation && ! $rightAnnotation) {
return $inputFieldHandler->handle($inputFieldDescriptor);
}

$hideIfUnauthorized = $annotations->getAnnotationByType(HideIfUnauthorized::class);
assert($hideIfUnauthorized instanceof HideIfUnauthorized || $hideIfUnauthorized === null);

if ($hideIfUnauthorized !== null && ! $this->isAuthorized($loggedAnnotation, $rightAnnotation)) {
return null;
Expand Down
1 change: 0 additions & 1 deletion src/Middlewares/SecurityFieldMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public function process(QueryFieldDescriptor $queryFieldDescriptor, FieldHandler
}

$failWith = $annotations->getAnnotationByType(FailWith::class);
assert($failWith instanceof FailWith || $failWith === null);

// If the failWith value is null and the return type is non nullable, we must set it to nullable.
$makeReturnTypeNullable = false;
Expand Down

0 comments on commit 775dc9e

Please sign in to comment.