Explorar o código

Add more type hints

Avtandil Kikabidze %!s(int64=7) %!d(string=hai) anos
pai
achega
be5c439167

+ 2 - 0
src/Monolog/Formatter/ElasticaFormatter.php

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

+ 2 - 2
src/Monolog/Formatter/ElasticsearchFormatter.php

@@ -34,7 +34,7 @@ class ElasticsearchFormatter extends NormalizerFormatter
      * @param string $index Elasticsearch index name
      * @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.
         parent::__construct(DateTime::ISO8601);
@@ -79,7 +79,7 @@ class ElasticsearchFormatter extends NormalizerFormatter
      * @param  array $record Log message
      * @return array
      */
-    protected function getDocument($record): array
+    protected function getDocument(array $record): array
     {
         $record['_index'] = $this->index;
         $record['_type'] = $this->type;

+ 2 - 2
src/Monolog/Handler/ElasticaHandler.php

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

+ 4 - 4
src/Monolog/Handler/ElasticsearchHandler.php

@@ -59,7 +59,7 @@ class ElasticsearchHandler extends AbstractProcessingHandler
      * @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
      */
-    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);
         $this->client = $client;
@@ -76,7 +76,7 @@ class ElasticsearchHandler extends AbstractProcessingHandler
     /**
      * {@inheritDoc}
      */
-    protected function write(array $record)
+    protected function write(array $record): void
     {
         $this->bulkSend([$record['formatted']]);
     }
@@ -113,7 +113,7 @@ class ElasticsearchHandler extends AbstractProcessingHandler
     /**
      * {@inheritdoc}
      */
-    public function handleBatch(array $records)
+    public function handleBatch(array $records): void
     {
         $documents = $this->getFormatter()->formatBatch($records);
         $this->bulkSend($documents);
@@ -125,7 +125,7 @@ class ElasticsearchHandler extends AbstractProcessingHandler
      * @param  array $records
      * @throws \RuntimeException
      */
-    protected function bulkSend(array $records)
+    protected function bulkSend(array $records): void
     {
         try {
             $params = [