Procházet zdrojové kódy

Update a few more callable to Closure

Jordi Boggiano před 3 roky
rodič
revize
a7de8dd0c2

+ 3 - 3
src/Monolog/Handler/FilterHandler.php

@@ -55,7 +55,7 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese
     /**
      * @phpstan-param (Closure(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface $handler
      *
-     * @param Closure|HandlerInterface                                                 $handler        Handler or factory callable($record|null, $filterHandler).
+     * @param Closure|HandlerInterface                                                 $handler        Handler or factory Closure($record|null, $filterHandler).
      * @param int|string|Level|LevelName|array<int|string|Level|LevelName|LogLevel::*> $minLevelOrList A list of levels to accept or a minimum level if maxLevel is provided
      * @param int|string|Level|LevelName|LogLevel::*                                   $maxLevel       Maximum level to accept, only used if $minLevelOrList is not an array
      * @param bool                                                                     $bubble         Whether the messages that are handled can bubble up the stack or not
@@ -148,14 +148,14 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese
     /**
      * Return the nested handler
      *
-     * If the handler was provided as a factory callable, this will trigger the handler's instantiation.
+     * If the handler was provided as a factory, this will trigger the handler's instantiation.
      */
     public function getHandler(LogRecord $record = null): HandlerInterface
     {
         if (!$this->handler instanceof HandlerInterface) {
             $handler = ($this->handler)($record, $this);
             if (!$handler instanceof HandlerInterface) {
-                throw new \RuntimeException("The factory callable should return a HandlerInterface");
+                throw new \RuntimeException("The factory Closure should return a HandlerInterface");
             }
             $this->handler = $handler;
         }

+ 4 - 4
src/Monolog/Handler/FingersCrossedHandler.php

@@ -43,7 +43,7 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
     use ProcessableHandlerTrait;
 
     /**
-     * Handler or factory callable($record, $this)
+     * Handler or factory Closure($record, $this)
      *
      * @phpstan-var (Closure(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface
      */
@@ -67,7 +67,7 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
     /**
      * @phpstan-param (Closure(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface $handler
      *
-     * @param Closure|HandlerInterface                    $handler            Handler or factory callable($record|null, $fingersCrossedHandler).
+     * @param Closure|HandlerInterface                    $handler            Handler or factory Closure($record|null, $fingersCrossedHandler).
      * @param int|string|Level|LevelName|LogLevel::*      $activationStrategy Strategy which determines when this handler takes action, or a level name/value at which the handler is activated
      * @param int                                         $bufferSize         How many entries should be buffered at most, beyond that the oldest items are removed from the buffer.
      * @param bool                                        $bubble             Whether the messages that are handled can bubble up the stack or not
@@ -198,14 +198,14 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
     /**
      * Return the nested handler
      *
-     * If the handler was provided as a factory callable, this will trigger the handler's instantiation.
+     * If the handler was provided as a factory, this will trigger the handler's instantiation.
      */
     public function getHandler(LogRecord $record = null): HandlerInterface
     {
         if (!$this->handler instanceof HandlerInterface) {
             $handler = ($this->handler)($record, $this);
             if (!$handler instanceof HandlerInterface) {
-                throw new \RuntimeException("The factory callable should return a HandlerInterface");
+                throw new \RuntimeException("The factory Closure should return a HandlerInterface");
             }
             $this->handler = $handler;
         }

+ 4 - 4
src/Monolog/Handler/SamplingHandler.php

@@ -34,7 +34,7 @@ class SamplingHandler extends AbstractHandler implements ProcessableHandlerInter
     use ProcessableHandlerTrait;
 
     /**
-     * Handler or factory callable($record, $this)
+     * Handler or factory Closure($record, $this)
      *
      * @phpstan-var (Closure(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface
      */
@@ -45,7 +45,7 @@ class SamplingHandler extends AbstractHandler implements ProcessableHandlerInter
     /**
      * @phpstan-param (Closure(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface $handler
      *
-     * @param Closure|HandlerInterface $handler Handler or factory callable($record|null, $samplingHandler).
+     * @param Closure|HandlerInterface $handler Handler or factory Closure($record|null, $samplingHandler).
      * @param int                      $factor  Sample factor (e.g. 10 means every ~10th record is sampled)
      */
     public function __construct(Closure|HandlerInterface $handler, int $factor)
@@ -76,14 +76,14 @@ class SamplingHandler extends AbstractHandler implements ProcessableHandlerInter
     /**
      * Return the nested handler
      *
-     * If the handler was provided as a factory callable, this will trigger the handler's instantiation.
+     * If the handler was provided as a factory, this will trigger the handler's instantiation.
      */
     public function getHandler(LogRecord $record = null): HandlerInterface
     {
         if (!$this->handler instanceof HandlerInterface) {
             $handler = ($this->handler)($record, $this);
             if (!$handler instanceof HandlerInterface) {
-                throw new \RuntimeException("The factory callable should return a HandlerInterface");
+                throw new \RuntimeException("The factory Closure should return a HandlerInterface");
             }
             $this->handler = $handler;
         }

+ 6 - 2
src/Monolog/Logger.php

@@ -212,8 +212,10 @@ class Logger implements LoggerInterface, ResettableInterface
 
     /**
      * Adds a processor on to the stack.
+     *
+     * @phpstan-param ProcessorInterface|(callable(LogRecord): LogRecord) $callback
      */
-    public function pushProcessor(callable $callback): self
+    public function pushProcessor(ProcessorInterface|callable $callback): self
     {
         array_unshift($this->processors, $callback);
 
@@ -223,6 +225,7 @@ class Logger implements LoggerInterface, ResettableInterface
     /**
      * Removes the processor on top of the stack and returns it.
      *
+     * @phpstan-return ProcessorInterface|(callable(LogRecord): LogRecord)
      * @throws \LogicException If empty processor stack
      */
     public function popProcessor(): callable
@@ -236,6 +239,7 @@ class Logger implements LoggerInterface, ResettableInterface
 
     /**
      * @return callable[]
+     * @phpstan-return array<ProcessorInterface|(callable(LogRecord): LogRecord)>
      */
     public function getProcessors(): array
     {
@@ -433,7 +437,7 @@ class Logger implements LoggerInterface, ResettableInterface
     /**
      * Set a custom exception handler that will be called if adding a new record fails
      *
-     * The callable will receive an exception object and the record that failed to be logged
+     * The Closure will receive an exception object and the record that failed to be logged
      */
     public function setExceptionHandler(Closure|null $callback): self
     {