numberOfParameters = $numberOfParameters; } /** * @throws InvalidArgumentException */ public function filter(string $property, ?object $instance = null): bool { try { $reflectionMethod = $instance !== null ? new ReflectionMethod($instance, $property) : new ReflectionMethod($property); } catch (ReflectionException $exception) { throw new InvalidArgumentException(sprintf( 'Method %s does not exist', $property )); } return $reflectionMethod->getNumberOfParameters() === $this->numberOfParameters; } }