Skip to content

Commit efbe7aa

Browse files
committed
Fixed PHPStan + bulk endpoint template generator
1 parent 3fce068 commit efbe7aa

File tree

15 files changed

+24
-55
lines changed

15 files changed

+24
-55
lines changed

phpstan-src.neon

Lines changed: 0 additions & 6 deletions
This file was deleted.

phpstan-tests.neon

Lines changed: 0 additions & 14 deletions
This file was deleted.

phpstan.neon

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
parameters:
2+
reportUnmatchedIgnoredErrors:
3+
false
4+
ignoreErrors:
5+
- '#Unsafe usage of new static\(\)#'
6+
- '#Call to static method performRequest\(\) on trait#'
7+
- '#Constant JSON_THROW_ON_ERROR not found#'
8+
- '#Caught class JsonException not found#'
9+
- '#Call to method getCode\(\) on an unknown class JsonException#'

src/Elasticsearch/Connections/Connection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function __construct(
171171
*/
172172
public function performRequest($method, $uri, $params = null, $body = null, $options = [], Transport $transport = null)
173173
{
174-
if (isset($body) === true) {
174+
if ($body !== null) {
175175
$body = $this->serializer->serialize($body);
176176
}
177177

@@ -333,7 +333,7 @@ private function wrapHandler(callable $handler)
333333
*
334334
* @return string
335335
*/
336-
private function getURI($uri, $params)
336+
private function getURI(string $uri, ?array $params)
337337
{
338338
if (isset($params) === true && !empty($params)) {
339339
array_walk($params, function (&$value, &$key) {
@@ -588,7 +588,7 @@ protected function getCurlRetryException($request, $response)
588588
*
589589
* @return string
590590
*/
591-
private function buildCurlCommand($method, $uri, $body)
591+
private function buildCurlCommand(string $method, string $uri, ?string $body): string
592592
{
593593
if (strpos($uri, '?') === false) {
594594
$uri .= '?pretty=true';

src/Elasticsearch/Endpoints/AbstractEndpoint.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,9 @@ private function getOptionalType()
237237
*
238238
* @throws \Elasticsearch\Common\Exceptions\UnexpectedValueException
239239
*/
240-
private function checkUserParams($params)
240+
private function checkUserParams(array $params)
241241
{
242-
if (isset($params) !== true) {
242+
if (empty($params)) {
243243
return; //no params, just return.
244244
}
245245

src/Elasticsearch/Endpoints/Bulk.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
use Elasticsearch\Common\Exceptions\InvalidArgumentException;
2020
use Elasticsearch\Endpoints\AbstractEndpoint;
21+
use Elasticsearch\Endpoints\BulkEndpointInterface;
2122
use Elasticsearch\Serializers\SerializerInterface;
2223
use Traversable;
2324

@@ -71,9 +72,6 @@ public function getMethod(): string
7172
return 'POST';
7273
}
7374

74-
/**
75-
* @param string|array|Traversable $body
76-
*/
7775
public function setBody($body): Bulk
7876
{
7977
if (isset($body) !== true) {

src/Elasticsearch/Endpoints/Ml/FindFileStructure.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
use Elasticsearch\Common\Exceptions\InvalidArgumentException;
2020
use Elasticsearch\Endpoints\AbstractEndpoint;
21+
use Elasticsearch\Endpoints\BulkEndpointInterface;
2122
use Elasticsearch\Serializers\SerializerInterface;
2223
use Traversable;
2324

@@ -66,9 +67,6 @@ public function getMethod(): string
6667
return 'POST';
6768
}
6869

69-
/**
70-
* @param string|array|Traversable $body
71-
*/
7270
public function setBody($body): FindFileStructure
7371
{
7472
if (isset($body) !== true) {

src/Elasticsearch/Endpoints/Ml/PostData.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Elasticsearch\Common\Exceptions\RuntimeException;
2020
use Elasticsearch\Common\Exceptions\InvalidArgumentException;
2121
use Elasticsearch\Endpoints\AbstractEndpoint;
22+
use Elasticsearch\Endpoints\BulkEndpointInterface;
2223
use Elasticsearch\Serializers\SerializerInterface;
2324
use Traversable;
2425

@@ -63,9 +64,6 @@ public function getMethod(): string
6364
return 'POST';
6465
}
6566

66-
/**
67-
* @param string|array|Traversable $body
68-
*/
6967
public function setBody($body): PostData
7068
{
7169
if (isset($body) !== true) {

src/Elasticsearch/Endpoints/Monitoring/Bulk.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
use Elasticsearch\Common\Exceptions\InvalidArgumentException;
2020
use Elasticsearch\Endpoints\AbstractEndpoint;
21+
use Elasticsearch\Endpoints\BulkEndpointInterface;
2122
use Elasticsearch\Serializers\SerializerInterface;
2223
use Traversable;
2324

@@ -60,9 +61,6 @@ public function getMethod(): string
6061
return 'POST';
6162
}
6263

63-
/**
64-
* @param string|array|Traversable $body
65-
*/
6664
public function setBody($body): Bulk
6765
{
6866
if (isset($body) !== true) {

src/Elasticsearch/Endpoints/Msearch.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
use Elasticsearch\Common\Exceptions\InvalidArgumentException;
2020
use Elasticsearch\Endpoints\AbstractEndpoint;
21+
use Elasticsearch\Endpoints\BulkEndpointInterface;
2122
use Elasticsearch\Serializers\SerializerInterface;
2223
use Traversable;
2324

@@ -67,9 +68,6 @@ public function getMethod(): string
6768
return isset($this->body) ? 'POST' : 'GET';
6869
}
6970

70-
/**
71-
* @param string|array|Traversable $body
72-
*/
7371
public function setBody($body): Msearch
7472
{
7573
if (isset($body) !== true) {

0 commit comments

Comments
 (0)