Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Jun 28, 2024
1 parent 3ba77d1 commit 07cd08e
Show file tree
Hide file tree
Showing 34 changed files with 106 additions and 91 deletions.
4 changes: 2 additions & 2 deletions src/Monolog/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ public function registerErrorHandler(array $levelMap = [], bool $callPrevious =
}

/**
* @param LogLevel::*|null $level a LogLevel::* constant, null to use the default LogLevel::ALERT
* @param int $reservedMemorySize Amount of KBs to reserve in memory so that it can be freed when handling fatal errors giving Monolog some room in memory to get its job done
* @param LogLevel::*|null $level a LogLevel::* constant, null to use the default LogLevel::ALERT
* @param int $reservedMemorySize Amount of KBs to reserve in memory so that it can be freed when handling fatal errors giving Monolog some room in memory to get its job done
* @return $this
*/
public function registerFatalHandler($level = null, int $reservedMemorySize = 20): self
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Formatter/HtmlFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function getLevelColor(Level $level): string
}

/**
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(?string $dateFormat = null)
Expand Down
5 changes: 3 additions & 2 deletions src/Monolog/Formatter/LineFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function includeStacktraces(bool $include = true, ?Closure $parser = null
/**
* Indent stack traces to separate them a bit from the main log record messages
*
* @param string $indent The string used to indent, for example " "
* @param string $indent The string used to indent, for example " "
* @return $this
*/
public function indentStacktraces(string $indent): self
Expand Down Expand Up @@ -117,7 +117,7 @@ public function ignoreEmptyContextAndExtra(bool $ignore = true): self
/**
* Allows cutting the level name to get fixed-length levels like INF for INFO, ERR for ERROR if you set this to 3 for example
*
* @param int|null $maxLevelNameLength Maximum characters for the level name. Set null for infinite length (default)
* @param int|null $maxLevelNameLength Maximum characters for the level name. Set null for infinite length (default)
* @return $this
*/
public function setMaxLevelNameLength(?int $maxLevelNameLength = null): self
Expand Down Expand Up @@ -244,6 +244,7 @@ protected function replaceNewlines(string $str): string
$str = preg_replace('/(?<!\\\\)\\\\[rn]/', "\n", $str);
if (null === $str) {
$pcreErrorCode = preg_last_error();

throw new \RuntimeException('Failed to run preg_replace: ' . $pcreErrorCode . ' / ' . Utils::pcreLastErrorMessage($pcreErrorCode));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Formatter/NormalizerFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class NormalizerFormatter implements FormatterInterface
protected string $basePath = '';

/**
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(?string $dateFormat = null)
Expand Down
1 change: 0 additions & 1 deletion src/Monolog/Formatter/SyslogFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public function format(LogRecord $record): string
}

/**
* @param LogRecord $record
* @return array<string, mixed>
*/
private function formatExtra(LogRecord $record): array
Expand Down
8 changes: 4 additions & 4 deletions src/Monolog/Handler/AbstractHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ abstract class AbstractHandler extends Handler implements ResettableInterface

/**
* @param int|string|Level|LogLevel::* $level The minimum logging level at which this handler will be triggered
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*
* @phpstan-param value-of<Level::VALUES>|value-of<Level::NAMES>|Level|LogLevel::* $level
*/
Expand All @@ -50,7 +50,7 @@ public function isHandling(LogRecord $record): bool
/**
* Sets minimum logging level at which this handler will be triggered.
*
* @param Level|LogLevel::* $level Level or level name
* @param Level|LogLevel::* $level Level or level name
* @return $this
*
* @phpstan-param value-of<Level::VALUES>|value-of<Level::NAMES>|Level|LogLevel::* $level
Expand All @@ -73,8 +73,8 @@ public function getLevel(): Level
/**
* Sets the bubbling behavior.
*
* @param bool $bubble true means that this handler allows bubbling.
* false means that bubbling is not permitted.
* @param bool $bubble true means that this handler allows bubbling.
* false means that bubbling is not permitted.
* @return $this
*/
public function setBubble(bool $bubble): self
Expand Down
4 changes: 3 additions & 1 deletion src/Monolog/Handler/AmqpHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function getExtraAttributes(): array
/**
* Configure extra attributes to pass to the AMQPExchange (if you are using the amqp extension)
*
* @param array<string, mixed> $extraAttributes One of content_type, content_encoding,
* @param array<string, mixed> $extraAttributes One of content_type, content_encoding,
* message_id, user_id, app_id, delivery_mode,
* priority, timestamp, expiration, type
* or reply_to, headers.
Expand All @@ -65,6 +65,7 @@ public function getExtraAttributes(): array
public function setExtraAttributes(array $extraAttributes): self
{
$this->extraAttributes = $extraAttributes;

return $this;
}

Expand Down Expand Up @@ -155,6 +156,7 @@ private function createAmqpMessage(string $data): AMQPMessage
if (\count($this->extraAttributes) > 0) {
$attributes = array_merge($attributes, $this->extraAttributes);
}

return new AMQPMessage($data, $attributes);
}

Expand Down
1 change: 0 additions & 1 deletion src/Monolog/Handler/BrowserConsoleHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Monolog\LogRecord;
use Monolog\Level;

use function count;
use function headers_list;
use function stripos;

Expand Down
8 changes: 4 additions & 4 deletions src/Monolog/Handler/DeduplicationHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ class DeduplicationHandler extends BufferHandler
protected bool $gc = false;

/**
* @param HandlerInterface $handler Handler.
* @param string|null $deduplicationStore The file/path where the deduplication log should be kept
* @param HandlerInterface $handler Handler.
* @param string|null $deduplicationStore The file/path where the deduplication log should be kept
* @param int|string|Level|LogLevel::* $deduplicationLevel The minimum logging level for log records to be looked at for deduplication purposes
* @param int $time The period (in seconds) during which duplicate entries should be suppressed after a given log is sent through
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
* @param int $time The period (in seconds) during which duplicate entries should be suppressed after a given log is sent through
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*
* @phpstan-param value-of<Level::VALUES>|value-of<Level::NAMES>|Level|LogLevel::* $deduplicationLevel
*/
Expand Down
10 changes: 5 additions & 5 deletions src/Monolog/Handler/FilterHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese
/**
* @phpstan-param (Closure(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface $handler
*
* @param Closure|HandlerInterface $handler Handler or factory Closure($record|null, $filterHandler).
* @param Closure|HandlerInterface $handler Handler or factory Closure($record|null, $filterHandler).
* @param int|string|Level|array<int|string|Level|LogLevel::*> $minLevelOrList A list of levels to accept or a minimum level if maxLevel is provided
* @param int|string|Level|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
* @param int|string|Level|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
*
* @phpstan-param value-of<Level::VALUES>|value-of<Level::NAMES>|Level|LogLevel::*|array<value-of<Level::VALUES>|value-of<Level::NAMES>|Level|LogLevel::*> $minLevelOrList
* @phpstan-param value-of<Level::VALUES>|value-of<Level::NAMES>|Level|LogLevel::* $maxLevel
Expand All @@ -78,8 +78,8 @@ public function getAcceptedLevels(): array
}

/**
* @param int|string|Level|LogLevel::*|array<int|string|Level|LogLevel::*> $minLevelOrList A list of levels to accept or a minimum level or level name if maxLevel is provided
* @param int|string|Level|LogLevel::* $maxLevel Maximum level or level name to accept, only used if $minLevelOrList is not an array
* @param int|string|Level|LogLevel::*|array<int|string|Level|LogLevel::*> $minLevelOrList A list of levels to accept or a minimum level or level name if maxLevel is provided
* @param int|string|Level|LogLevel::* $maxLevel Maximum level or level name to accept, only used if $minLevelOrList is not an array
* @return $this
*
* @phpstan-param value-of<Level::VALUES>|value-of<Level::NAMES>|Level|LogLevel::*|array<value-of<Level::VALUES>|value-of<Level::NAMES>|Level|LogLevel::*> $minLevelOrList
Expand Down
8 changes: 4 additions & 4 deletions src/Monolog/Handler/FingersCrossedHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
/**
* @phpstan-param (Closure(LogRecord|null, HandlerInterface): HandlerInterface)|HandlerInterface $handler
*
* @param Closure|HandlerInterface $handler Handler or factory Closure($record|null, $fingersCrossedHandler).
* @param Closure|HandlerInterface $handler Handler or factory Closure($record|null, $fingersCrossedHandler).
* @param int|string|Level|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
* @param bool $stopBuffering Whether the handler should stop buffering after being triggered (default true)
* @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
* @param bool $stopBuffering Whether the handler should stop buffering after being triggered (default true)
* @param int|string|Level|LogLevel::*|null $passthruLevel Minimum level to always flush to handler on close, even if strategy not triggered
*
* @phpstan-param value-of<Level::VALUES>|value-of<Level::NAMES>|Level|LogLevel::*|ActivationStrategyInterface $activationStrategy
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Handler/HandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function isHandling(LogRecord $record): bool;
*
* @param LogRecord $record The record to handle
* @return bool true means that this handler handled the record, and that bubbling is not permitted.
* false means the record was either not processed or that this handler allows bubbling.
* false means the record was either not processed or that this handler allows bubbling.
*/
public function handle(LogRecord $record): bool;

Expand Down
5 changes: 2 additions & 3 deletions src/Monolog/Handler/LogglyHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Monolog\Level;
use Monolog\Formatter\FormatterInterface;
use Monolog\Formatter\LogglyFormatter;
use function array_key_exists;
use CurlHandle;
use Monolog\LogRecord;

Expand Down Expand Up @@ -88,7 +87,7 @@ private function loadCurlHandle(string $endpoint): CurlHandle
}

