mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-22 17:16:18 +02:00
Wrap up type-hint adding to all handlers
This commit is contained in:
@@ -29,14 +29,14 @@ class NewRelicHandler extends AbstractProcessingHandler
|
||||
/**
|
||||
* Name of the New Relic application that will receive logs from this handler.
|
||||
*
|
||||
* @var string
|
||||
* @var string|null
|
||||
*/
|
||||
protected $appName;
|
||||
|
||||
/**
|
||||
* Name of the current transaction
|
||||
*
|
||||
* @var string
|
||||
* @var string|null
|
||||
*/
|
||||
protected $transactionName;
|
||||
|
||||
@@ -51,16 +51,18 @@ class NewRelicHandler extends AbstractProcessingHandler
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @param string $appName
|
||||
* @param bool $explodeArrays
|
||||
* @param string $transactionName
|
||||
* @param string|int $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 string|null $appName
|
||||
* @param bool $explodeArrays
|
||||
* @param string|null $transactionName
|
||||
*/
|
||||
public function __construct(
|
||||
$level = Logger::ERROR,
|
||||
$bubble = true,
|
||||
$appName = null,
|
||||
$explodeArrays = false,
|
||||
$transactionName = null
|
||||
bool $bubble = true,
|
||||
?string $appName = null,
|
||||
bool $explodeArrays = false,
|
||||
?string $transactionName = null
|
||||
) {
|
||||
parent::__construct($level, $bubble);
|
||||
|
||||
@@ -124,7 +126,7 @@ class NewRelicHandler extends AbstractProcessingHandler
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isNewRelicEnabled()
|
||||
protected function isNewRelicEnabled(): bool
|
||||
{
|
||||
return extension_loaded('newrelic');
|
||||
}
|
||||
@@ -132,11 +134,8 @@ class NewRelicHandler extends AbstractProcessingHandler
|
||||
/**
|
||||
* Returns the appname where this log should be sent. Each log can override the default appname, set in this
|
||||
* handler's constructor, by providing the appname in it's context.
|
||||
*
|
||||
* @param array $context
|
||||
* @return null|string
|
||||
*/
|
||||
protected function getAppName(array $context)
|
||||
protected function getAppName(array $context): ?string
|
||||
{
|
||||
if (isset($context['appname'])) {
|
||||
return $context['appname'];
|
||||
@@ -148,12 +147,8 @@ class NewRelicHandler extends AbstractProcessingHandler
|
||||
/**
|
||||
* Returns the name of the current transaction. Each log can override the default transaction name, set in this
|
||||
* handler's constructor, by providing the transaction_name in it's context
|
||||
*
|
||||
* @param array $context
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
protected function getTransactionName(array $context)
|
||||
protected function getTransactionName(array $context): ?string
|
||||
{
|
||||
if (isset($context['transaction_name'])) {
|
||||
return $context['transaction_name'];
|
||||
@@ -164,20 +159,16 @@ class NewRelicHandler extends AbstractProcessingHandler
|
||||
|
||||
/**
|
||||
* Sets the NewRelic application that should receive this log.
|
||||
*
|
||||
* @param string $appName
|
||||
*/
|
||||
protected function setNewRelicAppName($appName)
|
||||
protected function setNewRelicAppName(string $appName): void
|
||||
{
|
||||
newrelic_set_appname($appName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrites the name of the current transaction
|
||||
*
|
||||
* @param string $transactionName
|
||||
*/
|
||||
protected function setNewRelicTransactionName($transactionName)
|
||||
protected function setNewRelicTransactionName(string $transactionName): void
|
||||
{
|
||||
newrelic_name_transaction($transactionName);
|
||||
}
|
||||
@@ -186,7 +177,7 @@ class NewRelicHandler extends AbstractProcessingHandler
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*/
|
||||
protected function setNewRelicParameter($key, $value)
|
||||
protected function setNewRelicParameter(string $key, $value): void
|
||||
{
|
||||
if (null === $value || is_scalar($value)) {
|
||||
newrelic_add_custom_parameter($key, $value);
|
||||
|
Reference in New Issue
Block a user