1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-23 09:36:11 +02:00

Fix type errors, thanks phan

This commit is contained in:
Jordi Boggiano
2016-09-25 22:00:12 +02:00
parent 85792c8818
commit 5ce1c921ad
16 changed files with 56 additions and 68 deletions

View File

@@ -174,16 +174,14 @@ class ChromePHPHandler extends AbstractProcessingHandler
/**
* Verifies if the headers are accepted by the current user agent
*
* @return Boolean
*/
protected function headersAccepted()
protected function headersAccepted(): bool
{
if (empty($_SERVER['HTTP_USER_AGENT'])) {
return false;
}
return preg_match(self::USER_AGENT_REGEX, $_SERVER['HTTP_USER_AGENT']);
return preg_match(self::USER_AGENT_REGEX, $_SERVER['HTTP_USER_AGENT']) === 1;
}
/**

View File

@@ -61,7 +61,7 @@ class FirePHPHandler extends AbstractProcessingHandler
* @param string $message Log message
* @return array Complete header string ready for the client as key and message as value
*/
protected function createHeader(array $meta, $message)
protected function createHeader(array $meta, string $message): array
{
$header = sprintf('%s-%s', self::HEADER_PREFIX, join('-', $meta));
@@ -72,10 +72,8 @@ class FirePHPHandler extends AbstractProcessingHandler
* Creates message header from record
*
* @see createHeader()
* @param array $record
* @return string
*/
protected function createRecordHeader(array $record)
protected function createRecordHeader(array $record): array
{
// Wildfire is extensible to support multiple protocols & plugins in a single request,
// but we're not taking advantage of that (yet), so we're using "1" for simplicity's sake.

View File

@@ -64,8 +64,6 @@ class FlowdockHandler extends SocketHandler
/**
* Gets the default formatter.
*
* @return FormatterInterface
*/
protected function getDefaultFormatter(): FormatterInterface
{

View File

@@ -25,7 +25,7 @@ use Monolog\Formatter\FormatterInterface;
class GelfHandler extends AbstractProcessingHandler
{
/**
* @var Publisher the publisher object that sends the message to the server
* @var PublisherInterface|null the publisher object that sends the message to the server
*/
protected $publisher;

View File

@@ -29,7 +29,7 @@ class ProcessHandler extends AbstractProcessingHandler
/**
* Holds the process to receive data on its STDIN.
*
* @var resource
* @var resource|bool|null
*/
private $process;
@@ -58,20 +58,20 @@ class ProcessHandler extends AbstractProcessingHandler
];
/**
* @param int $command Command for the process to start. Absolute paths are recommended,
* @param string $command Command for the process to start. Absolute paths are recommended,
* especially if you do not use the $cwd parameter.
* @param bool|int $level The minimum logging level at which this handler will be triggered.
* @param bool|true $bubble Whether the messages that are handled can bubble up the stack or not.
* @param string|null $cwd "Current working directory" (CWD) for the process to be executed in.
* @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 $cwd "Current working directory" (CWD) for the process to be executed in.
* @throws \InvalidArgumentException
*/
public function __construct($command, $level = Logger::DEBUG, $bubble = true, $cwd = null)
public function __construct(string $command, $level = Logger::DEBUG, bool $bubble = true, string $cwd = null)
{
if (empty($command) || is_string($command) === false) {
if ($command === '') {
throw new \InvalidArgumentException('The command argument must be a non-empty string.');
}
if ($cwd !== null && (empty($cwd) || is_string($cwd) === false)) {
throw new \InvalidArgumentException('The optional CWD argument must be a non-empty string, if any.');
if ($cwd === '') {
throw new \InvalidArgumentException('The optional CWD argument must be a non-empty string or null.');
}
parent::__construct($level, $bubble);

View File

@@ -133,6 +133,7 @@ class RavenHandler extends AbstractProcessingHandler
*/
protected function write(array $record)
{
/** @var bool|null|array This is false, unless set below to null or an array of data, when we read the current user context */
$previousUserContext = false;
$options = [];
$options['level'] = $this->logLevels[$record['level']];
@@ -186,7 +187,8 @@ class RavenHandler extends AbstractProcessingHandler
$this->ravenClient->captureMessage($record['formatted'], [], $options);
}
if ($previousUserContext !== false) {
// restore the user context if it was modified
if (!is_bool($previousUserContext)) {
$this->ravenClient->user_context($previousUserContext);
}
}

View File

@@ -37,9 +37,9 @@ class RedisHandler extends AbstractProcessingHandler
* @param string $key The key name to push records to
* @param 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 int $capSize Number of entries to limit list size to
* @param int $capSize Number of entries to limit list size to, 0 = unlimited
*/
public function __construct($redis, $key, $level = Logger::DEBUG, $bubble = true, $capSize = false)
public function __construct($redis, string $key, $level = Logger::DEBUG, bool $bubble = true, int $capSize = 0)
{
if (!(($redis instanceof \Predis\Client) || ($redis instanceof \Redis))) {
throw new \InvalidArgumentException('Predis\Client or Redis instance required');

View File

@@ -23,8 +23,11 @@ class SocketHandler extends AbstractProcessingHandler
{
private $connectionString;
private $connectionTimeout;
/** @var resource|null */
private $resource;
/** @var float */
private $timeout = 0;
/** @var float */
private $writingTimeout = 10;
private $lastSentBytes = null;
private $persistent = false;
@@ -149,20 +152,16 @@ class SocketHandler extends AbstractProcessingHandler
/**
* Get current connection timeout setting
*
* @return float
*/
public function getConnectionTimeout()
public function getConnectionTimeout(): float
{
return $this->connectionTimeout;
}
/**
* Get current in-transfer timeout
*
* @return float
*/
public function getTimeout()
public function getTimeout(): float
{
return $this->timeout;
}
@@ -172,7 +171,7 @@ class SocketHandler extends AbstractProcessingHandler
*
* @return float
*/
public function getWritingTimeout()
public function getWritingTimeout(): float
{
return $this->writingTimeout;
}

View File

@@ -22,8 +22,10 @@ use Monolog\Logger;
*/
class StreamHandler extends AbstractProcessingHandler
{
/** @var resource|null */
protected $stream;
protected $url;
/** @var string|null */
private $errorMessage;
protected $filePermission;
protected $useLocking;

View File

@@ -17,6 +17,8 @@ class UdpSocket
protected $ip;
protected $port;
/** @var resource|null */
protected $socket;
public function __construct($ip, $port = 514)