Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pointless json_encode availability checks #1919

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/Monolog/Formatter/ElasticaFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ class ElasticaFormatter extends NormalizerFormatter
/**
* @param string $index Elastic Search index name
* @param ?string $type Elastic Search document type, deprecated as of Elastica 7
*
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(string $index, ?string $type)
{
Expand Down
2 changes: 0 additions & 2 deletions src/Monolog/Formatter/ElasticsearchFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ class ElasticsearchFormatter extends NormalizerFormatter
/**
* @param string $index Elasticsearch index name
* @param string $type Elasticsearch record type
*
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(string $index, string $type)
{
Expand Down
7 changes: 0 additions & 7 deletions src/Monolog/Formatter/FluentdFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,8 @@ class FluentdFormatter implements FormatterInterface
*/
protected bool $levelTag = false;

/**
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(bool $levelTag = false)
{
if (!\function_exists('json_encode')) {
throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s FluentdUnixFormatter');
}

$this->levelTag = $levelTag;
}

Expand Down
3 changes: 1 addition & 2 deletions src/Monolog/Formatter/HtmlFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ protected function getLevelColor(Level $level): string
}

/**
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
* @throws \RuntimeException If the function json_encode does not exist
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
*/
public function __construct(?string $dateFormat = null)
{
Expand Down
2 changes: 0 additions & 2 deletions src/Monolog/Formatter/JsonFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ class JsonFormatter extends NormalizerFormatter

/**
* @param self::BATCH_MODE_* $batchMode
*
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(int $batchMode = self::BATCH_MODE_JSON, bool $appendNewline = true, bool $ignoreEmptyContextAndExtra = false, bool $includeStacktraces = false)
{
Expand Down
2 changes: 0 additions & 2 deletions src/Monolog/Formatter/LineFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class LineFormatter extends NormalizerFormatter
* @param string|null $format The format of the message
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
* @param bool $allowInlineLineBreaks Whether to allow inline line breaks in log entries
*
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(?string $format = null, ?string $dateFormat = null, bool $allowInlineLineBreaks = false, bool $ignoreEmptyContextAndExtra = false, bool $includeStacktraces = false)
{
Expand Down
2 changes: 0 additions & 2 deletions src/Monolog/Formatter/LogstashFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ class LogstashFormatter extends NormalizerFormatter
* @param string|null $systemName The system/machine name, used as the "source" field of logstash, defaults to the hostname of the machine
* @param string $extraKey The key for extra keys inside logstash "fields", defaults to extra
* @param string $contextKey The key for context keys inside logstash "fields", defaults to context
*
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(string $applicationName, ?string $systemName = null, string $extraKey = 'extra', string $contextKey = 'context')
{
Expand Down
6 changes: 1 addition & 5 deletions src/Monolog/Formatter/NormalizerFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,11 @@ class NormalizerFormatter implements FormatterInterface
protected string $basePath = '';

/**
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
* @throws \RuntimeException If the function json_encode does not exist
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
*/
public function __construct(?string $dateFormat = null)
{
$this->dateFormat = null === $dateFormat ? static::SIMPLE_DATE : $dateFormat;
if (!\function_exists('json_encode')) {
throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s NormalizerFormatter');
}
}

/**
Expand Down
2 changes: 0 additions & 2 deletions src/Monolog/Formatter/WildfireFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ class WildfireFormatter extends NormalizerFormatter
{
/**
* @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
6 changes: 0 additions & 6 deletions src/Monolog/Handler/ChromePHPHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,9 @@ class ChromePHPHandler extends AbstractProcessingHandler

protected static bool $sendHeaders = true;

/**
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(int|string|Level $level = Level::Debug, bool $bubble = true)
{
parent::__construct($level, $bubble);
if (!\function_exists('json_encode')) {
throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s ChromePHPHandler');
}
}

/**
Expand Down
Loading