mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-21 20:35:17 +02:00
Move phpdoc to native types
This commit is contained in:
@@ -125,7 +125,6 @@ class ErrorHandlerTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertEquals('E_DEPRECATED', $method->invokeArgs(null, [E_DEPRECATED]));
|
||||
$this->assertEquals('E_USER_DEPRECATED', $method->invokeArgs(null, [E_USER_DEPRECATED]));
|
||||
|
||||
$this->assertEquals('Unknown PHP error', $method->invokeArgs(null, ['RANDOM_TEXT']));
|
||||
$this->assertEquals('Unknown PHP error', $method->invokeArgs(null, [E_ALL]));
|
||||
}
|
||||
}
|
||||
|
@@ -191,12 +191,9 @@ class JsonFormatterTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $expected
|
||||
* @param string $actual
|
||||
*
|
||||
* @internal param string $exception
|
||||
*/
|
||||
private function assertContextContainsFormattedException($expected, $actual)
|
||||
private function assertContextContainsFormattedException(string $expected, string $actual)
|
||||
{
|
||||
$this->assertEquals(
|
||||
'{"message":"foobar","context":{"exception":'.$expected.'},"level":500,"level_name":"CRITICAL","channel":"core","datetime":"2022-02-22T00:00:00+00:00","extra":{}}'."\n",
|
||||
@@ -204,10 +201,7 @@ class JsonFormatterTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function formatRecordWithExceptionInContext(JsonFormatter $formatter, \Throwable $exception)
|
||||
private function formatRecordWithExceptionInContext(JsonFormatter $formatter, \Throwable $exception): string
|
||||
{
|
||||
$message = $formatter->format($this->getRecord(
|
||||
Level::Critical,
|
||||
@@ -222,10 +216,8 @@ class JsonFormatterTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param \Exception|\Throwable $exception
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function formatExceptionFilePathWithLine($exception)
|
||||
private function formatExceptionFilePathWithLine($exception): string
|
||||
{
|
||||
$options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
|
||||
$path = substr(json_encode($exception->getFile(), $options), 1, -1);
|
||||
@@ -235,12 +227,8 @@ class JsonFormatterTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param \Exception|\Throwable $exception
|
||||
*
|
||||
* @param null|string $previous
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function formatException($exception, $previous = null)
|
||||
private function formatException($exception, ?string $previous = null): string
|
||||
{
|
||||
$formattedException =
|
||||
'{"class":"' . get_class($exception) .
|
||||
|
@@ -371,10 +371,7 @@ class NormalizerFormatterTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function formatRecordWithExceptionInContext(NormalizerFormatter $formatter, \Throwable $exception)
|
||||
private function formatRecordWithExceptionInContext(NormalizerFormatter $formatter, \Throwable $exception): array
|
||||
{
|
||||
$message = $formatter->format($this->getRecord(
|
||||
Level::Critical,
|
||||
|
@@ -24,12 +24,12 @@ class ElasticaHandlerTest extends TestCase
|
||||
/**
|
||||
* @var Client mock
|
||||
*/
|
||||
protected $client;
|
||||
protected Client $client;
|
||||
|
||||
/**
|
||||
* @var array Default handler options
|
||||
*/
|
||||
protected $options = [
|
||||
protected array $options = [
|
||||
'index' => 'my_index',
|
||||
'type' => 'doc_type',
|
||||
];
|
||||
@@ -136,10 +136,7 @@ class ElasticaHandlerTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function providerTestConnectionErrors()
|
||||
public function providerTestConnectionErrors(): array
|
||||
{
|
||||
return [
|
||||
[false, ['RuntimeException', 'Error sending messages to Elasticsearch']],
|
||||
@@ -241,10 +238,9 @@ class ElasticaHandlerTest extends TestCase
|
||||
|
||||
/**
|
||||
* Return last created document id from ES response
|
||||
* @param Response $response Elastica Response object
|
||||
* @return string|null
|
||||
* @param Response $response Elastica Response object
|
||||
*/
|
||||
protected function getCreatedDocId(Response $response)
|
||||
protected function getCreatedDocId(Response $response): ?string
|
||||
{
|
||||
$data = $response->getData();
|
||||
if (!empty($data['items'][0]['create']['_id'])) {
|
||||
@@ -254,13 +250,10 @@ class ElasticaHandlerTest extends TestCase
|
||||
|
||||
/**
|
||||
* Retrieve document by id from Elasticsearch
|
||||
* @param Client $client Elastica client
|
||||
* @param string $index
|
||||
* @param ?string $type
|
||||
* @param string $documentId
|
||||
* @return array
|
||||
* @param Client $client Elastica client
|
||||
* @param ?string $type
|
||||
*/
|
||||
protected function getDocSourceFromElastic(Client $client, $index, $type, $documentId)
|
||||
protected function getDocSourceFromElastic(Client $client, string $index, $type, string $documentId): array
|
||||
{
|
||||
if ($type === null) {
|
||||
$path = "/{$index}/_doc/{$documentId}";
|
||||
|
@@ -23,12 +23,12 @@ class ElasticsearchHandlerTest extends TestCase
|
||||
/**
|
||||
* @var Client mock
|
||||
*/
|
||||
protected $client;
|
||||
protected Client $client;
|
||||
|
||||
/**
|
||||
* @var array Default handler options
|
||||
*/
|
||||
protected $options = [
|
||||
protected array $options = [
|
||||
'index' => 'my_index',
|
||||
'type' => 'doc_type',
|
||||
];
|
||||
@@ -151,10 +151,7 @@ class ElasticsearchHandlerTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function providerTestConnectionErrors()
|
||||
public function providerTestConnectionErrors(): array
|
||||
{
|
||||
return [
|
||||
[false, ['RuntimeException', 'Error sending messages to Elasticsearch']],
|
||||
@@ -215,10 +212,9 @@ class ElasticsearchHandlerTest extends TestCase
|
||||
/**
|
||||
* Return last created document id from ES response
|
||||
*
|
||||
* @param array $info Elasticsearch last request info
|
||||
* @return string|null
|
||||
* @param array $info Elasticsearch last request info
|
||||
*/
|
||||
protected function getCreatedDocId(array $info)
|
||||
protected function getCreatedDocId(array $info): ?string
|
||||
{
|
||||
$data = json_decode($info['response']['body'], true);
|
||||
|
||||
@@ -230,13 +226,9 @@ class ElasticsearchHandlerTest extends TestCase
|
||||
/**
|
||||
* Retrieve document by id from Elasticsearch
|
||||
*
|
||||
* @param Client $client Elasticsearch client
|
||||
* @param string $index
|
||||
* @param string $type
|
||||
* @param string $documentId
|
||||
* @return array
|
||||
* @param Client $client Elasticsearch client
|
||||
*/
|
||||
protected function getDocSourceFromElastic(Client $client, $index, $type, $documentId)
|
||||
protected function getDocSourceFromElastic(Client $client, string $index, string $type, string $documentId): array
|
||||
{
|
||||
$params = [
|
||||
'index' => $index,
|
||||
|
@@ -17,7 +17,7 @@ use Monolog\LogRecord;
|
||||
class ExceptionTestHandler extends TestHandler
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function handle(LogRecord $record): bool
|
||||
{
|
||||
|
@@ -25,10 +25,7 @@ class FleepHookHandlerTest extends TestCase
|
||||
*/
|
||||
const TOKEN = '123abc';
|
||||
|
||||
/**
|
||||
* @var FleepHookHandler
|
||||
*/
|
||||
private $handler;
|
||||
private FleepHookHandler $handler;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
@@ -26,10 +26,7 @@ class FlowdockHandlerTest extends TestCase
|
||||
*/
|
||||
private $res;
|
||||
|
||||
/**
|
||||
* @var FlowdockHandler
|
||||
*/
|
||||
private $handler;
|
||||
private FlowdockHandler $handler;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
@@ -18,10 +18,7 @@ use Monolog\Test\TestCase;
|
||||
*/
|
||||
class HandlerWrapperTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var HandlerWrapper
|
||||
*/
|
||||
private $wrapper;
|
||||
private HandlerWrapper $wrapper;
|
||||
|
||||
private $handler;
|
||||
|
||||
@@ -32,10 +29,7 @@ class HandlerWrapperTest extends TestCase
|
||||
$this->wrapper = new HandlerWrapper($this->handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function trueFalseDataProvider()
|
||||
public function trueFalseDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[true],
|
||||
|
@@ -13,6 +13,7 @@ namespace Monolog\Handler;
|
||||
|
||||
use Monolog\Test\TestCase;
|
||||
use Monolog\Level;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
/**
|
||||
* @author Robert Kaufmann III <rok3@rok3.me>
|
||||
@@ -25,10 +26,7 @@ class InsightOpsHandlerTest extends TestCase
|
||||
*/
|
||||
private $resource;
|
||||
|
||||
/**
|
||||
* @var LogEntriesHandler
|
||||
*/
|
||||
private $handler;
|
||||
private InsightOpsHandler&MockObject $handler;
|
||||
|
||||
public function testWriteContent()
|
||||
{
|
||||
|
@@ -13,6 +13,7 @@ namespace Monolog\Handler;
|
||||
|
||||
use Monolog\Test\TestCase;
|
||||
use Monolog\Level;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
/**
|
||||
* @author Robert Kaufmann III <rok3@rok3.me>
|
||||
@@ -24,10 +25,7 @@ class LogEntriesHandlerTest extends TestCase
|
||||
*/
|
||||
private $res;
|
||||
|
||||
/**
|
||||
* @var LogEntriesHandler
|
||||
*/
|
||||
private $handler;
|
||||
private LogEntriesHandler&MockObject $handler;
|
||||
|
||||
public function testWriteContent()
|
||||
{
|
||||
|
@@ -13,6 +13,7 @@ namespace Monolog\Handler;
|
||||
|
||||
use Monolog\Test\TestCase;
|
||||
use Monolog\Level;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
/**
|
||||
* @author Julien Breux <julien.breux@gmail.com>
|
||||
@@ -24,10 +25,7 @@ class LogmaticHandlerTest extends TestCase
|
||||
*/
|
||||
private $res;
|
||||
|
||||
/**
|
||||
* @var LogmaticHandler
|
||||
*/
|
||||
private $handler;
|
||||
private LogmaticHandler&MockObject $handler;
|
||||
|
||||
public function testWriteContent()
|
||||
{
|
||||
|
@@ -57,10 +57,8 @@ class ProcessHandlerTest extends TestCase
|
||||
|
||||
/**
|
||||
* Data provider for invalid commands.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function invalidCommandProvider()
|
||||
public function invalidCommandProvider(): array
|
||||
{
|
||||
return [
|
||||
[1337, 'TypeError'],
|
||||
@@ -83,10 +81,8 @@ class ProcessHandlerTest extends TestCase
|
||||
|
||||
/**
|
||||
* Data provider for invalid CWDs.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function invalidCwdProvider()
|
||||
public function invalidCwdProvider(): array
|
||||
{
|
||||
return [
|
||||
[1337, 'TypeError'],
|
||||
|
@@ -27,15 +27,9 @@ use Rollbar\RollbarLogger;
|
||||
*/
|
||||
class RollbarHandlerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var MockObject
|
||||
*/
|
||||
private $rollbarLogger;
|
||||
private RollbarLogger&MockObject $rollbarLogger;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $reportedExceptionArguments = null;
|
||||
private array $reportedExceptionArguments;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
@@ -65,10 +65,7 @@ class SlackRecordTest extends TestCase
|
||||
$this->assertArrayNotHasKey('username', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function dataStringify()
|
||||
public function dataStringify(): array
|
||||
{
|
||||
$multipleDimensions = [[1, 2]];
|
||||
$numericKeys = ['library' => 'monolog'];
|
||||
|
@@ -27,10 +27,7 @@ class SlackHandlerTest extends TestCase
|
||||
*/
|
||||
private $res;
|
||||
|
||||
/**
|
||||
* @var SlackHandler
|
||||
*/
|
||||
private $handler;
|
||||
private SlackHandler $handler;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
|
@@ -261,9 +261,8 @@ STRING;
|
||||
|
||||
/**
|
||||
* @dataProvider provideMemoryValues
|
||||
* @return void
|
||||
*/
|
||||
public function testPreventOOMError($phpMemory, $expectedChunkSize)
|
||||
public function testPreventOOMError($phpMemory, $expectedChunkSize): void
|
||||
{
|
||||
$previousValue = ini_set('memory_limit', $phpMemory);
|
||||
|
||||
@@ -287,10 +286,7 @@ STRING;
|
||||
$this->assertEquals($expectedChunkSize, $handler->getStreamChunkSize());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testSimpleOOMPrevention()
|
||||
public function testSimpleOOMPrevention(): void
|
||||
{
|
||||
$previousValue = ini_set('memory_limit', '2048M');
|
||||
|
||||
|
@@ -13,6 +13,7 @@ namespace Monolog\Handler;
|
||||
|
||||
use Monolog\Level;
|
||||
use Monolog\Test\TestCase;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
/**
|
||||
* @author Mazur Alexandr <alexandrmazur96@gmail.com>
|
||||
@@ -20,10 +21,7 @@ use Monolog\Test\TestCase;
|
||||
*/
|
||||
class TelegramBotHandlerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var TelegramBotHandler
|
||||
*/
|
||||
private $handler;
|
||||
private TelegramBotHandler&MockObject $handler;
|
||||
|
||||
public function testSendTelegramRequest(): void
|
||||
{
|
||||
@@ -31,8 +29,6 @@ class TelegramBotHandlerTest extends TestCase
|
||||
$this->handler->handle($this->getRecord());
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
private function createHandler(
|
||||
string $apiKey = 'testKey',
|
||||
string $channel = 'testChannel',
|
||||
|
@@ -15,10 +15,12 @@ use DateTimeZone;
|
||||
use Monolog\Handler\TestHandler;
|
||||
use Monolog\Formatter\LineFormatter;
|
||||
use Monolog\Processor\PsrLogMessageProcessor;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\InvalidArgumentException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\LogLevel;
|
||||
use Stringable;
|
||||
|
||||
class PsrLogCompatTest extends TestCase
|
||||
{
|
||||
@@ -153,13 +155,11 @@ class PsrLogCompatTest extends TestCase
|
||||
/**
|
||||
* Creates a mock of a `Stringable`.
|
||||
*
|
||||
* @param string $string The string that must be represented by the stringable.
|
||||
* @return \PHPUnit_Framework_MockObject_MockObject A mock of an object that has a `__toString()` method.
|
||||
* @param string $string The string that must be represented by the stringable.
|
||||
*/
|
||||
protected function createStringable($string = '')
|
||||
protected function createStringable(string $string = ''): MockObject&Stringable
|
||||
{
|
||||
$mock = $this->getMockBuilder('Stringable')
|
||||
->setMethods(['__toString'])
|
||||
$mock = $this->getMockBuilder(Stringable::class)
|
||||
->getMock();
|
||||
|
||||
$mock->method('__toString')
|
||||
|
@@ -14,11 +14,9 @@ namespace Monolog;
|
||||
class UtilsTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @param string $expected
|
||||
* @param object $object
|
||||
* @dataProvider provideObjects
|
||||
*/
|
||||
public function testGetClass($expected, $object)
|
||||
public function testGetClass(string $expected, object $object)
|
||||
{
|
||||
$this->assertSame($expected, Utils::getClass($object));
|
||||
}
|
||||
@@ -35,11 +33,9 @@ class UtilsTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $expected
|
||||
* @param string $input
|
||||
* @dataProvider providePathsToCanonicalize
|
||||
*/
|
||||
public function testCanonicalizePath($expected, $input)
|
||||
public function testCanonicalizePath(string $expected, string $input)
|
||||
{
|
||||
$this->assertSame($expected, Utils::canonicalizePath($input));
|
||||
}
|
||||
@@ -58,11 +54,9 @@ class UtilsTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $code
|
||||
* @param string $msg
|
||||
* @dataProvider providesHandleJsonErrorFailure
|
||||
*/
|
||||
public function testHandleJsonErrorFailure($code, $msg)
|
||||
public function testHandleJsonErrorFailure(int $code, string $msg)
|
||||
{
|
||||
$this->expectException('RuntimeException', $msg);
|
||||
Utils::handleJsonError($code, 'faked');
|
||||
@@ -114,10 +108,8 @@ class UtilsTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider providesPcreLastErrorMessage
|
||||
* @param int $code
|
||||
* @param string $msg
|
||||
*/
|
||||
public function testPcreLastErrorMessage($code, $msg)
|
||||
public function testPcreLastErrorMessage(int $code, string $msg)
|
||||
{
|
||||
if (PHP_VERSION_ID >= 80000) {
|
||||
$this->assertSame('No error', Utils::pcreLastErrorMessage($code));
|
||||
@@ -131,7 +123,7 @@ class UtilsTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @return array[]
|
||||
*/
|
||||
public function providesPcreLastErrorMessage()
|
||||
public function providesPcreLastErrorMessage(): array
|
||||
{
|
||||
return [
|
||||
[0, 'PREG_NO_ERROR'],
|
||||
|
Reference in New Issue
Block a user