Skip to content

Commit

Permalink
Fix phpstan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rojtjo committed Dec 4, 2023
1 parent 078d0da commit 7942403
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/FindListeners.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Rojtjo\LaravelAutoSubscriber;

use Illuminate\Support\Collection;
use ReflectionIntersectionType;
use ReflectionMethod;
use ReflectionNamedType;
use ReflectionUnionType;
Expand Down Expand Up @@ -38,17 +39,20 @@ private static function hasOneClassParameter(): callable
}

$type = $parameter->getType();
$types = [$type];
if ($type instanceof ReflectionUnionType) {
$types = $type->getTypes();
if ($type instanceof ReflectionIntersectionType) {
return false;
}

$types = $type instanceof ReflectionUnionType
? $type->getTypes()
: [$type];

foreach ($types as $type) {
if ($type->isBuiltin()) {
if (! $type instanceof ReflectionNamedType) {
return false;
}

if (! $type instanceof ReflectionNamedType) {
if ($type->isBuiltin()) {
return false;
}
}
Expand All @@ -69,12 +73,11 @@ private static function eventName(): callable
return function (ReflectionMethod $method) {
[$parameter] = $method->getParameters();

/** @var ReflectionNamedType $type */
/** @var ReflectionNamedType|ReflectionUnionType $type */
$type = $parameter->getType();
$types = [$type];
if ($type instanceof ReflectionUnionType) {
$types = $type->getTypes();
}
$types = $type instanceof ReflectionUnionType
? $type->getTypes()
: [$type];

return array_map(
fn (ReflectionNamedType $type) => $type->getName(),
Expand Down

0 comments on commit 7942403

Please sign in to comment.