Skip to content

Commit

Permalink
phpstan fix
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Dec 28, 2024
1 parent 8d50f6d commit 87743da
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/Assert/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,32 @@

namespace ArrayLookup\Assert;

use Closure;
use InvalidArgumentException;
use ReflectionFunction;
use ReflectionMethod;
use ReflectionNamedType;
use TypeError;
use Webmozart\Assert\Assert;

use function sprintf;

final class Filter
{
public static function boolean(callable $filter): void
{
try {
if ($filter instanceof Closure) {
$reflection = new ReflectionFunction($filter);
} catch (TypeError) {
} elseif (is_object($filter)) {
$reflection = new ReflectionMethod($filter, '__invoke');
} else {
Assert::string($filter);

if (! str_contains($filter, '::')) {
$reflection = new ReflectionFunction($filter);
} else {
[, $method] = explode('::', $filter);
$reflection = new ReflectionMethod($filter, $method);
}
}

$returnType = $reflection->getReturnType();
Expand Down

0 comments on commit 87743da

Please sign in to comment.