diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 23adb9b8..5a760868 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -33,7 +33,7 @@ jobs: - php-version: "8.1" dependencies: lowest operating-system: ubuntu-latest - - php-version: "8.2" + - php-version: "8.4" dependencies: highest operating-system: ubuntu-latest composer-options: "--ignore-platform-req=php+" @@ -50,7 +50,7 @@ jobs: couchdb version: '2.3.1' - name: Run MongoDB - uses: supercharge/mongodb-github-action@1.7.0 + uses: supercharge/mongodb-github-action@1.10.0 with: mongodb-version: 5.0 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f5cbf9cc..0db61e04 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,6 +17,7 @@ jobs: matrix: php-version: - "8.1" + - "8.3" steps: - name: "Checkout" diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index a6a4e407..b3314065 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -37,7 +37,7 @@ jobs: run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" - name: Cache dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ steps.composercache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} diff --git a/src/Monolog/DateTimeImmutable.php b/src/Monolog/DateTimeImmutable.php index 274b73ea..3d9477f4 100644 --- a/src/Monolog/DateTimeImmutable.php +++ b/src/Monolog/DateTimeImmutable.php @@ -27,6 +27,8 @@ class DateTimeImmutable extends \DateTimeImmutable implements \JsonSerializable { $this->useMicroseconds = $useMicroseconds; + // if you like to use a custom time to pass to Logger::addRecord directly, + // call modify() or setTimestamp() on this instance to change the date after creating it parent::__construct('now', $timezone); } diff --git a/src/Monolog/Handler/FilterHandler.php b/src/Monolog/Handler/FilterHandler.php index 5fa558e1..66f65477 100644 --- a/src/Monolog/Handler/FilterHandler.php +++ b/src/Monolog/Handler/FilterHandler.php @@ -150,7 +150,7 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese * * If the handler was provided as a factory, this will trigger the handler's instantiation. */ - public function getHandler(LogRecord $record = null): HandlerInterface + public function getHandler(LogRecord|null $record = null): HandlerInterface { if (!$this->handler instanceof HandlerInterface) { $handler = ($this->handler)($record, $this); diff --git a/src/Monolog/Handler/FingersCrossedHandler.php b/src/Monolog/Handler/FingersCrossedHandler.php index 1c3df386..d4551fb9 100644 --- a/src/Monolog/Handler/FingersCrossedHandler.php +++ b/src/Monolog/Handler/FingersCrossedHandler.php @@ -199,7 +199,7 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa * * If the handler was provided as a factory, this will trigger the handler's instantiation. */ - public function getHandler(LogRecord $record = null): HandlerInterface + public function getHandler(LogRecord|null $record = null): HandlerInterface { if (!$this->handler instanceof HandlerInterface) { $handler = ($this->handler)($record, $this); diff --git a/src/Monolog/Handler/SamplingHandler.php b/src/Monolog/Handler/SamplingHandler.php index 511ec585..db43d5a8 100644 --- a/src/Monolog/Handler/SamplingHandler.php +++ b/src/Monolog/Handler/SamplingHandler.php @@ -78,7 +78,7 @@ class SamplingHandler extends AbstractHandler implements ProcessableHandlerInter * * If the handler was provided as a factory, this will trigger the handler's instantiation. */ - public function getHandler(LogRecord $record = null): HandlerInterface + public function getHandler(LogRecord|null $record = null): HandlerInterface { if (!$this->handler instanceof HandlerInterface) { $handler = ($this->handler)($record, $this); diff --git a/src/Monolog/Handler/Slack/SlackRecord.php b/src/Monolog/Handler/Slack/SlackRecord.php index 147d8f80..0cb8b9b4 100644 --- a/src/Monolog/Handler/Slack/SlackRecord.php +++ b/src/Monolog/Handler/Slack/SlackRecord.php @@ -86,7 +86,7 @@ class SlackRecord bool $useShortAttachment = false, bool $includeContextAndExtra = false, array $excludeFields = [], - FormatterInterface $formatter = null + FormatterInterface|null $formatter = null ) { $this ->setChannel($channel) diff --git a/src/Monolog/Handler/TelegramBotHandler.php b/src/Monolog/Handler/TelegramBotHandler.php index feaa002f..8fda7697 100644 --- a/src/Monolog/Handler/TelegramBotHandler.php +++ b/src/Monolog/Handler/TelegramBotHandler.php @@ -111,9 +111,9 @@ class TelegramBotHandler extends AbstractProcessingHandler string $channel, $level = Level::Debug, bool $bubble = true, - string $parseMode = null, - bool $disableWebPagePreview = null, - bool $disableNotification = null, + ?string $parseMode = null, + ?bool $disableWebPagePreview = null, + ?bool $disableNotification = null, bool $splitLongMessages = false, bool $delayBetweenMessages = false, int $topic = null @@ -137,7 +137,7 @@ class TelegramBotHandler extends AbstractProcessingHandler /** * @return $this */ - public function setParseMode(string $parseMode = null): self + public function setParseMode(string|null $parseMode = null): self { if ($parseMode !== null && !in_array($parseMode, self::AVAILABLE_PARSE_MODES, true)) { throw new \InvalidArgumentException('Unknown parseMode, use one of these: ' . implode(', ', self::AVAILABLE_PARSE_MODES) . '.'); @@ -151,7 +151,7 @@ class TelegramBotHandler extends AbstractProcessingHandler /** * @return $this */ - public function disableWebPagePreview(bool $disableWebPagePreview = null): self + public function disableWebPagePreview(bool|null $disableWebPagePreview = null): self { $this->disableWebPagePreview = $disableWebPagePreview; @@ -161,7 +161,7 @@ class TelegramBotHandler extends AbstractProcessingHandler /** * @return $this */ - public function disableNotification(bool $disableNotification = null): self + public function disableNotification(bool|null $disableNotification = null): self { $this->disableNotification = $disableNotification; diff --git a/src/Monolog/Logger.php b/src/Monolog/Logger.php index b04194bf..f33c08f8 100644 --- a/src/Monolog/Logger.php +++ b/src/Monolog/Logger.php @@ -320,15 +320,15 @@ class Logger implements LoggerInterface, ResettableInterface /** * Adds a log record. * - * @param int $level The logging level (a Monolog or RFC 5424 level) - * @param string $message The log message - * @param mixed[] $context The log context - * @param DateTimeImmutable $datetime Optional log date to log into the past or future - * @return bool Whether the record has been processed + * @param int $level The logging level (a Monolog or RFC 5424 level) + * @param string $message The log message + * @param mixed[] $context The log context + * @param DateTimeImmutable|null $datetime Optional log date to log into the past or future + * @return bool Whether the record has been processed * * @phpstan-param value-of|Level $level */ - public function addRecord(int|Level $level, string $message, array $context = [], DateTimeImmutable $datetime = null): bool + public function addRecord(int|Level $level, string $message, array $context = [], DateTimeImmutable|null $datetime = null): bool { if (is_int($level) && isset(self::RFC_5424_LEVELS[$level])) { $level = self::RFC_5424_LEVELS[$level]; diff --git a/tests/Monolog/SignalHandlerTest.php b/tests/Monolog/SignalHandlerTest.php index addcb8c1..e4e9cffd 100644 --- a/tests/Monolog/SignalHandlerTest.php +++ b/tests/Monolog/SignalHandlerTest.php @@ -34,7 +34,7 @@ class SignalHandlerTest extends TestCase $this->asyncSignalHandling = pcntl_async_signals(); } if (function_exists('pcntl_sigprocmask')) { - pcntl_sigprocmask(SIG_BLOCK, [], $this->blockedSignals); + pcntl_sigprocmask(SIG_SETMASK, [], $this->blockedSignals); } } } @@ -146,7 +146,7 @@ class SignalHandlerTest extends TestCase posix_kill(posix_getpid(), $signo); pcntl_signal_dispatch(); // If $callPrevious is true, SIGINT should terminate by this line. - pcntl_sigprocmask(SIG_BLOCK, [], $oldset); + pcntl_sigprocmask(SIG_SETMASK, [], $oldset); file_put_contents($path, implode(' ', $oldset), FILE_APPEND); posix_kill(posix_getpid(), $signo); pcntl_signal_dispatch();