Skip to content

Commit feb05f8

Browse files
timoschinkelezimuel
authored andcommitted
Remove unnecessary InvalidArgumentExceptions (#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 3c7d84c commit feb05f8

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
@@ -317,21 +317,13 @@ public function setHandler($handler): ClientBuilder
317317

318318
public function setLogger(LoggerInterface $logger): ClientBuilder
319319
{
320-
if (!$logger instanceof LoggerInterface) {
321-
throw new InvalidArgumentException('$logger must implement \Psr\Log\LoggerInterface!');
322-
}
323-
324320
$this->logger = $logger;
325321

326322
return $this;
327323
}
328324

329325
public function setTracer(LoggerInterface $tracer): ClientBuilder
330326
{
331-
if (!$tracer instanceof LoggerInterface) {
332-
throw new InvalidArgumentException('$tracer must implement \Psr\Log\LoggerInterface!');
333-
}
334-
335327
$this->tracer = $tracer;
336328

337329
return $this;

0 commit comments

Comments
 (0)