1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-07 21:56:31 +02:00

Add more type hints

This commit is contained in:
Avtandil Kikabidze
2018-09-12 18:20:33 +04:00
parent 8656fb1352
commit be5c439167
4 changed files with 10 additions and 8 deletions

View File

@@ -65,6 +65,8 @@ class ElasticaFormatter extends NormalizerFormatter
/** /**
* Convert a log message into an Elastica Document * Convert a log message into an Elastica Document
* @param array $record
* @return Document
*/ */
protected function getDocument(array $record): Document protected function getDocument(array $record): Document
{ {

View File

@@ -34,7 +34,7 @@ class ElasticsearchFormatter extends NormalizerFormatter
* @param string $index Elasticsearch index name * @param string $index Elasticsearch index name
* @param string $type Elasticsearch record type * @param string $type Elasticsearch record type
*/ */
public function __construct($index, $type) public function __construct(string $index, string $type)
{ {
// Elasticsearch requires an ISO 8601 format date with optional millisecond precision. // Elasticsearch requires an ISO 8601 format date with optional millisecond precision.
parent::__construct(DateTime::ISO8601); parent::__construct(DateTime::ISO8601);
@@ -79,7 +79,7 @@ class ElasticsearchFormatter extends NormalizerFormatter
* @param array $record Log message * @param array $record Log message
* @return array * @return array
*/ */
protected function getDocument($record): array protected function getDocument(array $record): array
{ {
$record['_index'] = $this->index; $record['_index'] = $this->index;
$record['_type'] = $this->type; $record['_type'] = $this->type;

View File

@@ -88,7 +88,7 @@ class ElasticaHandler extends AbstractProcessingHandler
* Getter options * Getter options
* @return array * @return array
*/ */
public function getOptions() public function getOptions(): array
{ {
return $this->options; return $this->options;
} }
@@ -115,7 +115,7 @@ class ElasticaHandler extends AbstractProcessingHandler
* @param array $documents * @param array $documents
* @throws \RuntimeException * @throws \RuntimeException
*/ */
protected function bulkSend(array $documents) protected function bulkSend(array $documents): void
{ {
try { try {
$this->client->addDocuments($documents); $this->client->addDocuments($documents);

View File

@@ -59,7 +59,7 @@ class ElasticsearchHandler extends AbstractProcessingHandler
* @param int $level The minimum logging level at which this handler will be triggered * @param int $level The minimum logging level at which this handler will be triggered
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
*/ */
public function __construct(Client $client, array $options = [], $level = Logger::DEBUG, $bubble = true) public function __construct(Client $client, array $options = [], $level = Logger::DEBUG, bool $bubble = true)
{ {
parent::__construct($level, $bubble); parent::__construct($level, $bubble);
$this->client = $client; $this->client = $client;
@@ -76,7 +76,7 @@ class ElasticsearchHandler extends AbstractProcessingHandler
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
protected function write(array $record) protected function write(array $record): void
{ {
$this->bulkSend([$record['formatted']]); $this->bulkSend([$record['formatted']]);
} }
@@ -113,7 +113,7 @@ class ElasticsearchHandler extends AbstractProcessingHandler
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function handleBatch(array $records) public function handleBatch(array $records): void
{ {
$documents = $this->getFormatter()->formatBatch($records); $documents = $this->getFormatter()->formatBatch($records);
$this->bulkSend($documents); $this->bulkSend($documents);
@@ -125,7 +125,7 @@ class ElasticsearchHandler extends AbstractProcessingHandler
* @param array $records * @param array $records
* @throws \RuntimeException * @throws \RuntimeException
*/ */
protected function bulkSend(array $records) protected function bulkSend(array $records): void
{ {
try { try {
$params = [ $params = [