Bläddra i källkod

Fix phpstan build

Jordi Boggiano 1 år sedan
förälder
incheckning
d5b588a306
2 ändrade filer med 36 tillägg och 3 borttagningar
  1. 26 1
      phpstan-baseline.neon
  2. 10 2
      src/Monolog/Handler/ElasticsearchHandler.php

+ 26 - 1
phpstan-baseline.neon

@@ -21,7 +21,32 @@ parameters:
 			path: src/Monolog/Formatter/WildfireFormatter.php
 
 		-
-			message: "#^Cannot access offset 'items' on array\\|Elastic\\\\Elasticsearch\\\\Response\\\\Elasticsearch\\.$#"
+			message: "#^Access to constant VERSION on an unknown class Elasticsearch\\\\Client\\.$#"
+			count: 1
+			path: src/Monolog/Handler/ElasticsearchHandler.php
+
+		-
+			message: "#^Call to method bulk\\(\\) on an unknown class Elasticsearch\\\\Client\\.$#"
+			count: 1
+			path: src/Monolog/Handler/ElasticsearchHandler.php
+
+		-
+			message: "#^Method Monolog\\\\Handler\\\\ElasticsearchHandler\\:\\:createExceptionFromError\\(\\) should return Throwable but returns Elasticsearch\\\\Common\\\\Exceptions\\\\RuntimeException\\.$#"
+			count: 1
+			path: src/Monolog/Handler/ElasticsearchHandler.php
+
+		-
+			message: "#^Method Monolog\\\\Handler\\\\ElasticsearchHandler\\:\\:createExceptionFromResponses\\(\\) should return Throwable but returns Elasticsearch\\\\Common\\\\Exceptions\\\\RuntimeException\\.$#"
+			count: 1
+			path: src/Monolog/Handler/ElasticsearchHandler.php
+
+		-
+			message: "#^Parameter \\$client of method Monolog\\\\Handler\\\\ElasticsearchHandler\\:\\:__construct\\(\\) has invalid type Elasticsearch\\\\Client\\.$#"
+			count: 2
+			path: src/Monolog/Handler/ElasticsearchHandler.php
+
+		-
+			message: "#^Property Monolog\\\\Handler\\\\ElasticsearchHandler\\:\\:\\$client has unknown class Elasticsearch\\\\Client as its type\\.$#"
 			count: 1
 			path: src/Monolog/Handler/ElasticsearchHandler.php
 

+ 10 - 2
src/Monolog/Handler/ElasticsearchHandler.php

@@ -209,7 +209,11 @@ class ElasticsearchHandler extends AbstractProcessingHandler
             return new ElasticInvalidArgumentException('Elasticsearch failed to index one or more records.');
         }
 
-        return new ElasticsearchRuntimeException('Elasticsearch failed to index one or more records.');
+        if (class_exists(ElasticsearchRuntimeException::class)) {
+            return new ElasticsearchRuntimeException('Elasticsearch failed to index one or more records.');
+        }
+
+        throw new \LogicException('Unsupported elastic search client version');
     }
 
     /**
@@ -225,6 +229,10 @@ class ElasticsearchHandler extends AbstractProcessingHandler
             return new ElasticInvalidArgumentException($error['type'] . ': ' . $error['reason'], 0, $previous);
         }
 
-        return new ElasticsearchRuntimeException($error['type'] . ': ' . $error['reason'], 0, $previous);
+        if (class_exists(ElasticsearchRuntimeException::class)) {
+            return new ElasticsearchRuntimeException($error['type'].': '.$error['reason'], 0, $previous);
+        }
+
+        throw new \LogicException('Unsupported elastic search client version');
     }
 }