Skip to content

Commit

Permalink
Merge pull request #1480 from gmponos/remove-call-user-func
Browse files Browse the repository at this point in the history
Replace call_user_func
  • Loading branch information
Seldaek committed Jul 9, 2020
2 parents 53e2c97 + a54cd1f commit 69b585f
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Monolog/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function handleException($e)
);

if ($this->previousExceptionHandler) {
call_user_func($this->previousExceptionHandler, $e);
($this->previousExceptionHandler)($e);
}

if (!headers_sent() && !ini_get('display_errors')) {
Expand Down Expand Up @@ -198,7 +198,7 @@ public function handleError($code, $message, $file = '', $line = 0, $context = [
if ($this->previousErrorHandler === true) {
return false;
} elseif ($this->previousErrorHandler) {
return call_user_func($this->previousErrorHandler, $code, $message, $file, $line, $context);
return ($this->previousErrorHandler)($code, $message, $file, $line, $context);
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Handler/FilterHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function handleBatch(array $records): void
public function getHandler(array $record = null)
{
if (!$this->handler instanceof HandlerInterface) {
$this->handler = call_user_func($this->handler, $record, $this);
$this->handler = ($this->handler)($record, $this);
if (!$this->handler instanceof HandlerInterface) {
throw new \RuntimeException("The factory callable should return a HandlerInterface");
}
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Handler/FingersCrossedHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private function flushBuffer(): void
public function getHandler(array $record = null)
{
if (!$this->handler instanceof HandlerInterface) {
$this->handler = call_user_func($this->handler, $record, $this);
$this->handler = ($this->handler)($record, $this);
if (!$this->handler instanceof HandlerInterface) {
throw new \RuntimeException("The factory callable should return a HandlerInterface");
}
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Handler/MandrillHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(string $apiKey, $message, $level = Logger::ERROR, bo
parent::__construct($level, $bubble);

if (!$message instanceof \Swift_Message && is_callable($message)) {
$message = call_user_func($message);
$message = $message();
}
if (!$message instanceof \Swift_Message) {
throw new \InvalidArgumentException('You must provide either a Swift_Message instance or a callable returning it');
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Handler/SamplingHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function handle(array $record): bool
public function getHandler(array $record = null)
{
if (!$this->handler instanceof HandlerInterface) {
$this->handler = call_user_func($this->handler, $record, $this);
$this->handler = ($this->handler)($record, $this);
if (!$this->handler instanceof HandlerInterface) {
throw new \RuntimeException("The factory callable should return a HandlerInterface");
}
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Handler/SwiftMailerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function buildMessage(string $content, array $records): Swift_Message
$message = clone $this->messageTemplate;
$message->generateId();
} elseif (is_callable($this->messageTemplate)) {
$message = call_user_func($this->messageTemplate, $content, $records);
$message = ($this->messageTemplate)($content, $records);
}

if (!$message instanceof Swift_Message) {
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Handler/TestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function hasRecordThatPasses(callable $predicate, $level)
}

foreach ($this->recordsByLevel[$level] as $i => $rec) {
if (call_user_func($predicate, $rec, $i)) {
if ($predicate($rec, $i)) {
return true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Monolog/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public function addRecord(int $level, string $message, array $context = []): boo

try {
foreach ($this->processors as $processor) {
$record = call_user_func($processor, $record);
$record = $processor($record);
}

// advance the array pointer to the first handler that will handle this record
Expand Down Expand Up @@ -610,6 +610,6 @@ protected function handleException(Throwable $e, array $record)
throw $e;
}

call_user_func($this->exceptionHandler, $e, $record);
($this->exceptionHandler)($e, $record);
}
}

0 comments on commit 69b585f

Please sign in to comment.