/**
* @param string[]|string $tag
* @param string[]|string $tag
* @return $this
*/
public function setTag(string|array $tag): self
Expand All @@ -103,7 +102,7 @@ public function setTag(string|array $tag): self
}

/**
* @param string[]|string $tag
* @param string[]|string $tag
* @return $this
*/
public function addTag(string|array $tag): self
Expand Down
6 changes: 3 additions & 3 deletions src/Monolog/Handler/NativeMailerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function __construct(string|array $to, string $subject, string $from, int
/**
* Add headers to the message
*
* @param string|string[] $headers Custom added headers
* @param string|string[] $headers Custom added headers
* @return $this
*/
public function addHeader($headers): self
Expand All @@ -96,7 +96,7 @@ public function addHeader($headers): self
/**
* Add parameters to the message
*
* @param string|string[] $parameters Custom added parameters
* @param string|string[] $parameters Custom added parameters
* @return $this
*/
public function addParameter($parameters): self
Expand Down Expand Up @@ -143,7 +143,7 @@ public function getEncoding(): string
}

/**
* @param string $contentType The content type of the email - Defaults to text/plain. Use text/html for HTML messages.
* @param string $contentType The content type of the email - Defaults to text/plain. Use text/html for HTML messages.
* @return $this
*/
public function setContentType(string $contentType): self
Expand Down
8 changes: 4 additions & 4 deletions src/Monolog/Handler/PushoverHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ class PushoverHandler extends SocketHandler
* to be retried for (every retry seconds).
*
* @param int|string|Level|LogLevel::* $highPriorityLevel The minimum logging level at which this handler will start
* sending "high priority" requests to the Pushover API
* sending "high priority" requests to the Pushover API
* @param int|string|Level|LogLevel::* $emergencyLevel The minimum logging level at which this handler will start
* sending "emergency" requests to the Pushover API
* sending "emergency" requests to the Pushover API
*
*
* @phpstan-param string|array<int|string> $users
Expand Down Expand Up @@ -207,7 +207,7 @@ protected function write(LogRecord $record): void
}

