Skip to content

Commit d4a81d4

Browse files
kornrunnerclaude
andcommitted
Fix PSR12 compliance and PHP 8.3+ deprecation warnings
- Add explicit nullable type declarations (?int, ?array) to method parameters - Remove spaces before colons in return type declarations - Add proper spacing around string concatenation operators - Add missing blank lines after opening PHP tags - Add missing newline at end of bootstrap.php All phpcs errors resolved and tests pass without deprecation warnings. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 50b2cef commit d4a81d4

File tree

9 files changed

+41
-35
lines changed

9 files changed

+41
-35
lines changed

src/Client.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ private function http()
5656
return $this->http;
5757
}
5858

59-
private function buildKeyUri(string $key) : string
59+
private function buildKeyUri(string $key): string
6060
{
6161
if (strpos($key, '/') !== 0) {
6262
$key = '/' . $key;
6363
}
6464

6565
$root = $this->root;
6666
if (strlen($root) > 0 && strpos($root, '/') !== 0) {
67-
$root = '/'.$root;
67+
$root = '/' . $root;
6868
}
6969

7070
$uri = '/' . $this->apiversion . '/keys' . $root . $key;
@@ -83,7 +83,7 @@ private function buildKeyUri(string $key) : string
8383
* // the new key is /datingvip/key1
8484
* </code>
8585
*/
86-
public function setRoot(string $root) : ClientInterface
86+
public function setRoot(string $root): ClientInterface
8787
{
8888
if (strpos('/', $root) === false) {
8989
$root = '/' . $root;
@@ -93,7 +93,7 @@ public function setRoot(string $root) : ClientInterface
9393
return $this;
9494
}
9595

96-
public function getNode(string $key, array $flags = null)
96+
public function getNode(string $key, ?array $flags = null)
9797
{
9898
$query = [];
9999
if ($flags) {
@@ -115,7 +115,7 @@ public function getNode(string $key, array $flags = null)
115115
return $response['node'];
116116
}
117117

118-
public function keySet(string $key, string $value, int $ttl = null, array $condition = []) : bool
118+
public function keySet(string $key, string $value, ?int $ttl = null, array $condition = []): bool
119119
{
120120
$data = ['value' => $value];
121121

@@ -131,7 +131,7 @@ public function keySet(string $key, string $value, int $ttl = null, array $condi
131131
return false;
132132
}
133133

134-
public function keyCreate(string $key, string $value, int $ttl = null, array $condition = []) : bool
134+
public function keyCreate(string $key, string $value, ?int $ttl = null, array $condition = []): bool
135135
{
136136
$extra = ['prevExist' => 'false'];
137137

@@ -142,7 +142,7 @@ public function keyCreate(string $key, string $value, int $ttl = null, array $co
142142
return $this->keySet($key, $value, $ttl, $extra);
143143
}
144144

145-
public function keyUpdate(string $key, string $value, int $ttl = null, array $condition = []) : bool
145+
public function keyUpdate(string $key, string $value, ?int $ttl = null, array $condition = []): bool
146146
{
147147
$extra = ['prevExist' => 'true'];
148148

@@ -153,19 +153,19 @@ public function keyUpdate(string $key, string $value, int $ttl = null, array $co
153153
return $this->keySet($key, $value, $ttl, $extra);
154154
}
155155

156-
public function keyGet(string $key, array $flags = null) : string
156+
public function keyGet(string $key, ?array $flags = null): string
157157
{
158158
$node = $this->getNode($key, $flags);
159159

160160
return $node['value'] ?? '';
161161
}
162162

163-
public function keyRemove(string $key) : bool
163+
public function keyRemove(string $key): bool
164164
{
165165
return (bool) $this->http()->delete($this->buildKeyUri($key));
166166
}
167167

168-
public function keyExists(string $key) : bool
168+
public function keyExists(string $key): bool
169169
{
170170
$url = $this->buildKeyUri($key);
171171
$response = json_decode($this->curlExec($this->curl($url), $url), true);
@@ -177,7 +177,7 @@ public function keyExists(string $key) : bool
177177
return false;
178178
}
179179

180-
public function dirCreate(string $key, int $ttl = 0) : bool
180+
public function dirCreate(string $key, int $ttl = 0): bool
181181
{
182182
$data = ['dir' => 'true'];
183183

@@ -188,7 +188,7 @@ public function dirCreate(string $key, int $ttl = 0) : bool
188188
return (bool)$this->http()->put($this->buildKeyUri($key), $data, ['prevExist' => 'false']);
189189
}
190190

191-
public function dirUpdate(string $key, int $ttl = 0) : bool
191+
public function dirUpdate(string $key, int $ttl = 0): bool
192192
{
193193
$data = ['dir' => 'true'];
194194

@@ -199,7 +199,7 @@ public function dirUpdate(string $key, int $ttl = 0) : bool
199199
return (bool) $this->http()->put($this->buildKeyUri($key), $data, ['prevExist' => 'true']);
200200
}
201201

202-
public function dirRemove(string $key, bool $recursive = false) : bool
202+
public function dirRemove(string $key, bool $recursive = false): bool
203203
{
204204
$query = ['dir' => 'true'];
205205

@@ -210,7 +210,7 @@ public function dirRemove(string $key, bool $recursive = false) : bool
210210
return (bool) $this->http()->delete($this->buildKeyUri($key), $query);
211211
}
212212

213-
public function dirExists(string $key) : bool
213+
public function dirExists(string $key): bool
214214
{
215215
$url = $this->buildKeyUri($key);
216216
$response = json_decode($this->curlExec($this->curl($url), $url), true);
@@ -222,7 +222,7 @@ public function dirExists(string $key) : bool
222222
return false;
223223
}
224224

225-
public function dirGet(string $key, bool $recursive = false) : array
225+
public function dirGet(string $key, bool $recursive = false): array
226226
{
227227
$query = [];
228228
if ($recursive) {
@@ -232,7 +232,7 @@ public function dirGet(string $key, bool $recursive = false) : array
232232
return $this->http()->get($this->buildKeyUri($key), $query);
233233
}
234234

235-
public function dirList(string $key, bool $recursive = false) : array
235+
public function dirList(string $key, bool $recursive = false): array
236236
{
237237
try {
238238
$data = $this->dirGet($key, $recursive);
@@ -243,7 +243,7 @@ public function dirList(string $key, bool $recursive = false) : array
243243
return $this->traversalDir((new RecursiveArrayIterator($data)));
244244
}
245245

246-
private function traversalDir(RecursiveArrayIterator $iterator) : array
246+
private function traversalDir(RecursiveArrayIterator $iterator): array
247247
{
248248
$key = '';
249249
while ($iterator->valid()) {

src/ClientInterface.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44

55
interface ClientInterface
66
{
7-
public function keySet(string $key, string $value, int $ttl = null, array $condition = []) ;
7+
public function keySet(string $key, string $value, ?int $ttl = null, array $condition = []);
88

9-
public function keyCreate(string $key, string $value, int $ttl = null, array $condition = []) : bool;
9+
public function keyCreate(string $key, string $value, ?int $ttl = null, array $condition = []): bool;
1010

11-
public function keyUpdate(string $key, string $value, int $ttl = null, array $condition = []) : bool;
11+
public function keyUpdate(string $key, string $value, ?int $ttl = null, array $condition = []): bool;
1212

13-
public function keyGet(string $key, array $flags = null) : string;
13+
public function keyGet(string $key, ?array $flags = null): string;
1414

15-
public function keyRemove(string $key) : bool;
15+
public function keyRemove(string $key): bool;
1616

17-
public function keyExists(string $key) : bool;
17+
public function keyExists(string $key): bool;
1818

19-
public function dirCreate(string $key, int $ttl = 0) : bool;
19+
public function dirCreate(string $key, int $ttl = 0): bool;
2020

21-
public function dirUpdate(string $key, int $ttl = 0) : bool;
21+
public function dirUpdate(string $key, int $ttl = 0): bool;
2222

23-
public function dirRemove(string $key, bool $recursive = false) : bool;
23+
public function dirRemove(string $key, bool $recursive = false): bool;
2424

25-
public function dirExists(string $key) : bool;
25+
public function dirExists(string $key): bool;
2626

27-
public function dirGet(string $key, bool $recursive = false) : array;
27+
public function dirGet(string $key, bool $recursive = false): array;
2828

29-
public function dirList(string $key, bool $recursive = false) : array;
29+
public function dirList(string $key, bool $recursive = false): array;
3030
}

src/Exception/EtcdException.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace DatingVIP\Component\Etcd\Exception;
34

45
use Exception;

src/Exception/KeyExistsException.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace DatingVIP\Component\Etcd\Exception;
34

45
class KeyExistsException extends EtcdException

src/Exception/KeyNotFoundException.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace DatingVIP\Component\Etcd\Exception;
34

45
class KeyNotFoundException extends EtcdException

src/Http/Curl.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace DatingVIP\Component\Etcd\Http;
34

45
use DatingVIP\Component\Etcd\HttpInterface;
@@ -14,13 +15,13 @@ class Curl implements HttpInterface
1415

1516
private $custom_ca_file = '';
1617

17-
public function verifySslPeer(bool $flag = true, string $ca_file = '') : void
18+
public function verifySslPeer(bool $flag = true, string $ca_file = ''): void
1819
{
1920
$this->verify_ssl_peer = $flag;
2021
$this->custom_ca_file = $ca_file;
2122
}
2223

23-
public function get(string $url, array $query_arguments = []) : array
24+
public function get(string $url, array $query_arguments = []): array
2425
{
2526
if (!empty($query_arguments)) {
2627
$url .= '?' . http_build_query($query_arguments);
@@ -29,7 +30,7 @@ public function get(string $url, array $query_arguments = []) : array
2930
return $this->execute($this->curl($url), $url);
3031
}
3132

32-
public function post(string $url, array $payload = [], array $query_arguments = []) : array
33+
public function post(string $url, array $payload = [], array $query_arguments = []): array
3334
{
3435
if (!empty($query_arguments)) {
3536
$url .= '?' . http_build_query($query_arguments);

src/HttpInterface.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
2+
23
namespace DatingVIP\Component\Etcd;
34

45
interface HttpInterface
56
{
6-
public function get(string $url, array $query_arguments = []) : array;
7-
public function post(string $url, array $payload = [], array $query_arguments = []) : array;
7+
public function get(string $url, array $query_arguments = []): array;
8+
public function post(string $url, array $payload = [], array $query_arguments = []): array;
89
public function put(string $url, array $payload = [], array $query_arguments = []);
910
public function delete(string $url, array $query_arguments = []);
1011
}

tests/DatingVIP/Tests/Component/Etcd/ClientTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace DatingVIP\Tests\Component\Etcd;

tests/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?php
22

33
error_reporting(E_ALL | E_STRICT);
4-
require dirname(__DIR__) . '/vendor/autoload.php';
4+
require dirname(__DIR__) . '/vendor/autoload.php';

0 commit comments

Comments
 (0)