1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-22 17:16:18 +02:00

Move to strict mode and fix tests

This commit is contained in:
Jordi Boggiano
2016-05-27 13:44:00 +01:00
parent 788902b320
commit 21dde4dedb
170 changed files with 239 additions and 240 deletions

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.
@@ -68,7 +68,12 @@ class GelfMessageFormatter extends NormalizerFormatter
*/
public function format(array $record)
{
$record = parent::format($record);
if (isset($record['context'])) {
$record['context'] = parent::format($record['context']);
}
if (isset($record['extra'])) {
$record['extra'] = parent::format($record['extra']);
}
if (!isset($record['datetime'], $record['message'], $record['level'])) {
throw new \InvalidArgumentException('The record should at least contain datetime, message and level keys, '.var_export($record, true).' given');

View File

@@ -1,4 +1,5 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.
*
@@ -87,7 +88,7 @@ class HtmlFormatter extends NormalizerFormatter
$output .= '<table cellspacing="1" width="100%" class="monolog-output">';
$output .= $this->addRow('Message', (string) $record['message']);
$output .= $this->addRow('Time', $record['datetime']->format($this->dateFormat));
$output .= $this->addRow('Time', $this->formatDate($record['datetime']));
$output .= $this->addRow('Channel', $record['channel']);
if ($record['context']) {
$embeddedTable = '<table cellspacing="1" width="100%">';

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.
@@ -30,7 +30,7 @@ class NormalizerFormatter implements FormatterInterface
*/
public function __construct(string $dateFormat = null)
{
$this->dateFormat = $dateFormat;
$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');
}
@@ -87,11 +87,7 @@ class NormalizerFormatter implements FormatterInterface
}
if ($data instanceof \DateTimeInterface) {
if ($data instanceof DateTimeImmutable) {
return (string) $data;
}
return $data->format($this->dateFormat ?: static::SIMPLE_DATE);
return $this->formatDate($data);
}
if (is_object($data)) {
@@ -271,7 +267,9 @@ class NormalizerFormatter implements FormatterInterface
if (is_string($data) && !preg_match('//u', $data)) {
$data = preg_replace_callback(
'/[\x80-\xFF]+/',
function ($m) { return utf8_encode($m[0]); },
function ($m) {
return utf8_encode($m[0]);
},
$data
);
$data = str_replace(
@@ -281,4 +279,13 @@ class NormalizerFormatter implements FormatterInterface
);
}
}
protected function formatDate(\DateTimeInterface $date)
{
if ($date instanceof DateTimeImmutable) {
return (string) $date;
}
return $date->format($this->dateFormat);
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.