diff --git a/src/Monolog/Handler/AmqpHandler.php b/src/Monolog/Handler/AmqpHandler.php index 119f33947..e03d1c2a2 100644 --- a/src/Monolog/Handler/AmqpHandler.php +++ b/src/Monolog/Handler/AmqpHandler.php @@ -25,7 +25,7 @@ class AmqpHandler extends AbstractProcessingHandler protected AMQPExchange|AMQPChannel $exchange; /** @var array */ - private array $extraAttributes = []; + protected array $extraAttributes = []; protected string $exchangeName; @@ -147,7 +147,7 @@ protected function getRoutingKey(LogRecord $record): string return strtolower($routingKey); } - private function createAmqpMessage(string $data): AMQPMessage + protected function createAmqpMessage(string $data): AMQPMessage { $attributes = [ 'delivery_mode' => 2, diff --git a/src/Monolog/Handler/BrowserConsoleHandler.php b/src/Monolog/Handler/BrowserConsoleHandler.php index 788d7d068..2a136dc5c 100644 --- a/src/Monolog/Handler/BrowserConsoleHandler.php +++ b/src/Monolog/Handler/BrowserConsoleHandler.php @@ -165,7 +165,7 @@ protected static function getResponseFormatFromContentType(string $contentType): return self::FORMAT_UNKNOWN; } - private static function generateScript(): string + protected static function generateScript(): string { $script = []; foreach (static::$records as $record) { @@ -188,7 +188,7 @@ private static function generateScript(): string return "(function (c) {if (c && c.groupCollapsed) {\n" . implode("\n", $script) . "\n}})(console);"; } - private static function getConsoleMethodForLevel(Level $level): string + protected static function getConsoleMethodForLevel(Level $level): string { return match ($level) { Level::Debug => 'debug', @@ -201,7 +201,7 @@ private static function getConsoleMethodForLevel(Level $level): string /** * @return string[] */ - private static function handleStyles(string $formatted): array + protected static function handleStyles(string $formatted): array { $args = []; $format = '%c' . $formatted; @@ -221,7 +221,7 @@ private static function handleStyles(string $formatted): array return array_reverse($args); } - private static function handleCustomStyles(string $style, string $string): string + protected static function handleCustomStyles(string $style, string $string): string { static $colors = ['blue', 'green', 'red', 'magenta', 'orange', 'black', 'grey']; static $labels = []; @@ -253,7 +253,7 @@ private static function handleCustomStyles(string $style, string $string): strin * @param mixed[] $dict * @return mixed[] */ - private static function dump(string $title, array $dict): array + protected static function dump(string $title, array $dict): array { $script = []; $dict = array_filter($dict, fn ($value) => $value !== null); @@ -272,7 +272,7 @@ private static function dump(string $title, array $dict): array return $script; } - private static function quote(string $arg): string + protected static function quote(string $arg): string { return '"' . addcslashes($arg, "\"\n\\") . '"'; } @@ -280,7 +280,7 @@ private static function quote(string $arg): string /** * @param mixed $args */ - private static function call(...$args): string + protected static function call(...$args): string { $method = array_shift($args); if (!\is_string($method)) { @@ -293,7 +293,7 @@ private static function call(...$args): string /** * @param mixed[] $args */ - private static function call_array(string $method, array $args): string + protected static function call_array(string $method, array $args): string { return 'c.' . $method . '(' . implode(', ', $args) . ');'; } diff --git a/src/Monolog/Handler/CouchDBHandler.php b/src/Monolog/Handler/CouchDBHandler.php index 8d9c10e76..0c91a629f 100644 --- a/src/Monolog/Handler/CouchDBHandler.php +++ b/src/Monolog/Handler/CouchDBHandler.php @@ -41,7 +41,7 @@ class CouchDBHandler extends AbstractProcessingHandler * @var mixed[] * @phpstan-var Options */ - private array $options; + protected array $options; /** * @param mixed[] $options diff --git a/src/Monolog/Handler/CubeHandler.php b/src/Monolog/Handler/CubeHandler.php index a76bf4089..787d9f6aa 100644 --- a/src/Monolog/Handler/CubeHandler.php +++ b/src/Monolog/Handler/CubeHandler.php @@ -24,13 +24,13 @@ */ class CubeHandler extends AbstractProcessingHandler { - private ?\Socket $udpConnection = null; - private ?\CurlHandle $httpConnection = null; - private string $scheme; - private string $host; - private int $port; + protected ?\Socket $udpConnection = null; + protected ?\CurlHandle $httpConnection = null; + protected string $scheme; + protected string $host; + protected int $port; /** @var string[] */ - private array $acceptedSchemes = ['http', 'udp']; + protected array $acceptedSchemes = ['http', 'udp']; /** * Create a Cube handler @@ -133,7 +133,7 @@ protected function write(LogRecord $record): void } } - private function writeUdp(string $data): void + protected function writeUdp(string $data): void { if (null === $this->udpConnection) { $this->connectUdp(); @@ -146,7 +146,7 @@ private function writeUdp(string $data): void socket_send($this->udpConnection, $data, \strlen($data), 0); } - private function writeHttp(string $data): void + protected function writeHttp(string $data): void { if (null === $this->httpConnection) { $this->connectHttp(); diff --git a/src/Monolog/Handler/Curl/Util.php b/src/Monolog/Handler/Curl/Util.php index f10281144..80fb15d08 100644 --- a/src/Monolog/Handler/Curl/Util.php +++ b/src/Monolog/Handler/Curl/Util.php @@ -21,7 +21,7 @@ final class Util { /** @var array */ - private static array $retriableErrorCodes = [ + protected static array $retriableErrorCodes = [ CURLE_COULDNT_RESOLVE_HOST, CURLE_COULDNT_CONNECT, CURLE_HTTP_NOT_FOUND, diff --git a/src/Monolog/Handler/DeduplicationHandler.php b/src/Monolog/Handler/DeduplicationHandler.php index 873a4b860..513a9c878 100644 --- a/src/Monolog/Handler/DeduplicationHandler.php +++ b/src/Monolog/Handler/DeduplicationHandler.php @@ -136,7 +136,7 @@ protected function buildDeduplicationStoreEntry(LogRecord $record): string return $record->datetime->getTimestamp() . ':' . $record->level->getName() . ':' . preg_replace('{[\r\n].*}', '', $record->message); } - private function collectLogs(): void + protected function collectLogs(): void { if (!file_exists($this->deduplicationStore)) { return; diff --git a/src/Monolog/Handler/DoctrineCouchDBHandler.php b/src/Monolog/Handler/DoctrineCouchDBHandler.php index eab9f1089..8f1de6028 100644 --- a/src/Monolog/Handler/DoctrineCouchDBHandler.php +++ b/src/Monolog/Handler/DoctrineCouchDBHandler.php @@ -24,7 +24,7 @@ */ class DoctrineCouchDBHandler extends AbstractProcessingHandler { - private CouchDBClient $client; + protected CouchDBClient $client; public function __construct(CouchDBClient $client, int|string|Level $level = Level::Debug, bool $bubble = true) { diff --git a/src/Monolog/Handler/ElasticsearchHandler.php b/src/Monolog/Handler/ElasticsearchHandler.php index 6fd705de4..ddb8e7042 100644 --- a/src/Monolog/Handler/ElasticsearchHandler.php +++ b/src/Monolog/Handler/ElasticsearchHandler.php @@ -70,7 +70,7 @@ class ElasticsearchHandler extends AbstractProcessingHandler /** * @var bool */ - private $needsType; + protected $needsType; /** * @param Client|Client8 $client Elasticsearch Client object diff --git a/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php b/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php index 383e19af9..d9af23379 100644 --- a/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php +++ b/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php @@ -38,12 +38,12 @@ */ class ChannelLevelActivationStrategy implements ActivationStrategyInterface { - private Level $defaultActionLevel; + protected Level $defaultActionLevel; /** * @var array */ - private array $channelToActionLevel; + protected array $channelToActionLevel; /** * @param int|string|Level|LogLevel::* $defaultActionLevel The default action level to be used if the record's category doesn't match any diff --git a/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php b/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php index c3ca2967a..345dfc63c 100644 --- a/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php +++ b/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php @@ -23,7 +23,7 @@ */ class ErrorLevelActivationStrategy implements ActivationStrategyInterface { - private Level $actionLevel; + protected Level $actionLevel; /** * @param int|string|Level $actionLevel Level or name or value diff --git a/src/Monolog/Handler/FingersCrossedHandler.php b/src/Monolog/Handler/FingersCrossedHandler.php index 1ce64e845..08ccf37a1 100644 --- a/src/Monolog/Handler/FingersCrossedHandler.php +++ b/src/Monolog/Handler/FingersCrossedHandler.php @@ -178,7 +178,7 @@ public function clear(): void /** * Resets the state of the handler. Stops forwarding records to the wrapped handler. */ - private function flushBuffer(): void + protected function flushBuffer(): void { if (null !== $this->passthruLevel) { $passthruLevel = $this->passthruLevel; diff --git a/src/Monolog/Handler/FleepHookHandler.php b/src/Monolog/Handler/FleepHookHandler.php index 46ebfc0b7..5be237238 100644 --- a/src/Monolog/Handler/FleepHookHandler.php +++ b/src/Monolog/Handler/FleepHookHandler.php @@ -107,7 +107,7 @@ protected function generateDataStream(LogRecord $record): string /** * Builds the header of the API Call */ - private function buildHeader(string $content): string + protected function buildHeader(string $content): string { $header = "POST " . static::FLEEP_HOOK_URI . $this->token . " HTTP/1.1\r\n"; $header .= "Host: " . static::FLEEP_HOST . "\r\n"; @@ -121,7 +121,7 @@ private function buildHeader(string $content): string /** * Builds the body of API call */ - private function buildContent(LogRecord $record): string + protected function buildContent(LogRecord $record): string { $dataArray = [ 'message' => $record->formatted, diff --git a/src/Monolog/Handler/FlowdockHandler.php b/src/Monolog/Handler/FlowdockHandler.php index 27c6c1533..77b822de9 100644 --- a/src/Monolog/Handler/FlowdockHandler.php +++ b/src/Monolog/Handler/FlowdockHandler.php @@ -106,7 +106,7 @@ protected function generateDataStream(LogRecord $record): string /** * Builds the body of API call */ - private function buildContent(LogRecord $record): string + protected function buildContent(LogRecord $record): string { return Utils::jsonEncode($record->formatted); } @@ -114,7 +114,7 @@ private function buildContent(LogRecord $record): string /** * Builds the header of the API Call */ - private function buildHeader(string $content): string + protected function buildHeader(string $content): string { $header = "POST /v1/messages/team_inbox/" . $this->apiToken . " HTTP/1.1\r\n"; $header .= "Host: api.flowdock.com\r\n"; diff --git a/src/Monolog/Handler/IFTTTHandler.php b/src/Monolog/Handler/IFTTTHandler.php index b9c7ba84b..63fd8db25 100644 --- a/src/Monolog/Handler/IFTTTHandler.php +++ b/src/Monolog/Handler/IFTTTHandler.php @@ -28,8 +28,8 @@ */ class IFTTTHandler extends AbstractProcessingHandler { - private string $eventName; - private string $secretKey; + protected string $eventName; + protected string $secretKey; /** * @param string $eventName The name of the IFTTT Maker event that should be triggered diff --git a/src/Monolog/Handler/LogglyHandler.php b/src/Monolog/Handler/LogglyHandler.php index ff298c661..2b19a7b9b 100644 --- a/src/Monolog/Handler/LogglyHandler.php +++ b/src/Monolog/Handler/LogglyHandler.php @@ -73,7 +73,7 @@ protected function getCurlHandler(string $endpoint): CurlHandle /** * Starts a fresh curl session for the given endpoint and returns its handler. */ - private function loadCurlHandle(string $endpoint): CurlHandle + protected function loadCurlHandle(string $endpoint): CurlHandle { $url = sprintf("https://%s/%s/%s/", static::HOST, $endpoint, $this->token); diff --git a/src/Monolog/Handler/LogmaticHandler.php b/src/Monolog/Handler/LogmaticHandler.php index 6aa1b31bf..625f56be6 100644 --- a/src/Monolog/Handler/LogmaticHandler.php +++ b/src/Monolog/Handler/LogmaticHandler.php @@ -21,11 +21,11 @@ */ class LogmaticHandler extends SocketHandler { - private string $logToken; + protected string $logToken; - private string $hostname; + protected string $hostname; - private string $appName; + protected string $appName; /** * @param string $token Log token supplied by Logmatic. diff --git a/src/Monolog/Handler/MongoDBHandler.php b/src/Monolog/Handler/MongoDBHandler.php index 33ab68c6d..72bb82b58 100644 --- a/src/Monolog/Handler/MongoDBHandler.php +++ b/src/Monolog/Handler/MongoDBHandler.php @@ -34,11 +34,11 @@ */ class MongoDBHandler extends AbstractProcessingHandler { - private \MongoDB\Collection $collection; + protected \MongoDB\Collection $collection; - private Client|Manager $manager; + protected Client|Manager $manager; - private string|null $namespace = null; + protected string|null $namespace = null; /** * Constructor. diff --git a/src/Monolog/Handler/NullHandler.php b/src/Monolog/Handler/NullHandler.php index 1aa84e4f8..ad53fb8eb 100644 --- a/src/Monolog/Handler/NullHandler.php +++ b/src/Monolog/Handler/NullHandler.php @@ -26,7 +26,7 @@ */ class NullHandler extends Handler { - private Level $level; + protected Level $level; /** * @param string|int|Level $level The minimum logging level at which this handler will be triggered diff --git a/src/Monolog/Handler/OverflowHandler.php b/src/Monolog/Handler/OverflowHandler.php index adc0eb1f0..8be907b50 100644 --- a/src/Monolog/Handler/OverflowHandler.php +++ b/src/Monolog/Handler/OverflowHandler.php @@ -37,17 +37,17 @@ */ class OverflowHandler extends AbstractHandler implements FormattableHandlerInterface { - private HandlerInterface $handler; + protected HandlerInterface $handler; /** @var array */ - private array $thresholdMap = []; + protected array $thresholdMap = []; /** * Buffer of all messages passed to the handler before the threshold was reached * * @var mixed[][] */ - private array $buffer = []; + protected array $buffer = []; /** * @param array $thresholdMap Dictionary of log level value => threshold diff --git a/src/Monolog/Handler/PHPConsoleHandler.php b/src/Monolog/Handler/PHPConsoleHandler.php index b37266d59..9a79c0b0a 100644 --- a/src/Monolog/Handler/PHPConsoleHandler.php +++ b/src/Monolog/Handler/PHPConsoleHandler.php @@ -91,7 +91,7 @@ class PHPConsoleHandler extends AbstractProcessingHandler /** * @phpstan-var Options */ - private array $options = [ + protected array $options = [ 'enabled' => true, // bool Is PHP Console server enabled 'classesPartialsTraceIgnore' => ['Monolog\\'], // array Hide calls of classes started with... 'debugTagsKeysInContext' => [0, 'tag'], // bool Is PHP Console server enabled @@ -114,7 +114,7 @@ class PHPConsoleHandler extends AbstractProcessingHandler 'dataStorage' => null, // \PhpConsole\Storage|null Fixes problem with custom $_SESSION handler (see https://github.com/barbushin/php-console#troubleshooting-with-_session-handler-overridden-in-some-frameworks) ]; - private Connector $connector; + protected Connector $connector; /** * @param array $options See \Monolog\Handler\PHPConsoleHandler::$options for more details @@ -139,7 +139,7 @@ public function __construct(array $options = [], ?Connector $connector = null, i * @phpstan-param InputOptions $options * @phpstan-return Options */ - private function initOptions(array $options): array + protected function initOptions(array $options): array { $wrongOptions = array_diff(array_keys($options), array_keys($this->options)); if (\count($wrongOptions) > 0) { @@ -149,7 +149,7 @@ private function initOptions(array $options): array return array_replace($this->options, $options); } - private function initConnector(?Connector $connector = null): Connector + protected function initConnector(?Connector $connector = null): Connector { if (null === $connector) { if ($this->options['dataStorage'] instanceof Storage) { @@ -240,7 +240,7 @@ protected function write(LogRecord $record): void } } - private function handleDebugRecord(LogRecord $record): void + protected function handleDebugRecord(LogRecord $record): void { [$tags, $filteredContext] = $this->getRecordTags($record); $message = $record->message; @@ -250,12 +250,12 @@ private function handleDebugRecord(LogRecord $record): void $this->connector->getDebugDispatcher()->dispatchDebug($message, $tags, $this->options['classesPartialsTraceIgnore']); } - private function handleExceptionRecord(LogRecord $record): void + protected function handleExceptionRecord(LogRecord $record): void { $this->connector->getErrorsDispatcher()->dispatchException($record->context['exception']); } - private function handleErrorRecord(LogRecord $record): void + protected function handleErrorRecord(LogRecord $record): void { $context = $record->context; @@ -271,7 +271,7 @@ private function handleErrorRecord(LogRecord $record): void /** * @return array{string, mixed[]} */ - private function getRecordTags(LogRecord $record): array + protected function getRecordTags(LogRecord $record): array { $tags = null; $filteredContext = []; diff --git a/src/Monolog/Handler/ProcessHandler.php b/src/Monolog/Handler/ProcessHandler.php index 96649aadc..9f721caf9 100644 --- a/src/Monolog/Handler/ProcessHandler.php +++ b/src/Monolog/Handler/ProcessHandler.php @@ -32,18 +32,18 @@ class ProcessHandler extends AbstractProcessingHandler * * @var resource|bool|null */ - private $process; + protected $process; - private string $command; + protected string $command; - private ?string $cwd; + protected ?string $cwd; /** * @var resource[] */ - private array $pipes = []; + protected array $pipes = []; - private float $timeout; + protected float $timeout; /** * @var array @@ -98,7 +98,7 @@ protected function write(LogRecord $record): void * Makes sure that the process is actually started, and if not, starts it, * assigns the stream pipes, and handles startup errors, if any. */ - private function ensureProcessIsStarted(): void + protected function ensureProcessIsStarted(): void { if (\is_resource($this->process) === false) { $this->startProcess(); @@ -110,7 +110,7 @@ private function ensureProcessIsStarted(): void /** * Starts the actual process and sets all streams to non-blocking. */ - private function startProcess(): void + protected function startProcess(): void { $this->process = proc_open($this->command, static::DESCRIPTOR_SPEC, $this->pipes, $this->cwd); @@ -124,7 +124,7 @@ private function startProcess(): void * * @throws \UnexpectedValueException */ - private function handleStartupErrors(): void + protected function handleStartupErrors(): void { $selected = $this->selectErrorStream(); if (false === $selected) { diff --git a/src/Monolog/Handler/PsrHandler.php b/src/Monolog/Handler/PsrHandler.php index 100e8e4a6..ac6bdca6c 100644 --- a/src/Monolog/Handler/PsrHandler.php +++ b/src/Monolog/Handler/PsrHandler.php @@ -33,7 +33,7 @@ class PsrHandler extends AbstractHandler implements FormattableHandlerInterface protected LoggerInterface $logger; protected FormatterInterface|null $formatter = null; - private bool $includeExtra; + protected bool $includeExtra; /** * @param LoggerInterface $logger The underlying PSR-3 compliant logger to which messages will be proxied diff --git a/src/Monolog/Handler/PushoverHandler.php b/src/Monolog/Handler/PushoverHandler.php index b2a78955a..c917461fb 100644 --- a/src/Monolog/Handler/PushoverHandler.php +++ b/src/Monolog/Handler/PushoverHandler.php @@ -25,31 +25,31 @@ */ class PushoverHandler extends SocketHandler { - private string $token; + protected string $token; /** @var array */ - private array $users; + protected array $users; - private string $title; + protected string $title; - private string|int|null $user = null; + protected string|int|null $user = null; - private int $retry; + protected int $retry; - private int $expire; + protected int $expire; - private Level $highPriorityLevel; + protected Level $highPriorityLevel; - private Level $emergencyLevel; + protected Level $emergencyLevel; - private bool $useFormattedMessage = false; + protected bool $useFormattedMessage = false; /** * All parameters that can be sent to Pushover * @see https://pushover.net/api * @var array */ - private array $parameterNames = [ + protected array $parameterNames = [ 'token' => true, 'user' => true, 'message' => true, @@ -70,7 +70,7 @@ class PushoverHandler extends SocketHandler * @see https://pushover.net/api#sounds * @var string[] */ - private array $sounds = [ + protected array $sounds = [ 'pushover', 'bike', 'bugle', 'cashregister', 'classical', 'cosmic', 'falling', 'gamelan', 'incoming', 'intermission', 'magic', 'mechanical', 'pianobar', 'siren', 'spacealarm', 'tugboat', 'alien', 'climb', 'persistent', 'echo', 'updown', 'none', @@ -142,7 +142,7 @@ protected function generateDataStream(LogRecord $record): string return $this->buildHeader($content) . $content; } - private function buildContent(LogRecord $record): string + protected function buildContent(LogRecord $record): string { // Pushover has a limit of 512 characters on title and message combined. $maxMessageLength = 512 - \strlen($this->title); @@ -183,7 +183,7 @@ private function buildContent(LogRecord $record): string return http_build_query($dataArray); } - private function buildHeader(string $content): string + protected function buildHeader(string $content): string { $header = "POST /1/messages.json HTTP/1.1\r\n"; $header .= "Host: api.pushover.net\r\n"; diff --git a/src/Monolog/Handler/RedisHandler.php b/src/Monolog/Handler/RedisHandler.php index c40d97c61..79e26672b 100644 --- a/src/Monolog/Handler/RedisHandler.php +++ b/src/Monolog/Handler/RedisHandler.php @@ -32,8 +32,8 @@ class RedisHandler extends AbstractProcessingHandler { /** @var Predis|Redis */ - private Predis|Redis $redisClient; - private string $redisKey; + protected Predis|Redis $redisClient; + protected string $redisKey; protected int $capSize; /** diff --git a/src/Monolog/Handler/RedisPubSubHandler.php b/src/Monolog/Handler/RedisPubSubHandler.php index fa8e9e9ff..e9482f5d7 100644 --- a/src/Monolog/Handler/RedisPubSubHandler.php +++ b/src/Monolog/Handler/RedisPubSubHandler.php @@ -32,8 +32,8 @@ class RedisPubSubHandler extends AbstractProcessingHandler { /** @var Predis|Redis */ - private Predis|Redis $redisClient; - private string $channelKey; + protected Predis|Redis $redisClient; + protected string $channelKey; /** * @param Predis|Redis $redis The redis instance diff --git a/src/Monolog/Handler/RollbarHandler.php b/src/Monolog/Handler/RollbarHandler.php index 6b9943265..b26c55871 100644 --- a/src/Monolog/Handler/RollbarHandler.php +++ b/src/Monolog/Handler/RollbarHandler.php @@ -39,7 +39,7 @@ class RollbarHandler extends AbstractProcessingHandler /** * Records whether any log records have been added since the last flush of the rollbar notifier */ - private bool $hasRecords = false; + protected bool $hasRecords = false; protected bool $initialized = false; diff --git a/src/Monolog/Handler/Slack/SlackRecord.php b/src/Monolog/Handler/Slack/SlackRecord.php index 0e46c2d2f..90eb444cf 100644 --- a/src/Monolog/Handler/Slack/SlackRecord.php +++ b/src/Monolog/Handler/Slack/SlackRecord.php @@ -38,42 +38,42 @@ class SlackRecord /** * Slack channel (encoded ID or name) */ - private string|null $channel; + protected string|null $channel; /** * Name of a bot */ - private string|null $username; + protected string|null $username; /** * User icon e.g. 'ghost', 'http://example.com/user.png' */ - private string|null $userIcon; + protected string|null $userIcon; /** * Whether the message should be added to Slack as attachment (plain text otherwise) */ - private bool $useAttachment; + protected bool $useAttachment; /** * Whether the the context/extra messages added to Slack as attachments are in a short style */ - private bool $useShortAttachment; + protected bool $useShortAttachment; /** * Whether the attachment should include context and extra data */ - private bool $includeContextAndExtra; + protected bool $includeContextAndExtra; /** * Dot separated list of fields to exclude from slack message. E.g. ['context.field1', 'extra.field2'] * @var string[] */ - private array $excludeFields; + protected array $excludeFields; - private FormatterInterface|null $formatter; + protected FormatterInterface|null $formatter; - private NormalizerFormatter $normalizerFormatter; + protected NormalizerFormatter $normalizerFormatter; /** * @param string[] $excludeFields @@ -319,7 +319,7 @@ public function setFormatter(?FormatterInterface $formatter = null): self * * @return array{title: string, value: string, short: false} */ - private function generateAttachmentField(string $title, $value): array + protected function generateAttachmentField(string $title, $value): array { $value = \is_array($value) ? sprintf('```%s```', substr($this->stringify($value), 0, 1990)) @@ -339,7 +339,7 @@ private function generateAttachmentField(string $title, $value): array * * @return array */ - private function generateAttachmentFields(array $data): array + protected function generateAttachmentFields(array $data): array { /** @var array|string> $normalized */ $normalized = $this->normalizerFormatter->normalizeValue($data); @@ -357,7 +357,7 @@ private function generateAttachmentFields(array $data): array * * @return mixed[] */ - private function removeExcludedFields(LogRecord $record): array + protected function removeExcludedFields(LogRecord $record): array { $recordData = $record->toArray(); foreach ($this->excludeFields as $field) { diff --git a/src/Monolog/Handler/SlackHandler.php b/src/Monolog/Handler/SlackHandler.php index 2a34dda2d..4847faf31 100644 --- a/src/Monolog/Handler/SlackHandler.php +++ b/src/Monolog/Handler/SlackHandler.php @@ -28,12 +28,12 @@ class SlackHandler extends SocketHandler /** * Slack API token */ - private string $token; + protected string $token; /** * Instance of the SlackRecord util class preparing data for Slack API. */ - private SlackRecord $slackRecord; + protected SlackRecord $slackRecord; /** * @param string $token Slack API token @@ -114,7 +114,7 @@ protected function generateDataStream(LogRecord $record): string /** * Builds the body of API call */ - private function buildContent(LogRecord $record): string + protected function buildContent(LogRecord $record): string { $dataArray = $this->prepareContentData($record); @@ -139,7 +139,7 @@ protected function prepareContentData(LogRecord $record): array /** * Builds the header of the API Call */ - private function buildHeader(string $content): string + protected function buildHeader(string $content): string { $header = "POST /api/chat.postMessage HTTP/1.1\r\n"; $header .= "Host: slack.com\r\n"; diff --git a/src/Monolog/Handler/SlackWebhookHandler.php b/src/Monolog/Handler/SlackWebhookHandler.php index eac51ccbe..adced7c51 100644 --- a/src/Monolog/Handler/SlackWebhookHandler.php +++ b/src/Monolog/Handler/SlackWebhookHandler.php @@ -28,12 +28,12 @@ class SlackWebhookHandler extends AbstractProcessingHandler /** * Slack Webhook token */ - private string $webhookUrl; + protected string $webhookUrl; /** * Instance of the SlackRecord util class preparing data for Slack API. */ - private SlackRecord $slackRecord; + protected SlackRecord $slackRecord; /** * @param string $webhookUrl Slack Webhook URL diff --git a/src/Monolog/Handler/SocketHandler.php b/src/Monolog/Handler/SocketHandler.php index 36d46bf9d..1920df788 100644 --- a/src/Monolog/Handler/SocketHandler.php +++ b/src/Monolog/Handler/SocketHandler.php @@ -22,18 +22,18 @@ */ class SocketHandler extends AbstractProcessingHandler { - private string $connectionString; - private float $connectionTimeout; + protected string $connectionString; + protected float $connectionTimeout; /** @var resource|null */ - private $resource; - private float $timeout; - private float $writingTimeout; - private int|null $lastSentBytes = null; - private int|null $chunkSize; - private bool $persistent; - private int|null $errno = null; - private string|null $errstr = null; - private float|null $lastWritingAt = null; + protected $resource; + protected float $timeout; + protected float $writingTimeout; + protected int|null $lastSentBytes = null; + protected int|null $chunkSize; + protected bool $persistent; + protected int|null $errno = null; + protected string|null $errstr = null; + protected float|null $lastWritingAt = null; /** * @param string $connectionString Socket connection string @@ -318,14 +318,14 @@ protected function streamGetMetadata(): array|bool return stream_get_meta_data($this->resource); } - private function validateTimeout(float $value): void + protected function validateTimeout(float $value): void { if ($value < 0) { throw new \InvalidArgumentException("Timeout must be 0 or a positive float (got $value)"); } } - private function connectIfNotConnected(): void + protected function connectIfNotConnected(): void { if ($this->isConnected()) { return; @@ -346,14 +346,14 @@ protected function getResource() return $this->resource; } - private function connect(): void + protected function connect(): void { $this->createSocketResource(); $this->setSocketTimeout(); $this->setStreamChunkSize(); } - private function createSocketResource(): void + protected function createSocketResource(): void { if ($this->isPersistent()) { $resource = $this->pfsockopen(); @@ -366,21 +366,21 @@ private function createSocketResource(): void $this->resource = $resource; } - private function setSocketTimeout(): void + protected function setSocketTimeout(): void { if (!$this->streamSetTimeout()) { throw new \UnexpectedValueException("Failed setting timeout with stream_set_timeout()"); } } - private function setStreamChunkSize(): void + protected function setStreamChunkSize(): void { if (null !== $this->chunkSize && false === $this->streamSetChunkSize()) { throw new \UnexpectedValueException("Failed setting chunk size with stream_set_chunk_size()"); } } - private function writeToSocket(string $data): void + protected function writeToSocket(string $data): void { $length = \strlen($data); $sent = 0; @@ -409,7 +409,7 @@ private function writeToSocket(string $data): void } } - private function writingIsTimedOut(int $sent): bool + protected function writingIsTimedOut(int $sent): bool { // convert to ms if (0.0 === $this->writingTimeout) { diff --git a/src/Monolog/Handler/SqsHandler.php b/src/Monolog/Handler/SqsHandler.php index 1d28b65d4..4a148d037 100644 --- a/src/Monolog/Handler/SqsHandler.php +++ b/src/Monolog/Handler/SqsHandler.php @@ -28,8 +28,8 @@ class SqsHandler extends AbstractProcessingHandler /** 100 KB in bytes - head message size for new error log */ protected const HEAD_MESSAGE_SIZE = 102400; - private SqsClient $client; - private string $queueUrl; + protected SqsClient $client; + protected string $queueUrl; public function __construct(SqsClient $sqsClient, string $queueUrl, int|string|Level $level = Level::Debug, bool $bubble = true) { diff --git a/src/Monolog/Handler/StreamHandler.php b/src/Monolog/Handler/StreamHandler.php index 6153cc285..216c24243 100644 --- a/src/Monolog/Handler/StreamHandler.php +++ b/src/Monolog/Handler/StreamHandler.php @@ -31,13 +31,13 @@ class StreamHandler extends AbstractProcessingHandler /** @var resource|null */ protected $stream; protected string|null $url = null; - private string|null $errorMessage = null; + protected string|null $errorMessage = null; protected int|null $filePermission; protected bool $useLocking; protected string $fileOpenMode; /** @var true|null */ - private bool|null $dirCreated = null; - private bool $retrying = false; + protected bool|null $dirCreated = null; + protected bool $retrying = false; /** * @param resource|string $stream If a missing path can't be created, an UnexpectedValueException will be thrown on first write @@ -201,14 +201,14 @@ protected function streamWrite($stream, LogRecord $record): void fwrite($stream, (string) $record->formatted); } - private function customErrorHandler(int $code, string $msg): bool + protected function customErrorHandler(int $code, string $msg): bool { $this->errorMessage = preg_replace('{^(fopen|mkdir|fwrite)\(.*?\): }', '', $msg); return true; } - private function getDirFromStream(string $stream): ?string + protected function getDirFromStream(string $stream): ?string { $pos = strpos($stream, '://'); if ($pos === false) { @@ -222,7 +222,7 @@ private function getDirFromStream(string $stream): ?string return null; } - private function createDir(string $url): void + protected function createDir(string $url): void { // Do not try to create dir if it has already been tried. if (true === $this->dirCreated) { diff --git a/src/Monolog/Handler/SymfonyMailerHandler.php b/src/Monolog/Handler/SymfonyMailerHandler.php index 33aa4fd7b..991174de3 100644 --- a/src/Monolog/Handler/SymfonyMailerHandler.php +++ b/src/Monolog/Handler/SymfonyMailerHandler.php @@ -30,7 +30,7 @@ class SymfonyMailerHandler extends MailHandler { protected MailerInterface|TransportInterface $mailer; /** @var Email|Closure(string, LogRecord[]): Email */ - private Email|Closure $emailTemplate; + protected Email|Closure $emailTemplate; /** * @phpstan-param Email|Closure(string, LogRecord[]): Email $email diff --git a/src/Monolog/Handler/SyslogUdpHandler.php b/src/Monolog/Handler/SyslogUdpHandler.php index b5e467417..6cbcace31 100644 --- a/src/Monolog/Handler/SyslogUdpHandler.php +++ b/src/Monolog/Handler/SyslogUdpHandler.php @@ -30,7 +30,7 @@ class SyslogUdpHandler extends AbstractSyslogHandler const RFC5424e = 2; /** @var array */ - private array $dateFormats = [ + protected array $dateFormats = [ self::RFC3164 => 'M d H:i:s', self::RFC5424 => \DateTime::RFC3339, self::RFC5424e => \DateTime::RFC3339_EXTENDED, @@ -86,7 +86,7 @@ public function close(): void * @param string|string[] $message * @return string[] */ - private function splitMessageIntoLines($message): array + protected function splitMessageIntoLines($message): array { if (\is_array($message)) { $message = implode("\n", $message); diff --git a/src/Monolog/Handler/TelegramBotHandler.php b/src/Monolog/Handler/TelegramBotHandler.php index dcca5d676..201eb0bed 100644 --- a/src/Monolog/Handler/TelegramBotHandler.php +++ b/src/Monolog/Handler/TelegramBotHandler.php @@ -36,12 +36,12 @@ */ class TelegramBotHandler extends AbstractProcessingHandler { - private const BOT_API = 'https://api.telegram.org/bot'; + protected const BOT_API = 'https://api.telegram.org/bot'; /** * The available values of parseMode according to the Telegram api documentation */ - private const AVAILABLE_PARSE_MODES = [ + protected const AVAILABLE_PARSE_MODES = [ 'HTML', 'MarkdownV2', 'Markdown', // legacy mode without underline and strikethrough, use MarkdownV2 instead @@ -50,53 +50,53 @@ class TelegramBotHandler extends AbstractProcessingHandler /** * The maximum number of characters allowed in a message according to the Telegram api documentation */ - private const MAX_MESSAGE_LENGTH = 4096; + protected const MAX_MESSAGE_LENGTH = 4096; /** * Telegram bot access token provided by BotFather. * Create telegram bot with https://telegram.me/BotFather and use access token from it. */ - private string $apiKey; + protected string $apiKey; /** * Telegram channel name. * Since to start with '@' symbol as prefix. */ - private string $channel; + protected string $channel; /** * The kind of formatting that is used for the message. * See available options at https://core.telegram.org/bots/api#formatting-options * or in AVAILABLE_PARSE_MODES */ - private string|null $parseMode; + protected string|null $parseMode; /** * Disables link previews for links in the message. */ - private bool|null $disableWebPagePreview; + protected bool|null $disableWebPagePreview; /** * Sends the message silently. Users will receive a notification with no sound. */ - private bool|null $disableNotification; + protected bool|null $disableNotification; /** * True - split a message longer than MAX_MESSAGE_LENGTH into parts and send in multiple messages. * False - truncates a message that is too long. */ - private bool $splitLongMessages; + protected bool $splitLongMessages; /** * Adds 1-second delay between sending a split message (according to Telegram API to avoid 429 Too Many Requests). */ - private bool $delayBetweenMessages; + protected bool $delayBetweenMessages; /** * Telegram message thread id, unique identifier for the target message thread (topic) of the forum; for forum supergroups only * See how to get the `message_thread_id` https://stackoverflow.com/a/75178418 */ - private int|null $topic; + protected int|null $topic; /** * @param string $apiKey Telegram bot access token provided by BotFather @@ -285,7 +285,7 @@ protected function sendCurl(string $message): void * Handle a message that is too long: truncates or splits into several * @return string[] */ - private function handleMessageLength(string $message): array + protected function handleMessageLength(string $message): array { $truncatedMarker = ' (...truncated)'; if (!$this->splitLongMessages && \strlen($message) > self::MAX_MESSAGE_LENGTH) { diff --git a/src/Monolog/Handler/TestHandler.php b/src/Monolog/Handler/TestHandler.php index eb5fb445c..1ed226693 100644 --- a/src/Monolog/Handler/TestHandler.php +++ b/src/Monolog/Handler/TestHandler.php @@ -74,7 +74,7 @@ class TestHandler extends AbstractProcessingHandler protected array $records = []; /** @phpstan-var array, LogRecord[]> */ protected array $recordsByLevel = []; - private bool $skipReset = false; + protected bool $skipReset = false; /** * @return array