diff --git a/src/Monolog/ErrorHandler.php b/src/Monolog/ErrorHandler.php index 594e64b2..08d414b3 100644 --- a/src/Monolog/ErrorHandler.php +++ b/src/Monolog/ErrorHandler.php @@ -63,7 +63,7 @@ class ErrorHandler * @param array|false $errorLevelMap an array of E_* constant to LogLevel::* constant mapping, or false to disable error handling * @param array|false $exceptionLevelMap an array of class name to LogLevel::* constant mapping, or false to disable exception handling * @param LogLevel::*|null|false $fatalLevel a LogLevel::* constant, null to use the default LogLevel::ALERT or false to disable fatal error handling - * @return ErrorHandler + * @return static */ public static function register(LoggerInterface $logger, $errorLevelMap = [], $exceptionLevelMap = [], $fatalLevel = null): self { @@ -126,6 +126,7 @@ class ErrorHandler /** * @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 { diff --git a/src/Monolog/Formatter/JsonFormatter.php b/src/Monolog/Formatter/JsonFormatter.php index 039c38dd..ca3d7d27 100644 --- a/src/Monolog/Formatter/JsonFormatter.php +++ b/src/Monolog/Formatter/JsonFormatter.php @@ -107,6 +107,9 @@ class JsonFormatter extends NormalizerFormatter }; } + /** + * @return $this + */ public function includeStacktraces(bool $include = true): self { $this->includeStacktraces = $include; diff --git a/src/Monolog/Formatter/LineFormatter.php b/src/Monolog/Formatter/LineFormatter.php index 76ac7700..5d559923 100644 --- a/src/Monolog/Formatter/LineFormatter.php +++ b/src/Monolog/Formatter/LineFormatter.php @@ -49,6 +49,9 @@ class LineFormatter extends NormalizerFormatter parent::__construct($dateFormat); } + /** + * @return $this + */ public function includeStacktraces(bool $include = true, ?Closure $parser = null): self { $this->includeStacktraces = $include; @@ -60,6 +63,9 @@ class LineFormatter extends NormalizerFormatter return $this; } + /** + * @return $this + */ public function allowInlineLineBreaks(bool $allow = true): self { $this->allowInlineLineBreaks = $allow; @@ -67,6 +73,9 @@ class LineFormatter extends NormalizerFormatter return $this; } + /** + * @return $this + */ public function ignoreEmptyContextAndExtra(bool $ignore = true): self { $this->ignoreEmptyContextAndExtra = $ignore; diff --git a/src/Monolog/Formatter/LogmaticFormatter.php b/src/Monolog/Formatter/LogmaticFormatter.php index 10ad0d9c..9e44c19f 100644 --- a/src/Monolog/Formatter/LogmaticFormatter.php +++ b/src/Monolog/Formatter/LogmaticFormatter.php @@ -26,6 +26,9 @@ class LogmaticFormatter extends JsonFormatter protected string $appName = ''; + /** + * @return $this + */ public function setHostname(string $hostname): self { $this->hostname = $hostname; @@ -33,6 +36,9 @@ class LogmaticFormatter extends JsonFormatter return $this; } + /** + * @return $this + */ public function setAppName(string $appName): self { $this->appName = $appName; diff --git a/src/Monolog/Formatter/MongoDBFormatter.php b/src/Monolog/Formatter/MongoDBFormatter.php index a3bdd4f8..9b7da8a9 100644 --- a/src/Monolog/Formatter/MongoDBFormatter.php +++ b/src/Monolog/Formatter/MongoDBFormatter.php @@ -154,7 +154,6 @@ class MongoDBFormatter implements FormatterInterface ? (int) $milliseconds : (string) $milliseconds; - // @phpstan-ignore-next-line return new UTCDateTime($milliseconds); } } diff --git a/src/Monolog/Formatter/NormalizerFormatter.php b/src/Monolog/Formatter/NormalizerFormatter.php index b1214f07..b8534b29 100644 --- a/src/Monolog/Formatter/NormalizerFormatter.php +++ b/src/Monolog/Formatter/NormalizerFormatter.php @@ -78,6 +78,9 @@ class NormalizerFormatter implements FormatterInterface return $this->dateFormat; } + /** + * @return $this + */ public function setDateFormat(string $dateFormat): self { $this->dateFormat = $dateFormat; @@ -93,6 +96,9 @@ class NormalizerFormatter implements FormatterInterface return $this->maxNormalizeDepth; } + /** + * @return $this + */ public function setMaxNormalizeDepth(int $maxNormalizeDepth): self { $this->maxNormalizeDepth = $maxNormalizeDepth; @@ -108,6 +114,9 @@ class NormalizerFormatter implements FormatterInterface return $this->maxNormalizeItemCount; } + /** + * @return $this + */ public function setMaxNormalizeItemCount(int $maxNormalizeItemCount): self { $this->maxNormalizeItemCount = $maxNormalizeItemCount; @@ -117,6 +126,8 @@ class NormalizerFormatter implements FormatterInterface /** * Enables `json_encode` pretty print. + * + * @return $this */ public function setJsonPrettyPrint(bool $enable): self { @@ -289,6 +300,9 @@ class NormalizerFormatter implements FormatterInterface return $date->format($this->dateFormat); } + /** + * @return $this + */ public function addJsonEncodeOption(int $option): self { $this->jsonEncodeOptions |= $option; @@ -296,6 +310,9 @@ class NormalizerFormatter implements FormatterInterface return $this; } + /** + * @return $this + */ public function removeJsonEncodeOption(int $option): self { $this->jsonEncodeOptions &= ~$option; diff --git a/src/Monolog/Handler/AbstractHandler.php b/src/Monolog/Handler/AbstractHandler.php index 3399a54e..d3c2cbd7 100644 --- a/src/Monolog/Handler/AbstractHandler.php +++ b/src/Monolog/Handler/AbstractHandler.php @@ -51,6 +51,7 @@ abstract class AbstractHandler extends Handler implements ResettableInterface * Sets minimum logging level at which this handler will be triggered. * * @param Level|LogLevel::* $level Level or level name + * @return $this * * @phpstan-param value-of|value-of|Level|LogLevel::* $level */ @@ -74,6 +75,7 @@ abstract class AbstractHandler extends Handler implements ResettableInterface * * @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 { diff --git a/src/Monolog/Handler/FilterHandler.php b/src/Monolog/Handler/FilterHandler.php index 00381ab4..5fa558e1 100644 --- a/src/Monolog/Handler/FilterHandler.php +++ b/src/Monolog/Handler/FilterHandler.php @@ -80,6 +80,7 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese /** * @param int|string|Level|LogLevel::*|array $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|value-of|Level|LogLevel::*|array|value-of|Level|LogLevel::*> $minLevelOrList * @phpstan-param value-of|value-of|Level|LogLevel::* $maxLevel diff --git a/src/Monolog/Handler/LogglyHandler.php b/src/Monolog/Handler/LogglyHandler.php index 2d8e66f1..b16fe656 100644 --- a/src/Monolog/Handler/LogglyHandler.php +++ b/src/Monolog/Handler/LogglyHandler.php @@ -89,6 +89,7 @@ class LogglyHandler extends AbstractProcessingHandler /** * @param string[]|string $tag + * @return $this */ public function setTag(string|array $tag): self { @@ -103,6 +104,7 @@ class LogglyHandler extends AbstractProcessingHandler /** * @param string[]|string $tag + * @return $this */ public function addTag(string|array $tag): self { diff --git a/src/Monolog/Handler/NativeMailerHandler.php b/src/Monolog/Handler/NativeMailerHandler.php index d4c9d801..70d6004e 100644 --- a/src/Monolog/Handler/NativeMailerHandler.php +++ b/src/Monolog/Handler/NativeMailerHandler.php @@ -79,6 +79,7 @@ class NativeMailerHandler extends MailHandler * Add headers to the message * * @param string|string[] $headers Custom added headers + * @return $this */ public function addHeader($headers): self { @@ -96,6 +97,7 @@ class NativeMailerHandler extends MailHandler * Add parameters to the message * * @param string|string[] $parameters Custom added parameters + * @return $this */ public function addParameter($parameters): self { @@ -142,6 +144,7 @@ class NativeMailerHandler extends MailHandler /** * @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 { @@ -154,6 +157,9 @@ class NativeMailerHandler extends MailHandler return $this; } + /** + * @return $this + */ public function setEncoding(string $encoding): self { if (strpos($encoding, "\n") !== false || strpos($encoding, "\r") !== false) { diff --git a/src/Monolog/Handler/PushoverHandler.php b/src/Monolog/Handler/PushoverHandler.php index 118f5760..615f1219 100644 --- a/src/Monolog/Handler/PushoverHandler.php +++ b/src/Monolog/Handler/PushoverHandler.php @@ -208,6 +208,7 @@ class PushoverHandler extends SocketHandler /** * @param int|string|Level|LogLevel::* $level + * @return $this * * @phpstan-param value-of|value-of|Level|LogLevel::* $level */ @@ -220,6 +221,7 @@ class PushoverHandler extends SocketHandler /** * @param int|string|Level|LogLevel::* $level + * @return $this * * @phpstan-param value-of|value-of|Level|LogLevel::* $level */ @@ -232,6 +234,8 @@ class PushoverHandler extends SocketHandler /** * Use the formatted message? + * + * @return $this */ public function useFormattedMessage(bool $useFormattedMessage): self { diff --git a/src/Monolog/Handler/RotatingFileHandler.php b/src/Monolog/Handler/RotatingFileHandler.php index 75081db5..86240b44 100644 --- a/src/Monolog/Handler/RotatingFileHandler.php +++ b/src/Monolog/Handler/RotatingFileHandler.php @@ -77,6 +77,9 @@ class RotatingFileHandler extends StreamHandler } } + /** + * @return $this + */ public function setFilenameFormat(string $filenameFormat, string $dateFormat): self { $this->setDateFormat($dateFormat); diff --git a/src/Monolog/Handler/Slack/SlackRecord.php b/src/Monolog/Handler/Slack/SlackRecord.php index 7e9cccc9..147d8f80 100644 --- a/src/Monolog/Handler/Slack/SlackRecord.php +++ b/src/Monolog/Handler/Slack/SlackRecord.php @@ -221,8 +221,7 @@ class SlackRecord * Channel used by the bot when posting * * @param ?string $channel - * - * @return static + * @return $this */ public function setChannel(?string $channel = null): self { @@ -235,8 +234,7 @@ class SlackRecord * Username used by the bot when posting * * @param ?string $username - * - * @return static + * @return $this */ public function setUsername(?string $username = null): self { @@ -245,6 +243,9 @@ class SlackRecord return $this; } + /** + * @return $this + */ public function useAttachment(bool $useAttachment = true): self { $this->useAttachment = $useAttachment; @@ -252,6 +253,9 @@ class SlackRecord return $this; } + /** + * @return $this + */ public function setUserIcon(?string $userIcon = null): self { $this->userIcon = $userIcon; @@ -263,6 +267,9 @@ class SlackRecord return $this; } + /** + * @return $this + */ public function useShortAttachment(bool $useShortAttachment = false): self { $this->useShortAttachment = $useShortAttachment; @@ -270,6 +277,9 @@ class SlackRecord return $this; } + /** + * @return $this + */ public function includeContextAndExtra(bool $includeContextAndExtra = false): self { $this->includeContextAndExtra = $includeContextAndExtra; @@ -283,6 +293,7 @@ class SlackRecord /** * @param string[] $excludeFields + * @return $this */ public function excludeFields(array $excludeFields = []): self { @@ -291,6 +302,9 @@ class SlackRecord return $this; } + /** + * @return $this + */ public function setFormatter(?FormatterInterface $formatter = null): self { $this->formatter = $formatter; diff --git a/src/Monolog/Handler/SlackHandler.php b/src/Monolog/Handler/SlackHandler.php index 321d8660..1d9a1771 100644 --- a/src/Monolog/Handler/SlackHandler.php +++ b/src/Monolog/Handler/SlackHandler.php @@ -192,6 +192,8 @@ class SlackHandler extends SocketHandler /** * Channel used by the bot when posting + * + * @return $this */ public function setChannel(string $channel): self { @@ -202,6 +204,8 @@ class SlackHandler extends SocketHandler /** * Username used by the bot when posting + * + * @return $this */ public function setUsername(string $username): self { @@ -210,6 +214,9 @@ class SlackHandler extends SocketHandler return $this; } + /** + * @return $this + */ public function useAttachment(bool $useAttachment): self { $this->slackRecord->useAttachment($useAttachment); @@ -217,6 +224,9 @@ class SlackHandler extends SocketHandler return $this; } + /** + * @return $this + */ public function setIconEmoji(string $iconEmoji): self { $this->slackRecord->setUserIcon($iconEmoji); @@ -224,6 +234,9 @@ class SlackHandler extends SocketHandler return $this; } + /** + * @return $this + */ public function useShortAttachment(bool $useShortAttachment): self { $this->slackRecord->useShortAttachment($useShortAttachment); @@ -231,6 +244,9 @@ class SlackHandler extends SocketHandler return $this; } + /** + * @return $this + */ public function includeContextAndExtra(bool $includeContextAndExtra): self { $this->slackRecord->includeContextAndExtra($includeContextAndExtra); @@ -240,6 +256,7 @@ class SlackHandler extends SocketHandler /** * @param string[] $excludeFields + * @return $this */ public function excludeFields(array $excludeFields): self { diff --git a/src/Monolog/Handler/SocketHandler.php b/src/Monolog/Handler/SocketHandler.php index c5f70888..63f437f3 100644 --- a/src/Monolog/Handler/SocketHandler.php +++ b/src/Monolog/Handler/SocketHandler.php @@ -110,6 +110,8 @@ class SocketHandler extends AbstractProcessingHandler /** * Set socket connection to be persistent. It only has effect before the connection is initiated. + * + * @return $this */ public function setPersistent(bool $persistent): self { @@ -122,6 +124,7 @@ class SocketHandler extends AbstractProcessingHandler * Set connection timeout. Only has effect before we connect. * * @see http://php.net/manual/en/function.fsockopen.php + * @return $this */ public function setConnectionTimeout(float $seconds): self { @@ -135,6 +138,7 @@ class SocketHandler extends AbstractProcessingHandler * Set write timeout. Only has effect before we connect. * * @see http://php.net/manual/en/function.stream-set-timeout.php + * @return $this */ public function setTimeout(float $seconds): self { @@ -148,6 +152,7 @@ class SocketHandler extends AbstractProcessingHandler * Set writing timeout. Only has effect during connection in the writing cycle. * * @param float $seconds 0 for no timeout + * @return $this */ public function setWritingTimeout(float $seconds): self { @@ -159,6 +164,8 @@ class SocketHandler extends AbstractProcessingHandler /** * Set chunk size. Only has effect during connection in the writing cycle. + * + * @return $this */ public function setChunkSize(int $bytes): self { diff --git a/src/Monolog/Handler/SyslogUdpHandler.php b/src/Monolog/Handler/SyslogUdpHandler.php index 16a7286a..60740935 100644 --- a/src/Monolog/Handler/SyslogUdpHandler.php +++ b/src/Monolog/Handler/SyslogUdpHandler.php @@ -142,6 +142,8 @@ class SyslogUdpHandler extends AbstractSyslogHandler /** * Inject your own socket, mainly used for testing + * + * @return $this */ public function setSocket(UdpSocket $socket): self { diff --git a/src/Monolog/Handler/TelegramBotHandler.php b/src/Monolog/Handler/TelegramBotHandler.php index 4302a03a..bbdb8a8e 100644 --- a/src/Monolog/Handler/TelegramBotHandler.php +++ b/src/Monolog/Handler/TelegramBotHandler.php @@ -130,6 +130,9 @@ class TelegramBotHandler extends AbstractProcessingHandler $this->setTopic($topic); } + /** + * @return $this + */ public function setParseMode(string $parseMode = null): self { if ($parseMode !== null && !in_array($parseMode, self::AVAILABLE_PARSE_MODES, true)) { @@ -141,6 +144,9 @@ class TelegramBotHandler extends AbstractProcessingHandler return $this; } + /** + * @return $this + */ public function disableWebPagePreview(bool $disableWebPagePreview = null): self { $this->disableWebPagePreview = $disableWebPagePreview; @@ -148,6 +154,9 @@ class TelegramBotHandler extends AbstractProcessingHandler return $this; } + /** + * @return $this + */ public function disableNotification(bool $disableNotification = null): self { $this->disableNotification = $disableNotification; @@ -158,6 +167,7 @@ class TelegramBotHandler extends AbstractProcessingHandler /** * True - split a message longer than MAX_MESSAGE_LENGTH into parts and send in multiple messages. * False - truncates a message that is too long. + * * @return $this */ public function splitLongMessages(bool $splitLongMessages = false): self @@ -169,6 +179,7 @@ class TelegramBotHandler extends AbstractProcessingHandler /** * Adds 1-second delay between sending a split message (according to Telegram API to avoid 429 Too Many Requests). + * * @return $this */ public function delayBetweenMessages(bool $delayBetweenMessages = false): self @@ -178,6 +189,9 @@ class TelegramBotHandler extends AbstractProcessingHandler return $this; } + /** + * @return $this + */ public function setTopic(int $topic = null): self { $this->topic = $topic; diff --git a/src/Monolog/Logger.php b/src/Monolog/Logger.php index db8bc21b..d929b535 100644 --- a/src/Monolog/Logger.php +++ b/src/Monolog/Logger.php @@ -188,6 +188,8 @@ class Logger implements LoggerInterface, ResettableInterface /** * Return a new cloned instance with the name changed + * + * @return static */ public function withName(string $name): self { @@ -199,6 +201,8 @@ class Logger implements LoggerInterface, ResettableInterface /** * Pushes a handler on to the stack. + * + * @return $this */ public function pushHandler(HandlerInterface $handler): self { @@ -227,6 +231,7 @@ class Logger implements LoggerInterface, ResettableInterface * If a map is passed, keys will be ignored. * * @param list $handlers + * @return $this */ public function setHandlers(array $handlers): self { @@ -250,6 +255,7 @@ class Logger implements LoggerInterface, ResettableInterface * Adds a processor on to the stack. * * @phpstan-param ProcessorInterface|(callable(LogRecord): LogRecord) $callback + * @return $this */ public function pushProcessor(ProcessorInterface|callable $callback): self { @@ -292,6 +298,7 @@ class Logger implements LoggerInterface, ResettableInterface * to suppress microseconds from the output. * * @param bool $micro True to use microtime() to create timestamps + * @return $this */ public function useMicrosecondTimestamps(bool $micro): self { @@ -300,6 +307,9 @@ class Logger implements LoggerInterface, ResettableInterface return $this; } + /** + * @return $this + */ public function useLoggingLoopDetection(bool $detectCycles): self { $this->detectCycles = $detectCycles; @@ -526,6 +536,8 @@ class Logger implements LoggerInterface, ResettableInterface * Set a custom exception handler that will be called if adding a new record fails * * The Closure will receive an exception object and the record that failed to be logged + * + * @return $this */ public function setExceptionHandler(Closure|null $callback): self { @@ -673,6 +685,8 @@ class Logger implements LoggerInterface, ResettableInterface /** * Sets the timezone to be used for the timestamp of log records. + * + * @return $this */ public function setTimezone(DateTimeZone $tz): self { diff --git a/src/Monolog/Processor/TagProcessor.php b/src/Monolog/Processor/TagProcessor.php index 4543ccf6..10ed1cea 100644 --- a/src/Monolog/Processor/TagProcessor.php +++ b/src/Monolog/Processor/TagProcessor.php @@ -33,6 +33,7 @@ class TagProcessor implements ProcessorInterface /** * @param string[] $tags + * @return $this */ public function addTags(array $tags = []): self { @@ -43,6 +44,7 @@ class TagProcessor implements ProcessorInterface /** * @param string[] $tags + * @return $this */ public function setTags(array $tags = []): self { diff --git a/src/Monolog/Processor/WebProcessor.php b/src/Monolog/Processor/WebProcessor.php index 2088b180..1abb8400 100644 --- a/src/Monolog/Processor/WebProcessor.php +++ b/src/Monolog/Processor/WebProcessor.php @@ -90,6 +90,9 @@ class WebProcessor implements ProcessorInterface return $record; } + /** + * @return $this + */ public function addExtraField(string $extraName, string $serverName): self { $this->extraFields[$extraName] = $serverName;