/**
* @param int|string|Level|LogLevel::* $level
* @param int|string|Level|LogLevel::* $level
* @return $this
*
* @phpstan-param value-of<Level::VALUES>|value-of<Level::NAMES>|Level|LogLevel::* $level
Expand All @@ -220,7 +220,7 @@ public function setHighPriorityLevel(int|string|Level $level): self
}

/**
* @param int|string|Level|LogLevel::* $level
* @param int|string|Level|LogLevel::* $level
* @return $this
*
* @phpstan-param value-of<Level::VALUES>|value-of<Level::NAMES>|Level|LogLevel::* $level
Expand Down
4 changes: 2 additions & 2 deletions src/Monolog/Handler/RotatingFileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ protected function getGlobPattern(): string
[$fileInfo['filename'], str_replace(
['Y', 'y', 'm', 'd'],
['[0-9][0-9][0-9][0-9]', '[0-9][0-9]', '[0-9][0-9]', '[0-9][0-9]'],
$this->dateFormat)
],
$this->dateFormat
)],
($fileInfo['dirname'] ?? '') . '/' . $this->filenameFormat
);
if (isset($fileInfo['extension'])) {
Expand Down
6 changes: 3 additions & 3 deletions src/Monolog/Handler/Slack/SlackRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public function stringify(array $fields): string
/**
* Channel used by the bot when posting
*
* @param ?string $channel
* @param ?string $channel
* @return $this
*/
public function setChannel(?string $channel = null): self
Expand All @@ -233,7 +233,7 @@ public function setChannel(?string $channel = null): self
/**
* Username used by the bot when posting
*
* @param ?string $username
* @param ?string $username
* @return $this
*/
public function setUsername(?string $username = null): self
Expand Down Expand Up @@ -292,7 +292,7 @@ public function includeContextAndExtra(bool $includeContextAndExtra = false): se
}

