Skip to content

Commit c5a6f9a

Browse files
committed
Fix PHPStan issues
1 parent 5491764 commit c5a6f9a

File tree

11 files changed

+27
-19
lines changed

11 files changed

+27
-19
lines changed

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ matrix:
1414
- php: 7.2
1515
env:
1616
- DEPENDENCIES=""
17-
- TEST_COVERAGE=true
17+
- EXECUTE_CS_CHECK=true
1818
- ARANGODB_VERSION=3.4.10
1919
- php: 7.3
2020
env:
2121
- DEPENDENCIES=""
22+
- EXECUTE_PHPSTAN=true
2223
- ARANGODB_VERSION=3.5.5
2324
- php: 7.4
2425
env:
2526
- DEPENDENCIES=""
27+
- TEST_COVERAGE=true
2628
- ARANGODB_VERSION=3.6.4
2729
- php: nightly
2830
env:
@@ -49,7 +51,7 @@ before_script:
4951
- ./test/.travis/setup_arangodb.sh
5052

5153
script:
52-
- if [[ $PHPSTAN_CHECK == 'true' ]]; then ./vendor/bin/phpstan analyze -l max -c ./phpstan.installer.neon ./src; fi
54+
- if [[ $EXECUTE_PHPSTAN == 'true' ]]; then ./vendor/bin/phpstan analyze -l max -c ./phpstan.installer.neon ./src; fi
5355
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/phpcs; fi
5456
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/docheader check src/ tests/; fi
5557
- if [[ $TEST_COVERAGE == 'true' ]]; then php -dzend_extension=xdebug.so ./vendor/bin/phpunit --coverage-text --coverage-clover ./build/logs/clover.xml; fi

phpcs.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@
2323

2424
<!-- Paths to check -->
2525
<file>src</file>
26+
<file>example</file>
2627
</ruleset>

phpstan.installer.neon

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ parameters:
66
- php
77
- dist
88
reportUnmatchedIgnoredErrors: true
9+
checkMissingIterableValueType: false
910
ignoreErrors:
10-
- '#and array|string|null results in an error#'
11+
- '#Only booleans are allowed in &&, string\|null given on the right side#'

src/Handler/Collection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function create(string $collectionName, array $options = []): string
4646

4747
$data = Json::decode($response->getBody()->getContents());
4848

49-
if (!isset($data['id'])) {
49+
if (! isset($data['id'])) {
5050
throw UnexpectedResponse::forType($type, $response);
5151
}
5252

@@ -84,7 +84,7 @@ public function count(string $collectionName): int
8484

8585
$data = Json::decode($response->getBody()->getContents());
8686

87-
if (!isset($data['count'])) {
87+
if (! isset($data['count'])) {
8888
throw UnexpectedResponse::forType($type, $response);
8989
}
9090

src/Handler/Document.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function save(string $collectionName, array $doc, int $flags = 0): string
4646

4747
$data = Json::decode($response->getBody()->getContents());
4848

49-
if (!isset($data['_id'])) {
49+
if (! isset($data['_id'])) {
5050
throw UnexpectedResponse::forType($type, $response);
5151
}
5252

@@ -96,5 +96,4 @@ public function hasById(string $collectionName, string $id): bool
9696
{
9797
return $this->has($collectionName . self::ID_SEPARATOR . $id);
9898
}
99-
10099
}

src/Http/BatchResult.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@
1414
use ArangoDb\Exception\InvalidArgumentException;
1515
use ArangoDb\Exception\LogicException;
1616
use ArangoDb\Guard\Guard;
17-
use ArangoDb\Http\HttpHelper;
1817
use ArangoDb\Type\BatchType;
1918
use Countable;
2019
use Iterator;
2120
use Psr\Http\Message\ResponseFactoryInterface;
2221
use Psr\Http\Message\ResponseInterface;
2322
use Psr\Http\Message\StreamFactoryInterface;
2423

24+
/**
25+
* @implements Iterator<string, ResponseInterface>
26+
*/
2527
final class BatchResult implements Countable, Iterator
2628
{
2729
/**
@@ -128,17 +130,14 @@ public function next(): void
128130
next($this->responses);
129131
}
130132

131-
/**
132-
* @return int|string|null
133-
*/
134133
public function key()
135134
{
136-
return key($this->responses);
135+
return key($this->responses); // @phpstan-ignore-line
137136
}
138137

139138
public function valid(): bool
140139
{
141-
return $this->key() !== null;
140+
return $this->key() !== null; // @phpstan-ignore-line
142141
}
143142

144143
public function rewind(): void

src/Http/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ private function updateCommonHttpHeaders(): void
300300
*/
301301
private function open(RequestInterface $request): void
302302
{
303-
if ($this->useKeepAlive && $this->handle !== null && is_resource($this->handle)) {
303+
if ($this->useKeepAlive && $this->handle !== null && is_resource($this->handle)) { // @phpstan-ignore-line
304304
if (! feof($this->handle)) {
305305
return;
306306
}

src/Http/ClientOptions.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010
namespace ArangoDb\Http;
1111

1212
use ArangoDb\Exception\LogicException;
13+
use ArrayAccess;
1314

1415
/**
1516
* Immutable client options array container
17+
*
18+
* @implements ArrayAccess<string, mixed>
1619
*/
17-
final class ClientOptions implements \ArrayAccess
20+
final class ClientOptions implements ArrayAccess
1821
{
1922
// connection options
2023
public const OPTION_ENDPOINT = 'endpoint';

src/Http/TransactionalClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function send(array $params = [], bool $waitForSync = false): ResponseInt
112112
);
113113

114114
if (0 !== count($guards)) {
115-
\array_walk($guards, static function ($guard) use ($response) {
115+
\array_walk($guards, static function ($guard) use ($response): void {
116116
$guard($response);
117117
});
118118
}

src/Statement/Statement.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111

1212
use ArangoDb\Exception\ServerException;
1313
use ArangoDb\Http\Url;
14-
use ArangoDb\Statement\QueryResult;
15-
use ArangoDb\Statement\StreamHandler;
16-
use ArangoDb\Statement\StreamHandlerFactoryInterface;
1714
use Countable;
1815
use Fig\Http\Message\RequestMethodInterface;
1916
use Fig\Http\Message\StatusCodeInterface;
@@ -23,6 +20,9 @@
2320
use Psr\Http\Message\RequestFactoryInterface;
2421
use Psr\Http\Message\RequestInterface;
2522

23+
/**
24+
* @implements Iterator<int, mixed>
25+
*/
2626
final class Statement implements QueryResult, Iterator, Countable
2727
{
2828
/**

0 commit comments

Comments
 (0)