Skip to content

Commit 2215c18

Browse files
authored
Remove unnecessary InvalidArgumentExceptions (elastic#1069)
There are some locations where an object is type hinted and inside the method a check is performed to verify the type again. This is not necessary as PHP will take care of this. A consequence of this is that these methods no longer throw an instance of `\Elasticsearch\Common\Exceptions\InvalidArgumentException` but of `\InvalidArgumentException`. As theres no PHPDoc indicating that the aforementioned exception is thrown by these methods I dont see any issues with this.
1 parent c60f704 commit 2215c18

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

src/Elasticsearch/ClientBuilder.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,21 +305,13 @@ public function setHandler($handler): ClientBuilder
305305

306306
public function setLogger(LoggerInterface $logger): ClientBuilder
307307
{
308-
if (!$logger instanceof LoggerInterface) {
309-
throw new InvalidArgumentException('$logger must implement \Psr\Log\LoggerInterface!');
310-
}
311-
312308
$this->logger = $logger;
313309

314310
return $this;
315311
}
316312

317313
public function setTracer(LoggerInterface $tracer): ClientBuilder
318314
{
319-
if (!$tracer instanceof LoggerInterface) {
320-
throw new InvalidArgumentException('$tracer must implement \Psr\Log\LoggerInterface!');
321-
}
322-
323315
$this->tracer = $tracer;
324316

325317
return $this;

0 commit comments

Comments
 (0)