Skip to content

Commit

Permalink
Fix problems in Connection
Browse files Browse the repository at this point in the history
  • Loading branch information
szepeviktor committed Feb 4, 2021
1 parent 1f53edb commit 71dba3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
parameters:
phpVersion: 70100
level: 2
paths:
- src/
ignoreErrors:
- '#^Unsafe usage of new static\(\)\.$#'
# PHP 7.1 only
- '#^Caught class JsonException not found\.$#'
- '#^Call to method getCode\(\) on an unknown class JsonException\.$#'
18 changes: 7 additions & 11 deletions src/Elasticsearch/Connections/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function __construct(
* @param Transport $transport
* @return mixed
*/
public function performRequest(string $method, string $uri, ?array $params = [], $body = null, array $options = [], Transport $transport = null)
public function performRequest(string $method, string $uri, array $params = [], $body = null, array $options = [], Transport $transport = null)
{
if ($body !== null) {
$body = $this->serializer->serialize($body);
Expand Down Expand Up @@ -337,9 +337,9 @@ private function wrapHandler(callable $handler): callable
};
}

private function getURI(string $uri, ?array $params): string
private function getURI(string $uri, array $params): string
{
if (isset($params) === true && !empty($params)) {
if ($params !== []) {
array_walk(
$params,
function (&$value, &$key) {
Expand Down Expand Up @@ -461,7 +461,7 @@ public function ping(): bool
]
];
try {
$response = $this->performRequest('HEAD', '/', null, null, $options);
$response = $this->performRequest('HEAD', '/', [], null, $options);
$response = $response->wait();
} catch (TransportException $exception) {
$this->markDead();
Expand Down Expand Up @@ -492,7 +492,7 @@ public function sniff()
]
];

return $this->performRequest('GET', '/_nodes/', null, null, $options);
return $this->performRequest('GET', '/_nodes/', [], null, $options);
}

public function isAlive(): bool
Expand Down Expand Up @@ -609,9 +609,7 @@ private function process4xxError(array $request, array $response, array $ignore)
$statusCode = $response['status'];
$responseBody = $response['body'];

/**
* @var \Exception $exception
*/
/** @var \Exception $exception */
$exception = $this->tryDeserialize400Error($response);

if (array_search($response['status'], $ignore) !== false) {
Expand Down Expand Up @@ -647,9 +645,7 @@ private function process5xxError(array $request, array $response, array $ignore)
$statusCode = (int) $response['status'];
$responseBody = $response['body'];

/**
* @var \Exception $exception
*/
/** @var \Exception $exception */
$exception = $this->tryDeserialize500Error($response);

$exceptionText = "[$statusCode Server Exception] ".$exception->getMessage();
Expand Down

0 comments on commit 71dba3d

Please sign in to comment.