Skip to content

Commit 659675c

Browse files
Ensure PHP 8.2 compatibility (#14)
* Ensure PHP 8.2 compatibility Improved code quality * Fix styling * Ensure PHP 8.2 compatibility Improved code quality * Style fixes Co-authored-by: LaravelFreelancerNL <LaravelFreelancerNL@users.noreply.github.com>
1 parent 09b52e1 commit 659675c

23 files changed

+58
-250
lines changed

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
matrix:
1414
os: [ubuntu-latest]
1515
arangodb: [3.8, 3.9]
16-
php: ["8.0", "8.1"]
16+
php: [8.0, 8.1, 8.2]
1717
stability: [prefer-stable]
1818

1919
name: P${{ matrix.php }} - A${{ matrix.arangodb }} - ${{ matrix.stability }}

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@
2424
"spatie/data-transfer-object": "^3.1"
2525
},
2626
"require-dev": {
27-
"phpunit/phpunit": "^9.5",
28-
"phpstan/phpstan": "^1.0",
29-
"phpmd/phpmd": "^2.9",
27+
"laravel/pint": "^1.2.1",
3028
"mockery/mockery": "^1.4",
29+
"phpmd/phpmd": "^2.9",
30+
"phpstan/phpstan": "^1.0",
31+
"phpunit/phpunit": "^9.5",
32+
"rector/rector": "^0.14.8",
3133
"scrutinizer/ocular": "^1.8",
32-
"sebastian/phpcpd": "^6.0",
33-
"laravel/pint": "^0.1.7"
34+
"sebastian/phpcpd": "^6.0"
3435
},
3536
"autoload": {
3637
"psr-4": {

pint.json

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

rector.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Set\ValueObject\LevelSetList;
7+
use Rector\Set\ValueObject\SetList;
8+
9+
return static function (RectorConfig $rectorConfig): void {
10+
$rectorConfig->paths([
11+
__DIR__.'/src',
12+
__DIR__.'/tests',
13+
]);
14+
15+
// define sets of rules
16+
$rectorConfig->sets([
17+
SetList::CODE_QUALITY,
18+
LevelSetList::UP_TO_PHP_80,
19+
]);
20+
21+
// Path to PHPStan with extensions, that PHPStan in Rector uses to determine types
22+
$rectorConfig->phpstanConfig(__DIR__.'/phpstan.neon.dist');
23+
};

src/Admin/AdminManager.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,13 @@
1111

1212
class AdminManager extends Manager
1313
{
14-
protected ArangoClient $arangoClient;
15-
16-
public function __construct(ArangoClient $arangoClient)
14+
public function __construct(protected ArangoClient $arangoClient)
1715
{
18-
$this->arangoClient = $arangoClient;
1916
}
2017

2118
/**
2219
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
2320
*
24-
* @param bool $details
25-
* @return stdClass
26-
*
2721
* @throws ArangoException
2822
*/
2923
public function getVersion(bool $details = false): stdClass
@@ -48,6 +42,6 @@ public function getRunningTransactions(): array
4842
{
4943
$result = $this->arangoClient->request('get', '/_api/transaction');
5044

51-
return (isset($result->transactions)) ? (array) $result->transactions : [];
45+
return (property_exists($result, 'transactions') && $result->transactions !== null) ? (array) $result->transactions : [];
5246
}
5347
}

src/ArangoClient.php

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public function __construct(array $config = [], GuzzleClient $httpClient = null)
5151

5252
/**
5353
* @param array<mixed> $config
54-
* @return string
5554
*/
5655
public function generateEndpoint(array $config): string
5756
{
@@ -70,17 +69,11 @@ public function generateEndpoint(array $config): string
7069
}
7170

7271
/**
73-
* @psalm-suppress MixedReturnStatement
74-
*
75-
* @param string $method
76-
* @param string $uri
7772
* @param array<mixed>|HttpRequestOptions $options
78-
* @param string|null $database
79-
* @return stdClass
8073
*
8174
* @throws ArangoException
8275
*/
83-
public function request(string $method, string $uri, $options = [], ?string $database = null): stdClass
76+
public function request(string $method, string $uri, array|HttpRequestOptions $options = [], ?string $database = null): stdClass
8477
{
8578
$uri = $this->prependDatabaseToUri($uri, $database);
8679

@@ -100,7 +93,6 @@ public function request(string $method, string $uri, $options = [], ?string $dat
10093

10194
/**
10295
* @param array<mixed> $options
103-
* @return HttpRequestOptions
10496
*
10597
* @throws ArangoException
10698
*/
@@ -116,11 +108,7 @@ protected function prepareRequestOptions(array $options): HttpRequestOptions
116108
/**
117109
* Return the response with debug information (for internal testing purposes).
118110
*
119-
* @param string $method
120-
* @param string $uri
121111
* @param array<mixed> $options
122-
* @param string|null $database
123-
* @return ResponseInterface
124112
*
125113
* @throws GuzzleException
126114
*/
@@ -146,8 +134,6 @@ protected function prependDatabaseToUri(string $uri, ?string $database = null):
146134
}
147135

148136
/**
149-
* @param Throwable $e
150-
*
151137
* @throws ArangoException
152138
*/
153139
protected function handleGuzzleException(Throwable $e): void
@@ -170,11 +156,7 @@ protected function handleGuzzleException(Throwable $e): void
170156
}
171157

172158
/**
173-
* @psalm-suppress MixedAssignment, MixedArrayOffset
174159
* @SuppressWarnings(PHPMD.StaticAccess)
175-
*
176-
* @param ResponseInterface|null $response
177-
* @return stdClass
178160
*/
179161
protected function cleanupResponse(?ResponseInterface $response): stdClass
180162
{
@@ -186,7 +168,6 @@ protected function cleanupResponse(?ResponseInterface $response): stdClass
186168
}
187169

188170
/**
189-
* @param string $query
190171
* @param array<scalar> $bindVars
191172
* @param array<mixed> $options
192173
* @return Statement
@@ -207,18 +188,11 @@ public function getConfig(): array
207188
return $this->config->toArray();
208189
}
209190

210-
/**
211-
* @param string $name
212-
* @return void
213-
*/
214191
public function setDatabase(string $name): void
215192
{
216193
$this->config->database = $name;
217194
}
218195

219-
/**
220-
* @return string
221-
*/
222196
public function getDatabase(): string
223197
{
224198
return $this->config->database;

src/HandlesJson.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
trait HandlesJson
1515
{
1616
/**
17-
* @param mixed $data
18-
* @return string
19-
*
2017
* @throws ArangoException
2118
*/
2219
public function jsonEncode(mixed $data): string
@@ -36,11 +33,7 @@ public function jsonEncode(mixed $data): string
3633
}
3734

3835
/**
39-
* @psalm-suppress MixedAssignment, MixedArrayOffset
4036
* @SuppressWarnings(PHPMD.StaticAccess)
41-
*
42-
* @param ResponseInterface|null $response
43-
* @return stdClass
4437
*/
4538
protected function decodeResponse(?ResponseInterface $response): stdClass
4639
{

src/HasManagers.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ trait HasManagers
1515

1616
public function admin(): AdminManager
1717
{
18-
if (! isset($this->adminManager)) {
18+
if (! (property_exists($this, 'adminManager') && $this->adminManager !== null)) {
1919
$this->adminManager = new AdminManager($this);
2020
}
2121

@@ -24,7 +24,7 @@ public function admin(): AdminManager
2424

2525
public function schema(): SchemaManager
2626
{
27-
if (! isset($this->schemaManager)) {
27+
if (! (property_exists($this, 'schemaManager') && $this->schemaManager !== null)) {
2828
$this->schemaManager = new SchemaManager($this);
2929
}
3030

src/Http/HttpClientConfig.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,11 @@ class HttpClientConfig extends DataTransferObject
4242
*/
4343
public function mapGuzzleHttpClientConfig(): array
4444
{
45-
$config = [];
46-
$config['base_uri'] = $this->endpoint;
47-
$config['version'] = $this->version;
48-
$config['allow_redirects'] = $this->allow_redirects;
49-
$config['connect_timeout'] = $this->connect_timeout;
50-
51-
$config['auth'] = [
45+
return ['base_uri' => $this->endpoint, 'version' => $this->version, 'allow_redirects' => $this->allow_redirects, 'connect_timeout' => $this->connect_timeout, 'auth' => [
5246
$this->username,
5347
$this->password,
54-
];
55-
$config['headers'] = [
48+
], 'headers' => [
5649
'Connection' => $this->connection,
57-
];
58-
59-
return $config;
50+
]];
6051
}
6152
}

src/Schema/ManagesCollections.php

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ trait ManagesCollections
1818
/**
1919
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
2020
*
21-
* @param bool $excludeSystemCollections
2221
* @return array<mixed>
2322
*
2423
* @throws ArangoException
@@ -41,16 +40,14 @@ public function getCollections(bool $excludeSystemCollections = false): array
4140
/**
4241
* Check for collection existence in current DB.
4342
*
44-
* @param string $name
45-
* @return bool
4643
*
4744
* @throws ArangoException
4845
*/
4946
public function hasCollection(string $name): bool
5047
{
5148
$results = $this->getCollections();
5249

53-
return array_search($name, array_column($results, 'name'), true) !== false;
50+
return in_array($name, array_column($results, 'name'), true);
5451
}
5552

5653
/**
@@ -68,9 +65,6 @@ public function getCollection(string $name): stdClass
6865
/**
6966
* @see https://www.arangodb.com/docs/stable/http/collection-getting.html#read-properties-of-a-collection
7067
*
71-
* @param string $name
72-
* @return stdClass
73-
*
7468
* @throws ArangoException
7569
*/
7670
public function getCollectionProperties(string $name): stdClass
@@ -83,9 +77,6 @@ public function getCollectionProperties(string $name): stdClass
8377
/**
8478
* @see https://www.arangodb.com/docs/stable/http/collection-getting.html#return-number-of-documents-in-a-collection
8579
*
86-
* @param string $name
87-
* @return stdClass
88-
*
8980
* @throws ArangoException
9081
*/
9182
public function getCollectionWithDocumentCount(string $name): stdClass
@@ -98,9 +89,6 @@ public function getCollectionWithDocumentCount(string $name): stdClass
9889
/**
9990
* @see https://www.arangodb.com/docs/stable/http/collection-getting.html#return-number-of-documents-in-a-collection
10091
*
101-
* @param string $name
102-
* @return int
103-
*
10492
* @throws ArangoException
10593
*/
10694
public function getCollectionDocumentCount(string $name): int
@@ -115,10 +103,6 @@ public function getCollectionDocumentCount(string $name): int
115103
*
116104
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
117105
*
118-
* @param string $name
119-
* @param bool $details
120-
* @return stdClass
121-
*
122106
* @throws ArangoException
123107
*/
124108
public function getCollectionStatistics(string $name, bool $details = false): stdClass
@@ -137,11 +121,9 @@ public function getCollectionStatistics(string $name, bool $details = false): st
137121
}
138122

139123
/**
140-
* @param string $name
141124
* @param array<mixed> $config
142125
* @param int|bool|null $waitForSyncReplication
143126
* @param int|bool|null $enforceReplicationFactor
144-
* @return stdClass
145127
*
146128
* @throws ArangoException
147129
*/
@@ -166,11 +148,9 @@ public function createCollection(
166148
}
167149

168150
/**
169-
* @param string $name
170151
* @param array<mixed> $config
171152
* @param int|bool|null $waitForSyncReplication
172153
* @param int|bool|null $enforceReplicationFactor
173-
* @return stdClass
174154
*
175155
* @throws ArangoException
176156
*/
@@ -186,9 +166,7 @@ public function createEdgeCollection(
186166
}
187167

188168
/**
189-
* @param string $name
190169
* @param array<mixed> $config
191-
* @return stdClass
192170
*
193171
* @throws ArangoException
194172
*/
@@ -202,10 +180,6 @@ public function updateCollection(string $name, array $config = []): stdClass
202180
}
203181

204182
/**
205-
* @param string $old
206-
* @param string $new
207-
* @return stdClass
208-
*
209183
* @throws ArangoException
210184
*/
211185
public function renameCollection(string $old, string $new): stdClass
@@ -222,9 +196,6 @@ public function renameCollection(string $old, string $new): stdClass
222196
}
223197

224198
/**
225-
* @param string $name
226-
* @return stdClass
227-
*
228199
* @throws ArangoException
229200
*/
230201
public function truncateCollection(string $name): stdClass
@@ -235,9 +206,6 @@ public function truncateCollection(string $name): stdClass
235206
}
236207

237208
/**
238-
* @param string $name
239-
* @return bool
240-
*
241209
* @throws ArangoException
242210
*/
243211
public function deleteCollection(string $name): bool

0 commit comments

Comments
 (0)