1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-24 10:06:08 +02:00

Add a lot more scalar types and go strict in Logger

This commit is contained in:
Jordi Boggiano
2015-12-18 17:47:20 +00:00
parent c9aa0368bf
commit 6c424f851c
15 changed files with 67 additions and 75 deletions

View File

@@ -36,7 +36,7 @@ abstract class AbstractHandler extends Handler
/**
* {@inheritdoc}
*/
public function isHandling(array $record)
public function isHandling(array $record): bool
{
return $record['level'] >= $this->level;
}
@@ -47,7 +47,7 @@ abstract class AbstractHandler extends Handler
* @param int|string $level Level or level name
* @return self
*/
public function setLevel($level)
public function setLevel($level): self
{
$this->level = Logger::toMonologLevel($level);
@@ -59,7 +59,7 @@ abstract class AbstractHandler extends Handler
*
* @return int
*/
public function getLevel()
public function getLevel(): int
{
return $this->level;
}
@@ -71,7 +71,7 @@ abstract class AbstractHandler extends Handler
* false means that bubbling is not permitted.
* @return self
*/
public function setBubble($bubble)
public function setBubble(bool $bubble): self
{
$this->bubble = $bubble;
@@ -84,7 +84,7 @@ abstract class AbstractHandler extends Handler
* @return Boolean true means that this handler allows bubbling.
* false means that bubbling is not permitted.
*/
public function getBubble()
public function getBubble(): bool
{
return $this->bubble;
}

View File

@@ -27,7 +27,7 @@ abstract class AbstractProcessingHandler extends AbstractHandler implements Proc
/**
* {@inheritdoc}
*/
public function handle(array $record)
public function handle(array $record): bool
{
if (!$this->isHandling($record)) {
return false;

View File

@@ -50,7 +50,7 @@ class BufferHandler extends AbstractHandler implements ProcessableHandlerInterfa
/**
* {@inheritdoc}
*/
public function handle(array $record)
public function handle(array $record): bool
{
if ($record['level'] < $this->level) {
return false;

View File

@@ -66,7 +66,7 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface
/**
* @return array
*/
public function getAcceptedLevels()
public function getAcceptedLevels(): array
{
return array_flip($this->acceptedLevels);
}
@@ -92,7 +92,7 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface
/**
* {@inheritdoc}
*/
public function isHandling(array $record)
public function isHandling(array $record): bool
{
return isset($this->acceptedLevels[$record['level']]);
}
@@ -100,7 +100,7 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface
/**
* {@inheritdoc}
*/
public function handle(array $record)
public function handle(array $record): bool
{
if (!$this->isHandling($record)) {
return false;

View File

@@ -76,7 +76,7 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
/**
* {@inheritdoc}
*/
public function isHandling(array $record)
public function isHandling(array $record): bool
{
return true;
}
@@ -84,7 +84,7 @@ class FingersCrossedHandler extends Handler implements ProcessableHandlerInterfa
/**
* {@inheritdoc}
*/
public function handle(array $record)
public function handle(array $record): bool
{
if ($this->processors) {
$record = $this->processRecord($record);

View File

@@ -41,7 +41,7 @@ class GroupHandler extends Handler implements ProcessableHandlerInterface
/**
* {@inheritdoc}
*/
public function isHandling(array $record)
public function isHandling(array $record): bool
{
foreach ($this->handlers as $handler) {
if ($handler->isHandling($record)) {
@@ -55,7 +55,7 @@ class GroupHandler extends Handler implements ProcessableHandlerInterface
/**
* {@inheritdoc}
*/
public function handle(array $record)
public function handle(array $record): bool
{
if ($this->processors) {
$record = $this->processRecord($record);

View File

@@ -31,7 +31,7 @@ interface HandlerInterface
*
* @return Boolean
*/
public function isHandling(array $record);
public function isHandling(array $record): bool;
/**
* Handles a record.
@@ -47,7 +47,7 @@ interface HandlerInterface
* @return Boolean true means that this handler handled the record, and that bubbling is not permitted.
* false means the record was either not processed or that this handler allows bubbling.
*/
public function handle(array $record);
public function handle(array $record): bool;
/**
* Handles a set of records at once.

View File

@@ -36,7 +36,7 @@ class NullHandler extends Handler
/**
* {@inheritdoc}
*/
public function isHandling(array $record)
public function isHandling(array $record): bool
{
return $record['level'] >= $this->level;
}
@@ -44,7 +44,7 @@ class NullHandler extends Handler
/**
* {@inheritdoc}
*/
public function handle(array $record)
public function handle(array $record): bool
{
if ($record['level'] < $this->level) {
return false;

View File

@@ -157,7 +157,7 @@ class PHPConsoleHandler extends AbstractProcessingHandler
return $this->options;
}
public function handle(array $record)
public function handle(array $record): bool
{
if ($this->options['enabled'] && $this->connector->isActiveClient()) {
return parent::handle($record);

View File

@@ -43,7 +43,7 @@ class PsrHandler extends AbstractHandler
/**
* {@inheritDoc}
*/
public function handle(array $record)
public function handle(array $record): bool
{
if (!$this->isHandling($record)) {
return false;

View File

@@ -54,12 +54,12 @@ class SamplingHandler extends AbstractHandler implements ProcessableHandlerInter
}
}
public function isHandling(array $record)
public function isHandling(array $record): bool
{
return $this->handler->isHandling($record);
}
public function handle(array $record)
public function handle(array $record): bool
{
if ($this->isHandling($record) && mt_rand(1, $this->factor) === 1) {
// The same logic as in FingersCrossedHandler

View File

@@ -22,7 +22,7 @@ class WhatFailureGroupHandler extends GroupHandler
/**
* {@inheritdoc}
*/
public function handle(array $record)
public function handle(array $record): bool
{
if ($this->processors) {
foreach ($this->processors as $processor) {