/**
* @param string[] $excludeFields
* @param string[] $excludeFields
* @return $this
*/
public function excludeFields(array $excludeFields = []): self
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Handler/SlackHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public function includeContextAndExtra(bool $includeContextAndExtra): self
}

/**
* @param string[] $excludeFields
* @param string[] $excludeFields
* @return $this
*/
public function excludeFields(array $excludeFields): self
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Handler/SocketHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function setTimeout(float $seconds): self
/**
* Set writing timeout. Only has effect during connection in the writing cycle.
*
* @param float $seconds 0 for no timeout
* @param float $seconds 0 for no timeout
* @return $this
*/
public function setWritingTimeout(float $seconds): self
Expand Down
1 change: 1 addition & 0 deletions src/Monolog/Handler/StreamHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ protected function write(LogRecord $record): void
set_error_handler(function (...$args) {
return $this->customErrorHandler(...$args);
});

try {
$stream = fopen($url, 'a');
if ($this->filePermission !== null) {
Expand Down
6 changes: 3 additions & 3 deletions src/Monolog/Handler/SymfonyMailerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use Closure;
use Monolog\Level;
use Monolog\Logger;
use Monolog\LogRecord;
use Monolog\Utils;
use Monolog\Formatter\FormatterInterface;
Expand Down Expand Up @@ -68,8 +67,8 @@ protected function getSubjectFormatter(?string $format): FormatterInterface
/**
* Creates instance of Email to be sent
*
* @param string $content formatted email body to be sent
* @param LogRecord[] $records Log records that formed the content
* @param string $content formatted email body to be sent
* @param LogRecord[] $records Log records that formed the content
*/
protected function buildMessage(string $content, array $records): Email
{
Expand All @@ -82,6 +81,7 @@ protected function buildMessage(string $content, array $records): Email

if (!$message instanceof Email) {
$record = reset($records);

throw new \InvalidArgumentException('Could not resolve message as instance of Email or a callable returning it' . ($record instanceof LogRecord ? Utils::getRecordMessageForException($record) : ''));
}

Expand Down
1 change: 0 additions & 1 deletion src/Monolog/Handler/SyslogHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Monolog\Handler;

use Monolog\Level;
use Monolog\Utils;
use Monolog\LogRecord;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Monolog/Level.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ enum Level: int
case Emergency = 600;

/**
* @param value-of<self::NAMES>|LogLevel::*|'Debug'|'Info'|'Notice'|'Warning'|'Error'|'Critical'|'Alert'|'Emergency' $name
* @param value-of<self::NAMES>|LogLevel::*|'Debug'|'Info'|'Notice'|'Warning'|'Error'|'Critical'|'Alert'|'Emergency' $name
* @return static
*/
public static function fromName(string $name): self
Expand All @@ -100,7 +100,7 @@ public static function fromName(string $name): self
}

/**
* @param value-of<self::VALUES> $value
* @param value-of<self::VALUES> $value
* @return static
*/
public static function fromValue(int $value): self
Expand Down
Loading

0 comments on commit 07cd08e

Please sign in to comment.