Skip to content

Commit d13229f

Browse files
authored
Merge pull request #65 from MacFJA/php8-deprecated
Fix deprecation warning with PHP 8.1+
2 parents 837bf52 + be24590 commit d13229f

File tree

13 files changed

+36
-76
lines changed

13 files changed

+36
-76
lines changed

src/Query/Builder/QueryElementDecorator.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,4 @@
2121

2222
namespace MacFJA\RediSearch\Query\Builder;
2323

24-
interface QueryElementDecorator extends QueryElement
25-
{
26-
}
24+
interface QueryElementDecorator extends QueryElement {}

src/Query/Builder/QueryElementVector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
class QueryElementVector implements QueryElementDecorator
3434
{
3535
private const PARAMETERS = [
36-
'EF_RUNTIME' => 'int',
36+
'EF_RUNTIME' => 'integer',
3737
];
3838

3939
/** @var QueryElement */

src/Redis/Client/PhpredisClient.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public function executeRaw(...$args)
8585
if (count($args) < 1) {
8686
return null;
8787
}
88+
8889
// @phpstan-ignore-next-line
8990
return $this->redis->rawCommand(...$args);
9091
}

src/Redis/Command/AggregateCommand/LimitOption.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,4 @@
2121

2222
namespace MacFJA\RediSearch\Redis\Command\AggregateCommand;
2323

24-
class LimitOption extends \MacFJA\RediSearch\Redis\Command\SearchCommand\LimitOption
25-
{
26-
}
24+
class LimitOption extends \MacFJA\RediSearch\Redis\Command\SearchCommand\LimitOption {}

src/Redis/Command/CreateCommand/VectorFieldOption.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ public function addAttribute(string $type, int $dimension, string $distanceMetri
121121
+ (is_int($blockSize) ? 2 : 0)
122122
+ (is_int($maxEdge) ? 2 : 0)
123123
+ (is_int($efConstruction) ? 2 : 0)
124-
+ (is_int($efRuntime) ? 2 : 0)
125-
;
124+
+ (is_int($efRuntime) ? 2 : 0);
126125

127126
/** @var int $count */
128127
$count = $this->getDataOfOption('count') ?? 0;

src/Redis/Command/Option/DecoratedOptionTrait.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public function getVersionConstraint(): string
6161
return $this->decorated->getVersionConstraint();
6262
}
6363

64+
/**
65+
* @return array<float|int|string>
66+
*/
6467
public function render(?string $version = null): array
6568
{
6669
return $this->decorated->render($version);

src/Redis/Command/Search.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,7 @@ public function parseResponse($data)
360360
+ (true === $useScores ? 1 : 0)
361361
+ (true === $usePayloads ? 1 : 0)
362362
+ (true === $useSortKeys ? 1 : 0)
363-
- (true === $noContent ? 1 : 0)
364-
;
363+
- (true === $noContent ? 1 : 0);
365364

366365
$documents = array_chunk($data, $chunkSize);
367366

src/Redis/Response.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,4 @@
2121

2222
namespace MacFJA\RediSearch\Redis;
2323

24-
interface Response
25-
{
26-
}
24+
interface Response {}

src/Redis/Response/AggregateResponseItem.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public function getValue(string $fieldName, $default = null)
6565
__METHOD__,
6666
__CLASS__
6767
), E_USER_DEPRECATED);
68+
6869
// @phpstan-ignore-next-line
6970
return $this->getFieldValue($fieldName, $default);
7071
}

src/Redis/Response/PaginatedResponse.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function __construct(PaginatedCommand $command, int $totalCount, array $i
6666
/**
6767
* @return array<ResponseItem>
6868
*/
69-
public function current()
69+
public function current(): array
7070
{
7171
if ($this->requestedOffset === ($this->lastCommand->getOffset() ?? 0) && ($this->requestedSize === $this->getPageSize())) {
7272
$this->requestedOffset = null;
@@ -101,7 +101,7 @@ public function getPageCount(): int
101101
return (int) ceil($this->totalCount / $this->getPageSize());
102102
}
103103

104-
public function key()
104+
public function key(): int
105105
{
106106
if (0 === $this->getPageSize()) {
107107
return 0;
@@ -110,7 +110,7 @@ public function key()
110110
return (int) floor(($this->lastCommand->getOffset() ?? $this->requestedOffset ?? 0) / $this->getPageSize());
111111
}
112112

113-
public function valid()
113+
public function valid(): bool
114114
{
115115
return (
116116
null === $this->requestedOffset
@@ -133,7 +133,7 @@ public function getTotalCount(): int
133133
return $this->totalCount;
134134
}
135135

136-
public function count()
136+
public function count(): int
137137
{
138138
return $this->getPageCount();
139139
}

tests/Query/BuilderTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,7 @@ public function testDocExample3(): void
384384
$expected = 'hello|world';
385385
$builder = new Builder();
386386

387-
$builder->addElement(Builder\OrGroup::fromStrings('hello', 'world'))
388-
;
387+
$builder->addElement(Builder\OrGroup::fromStrings('hello', 'world'));
389388

390389
static::assertSame($expected, $builder->render());
391390
}

tests/Redis/Command/Option/GroupedOptionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function testGetOptionsName(): void
107107
public function testSetUnknownOptionData(): void
108108
{
109109
$this->expectException(OutOfRangeException::class);
110-
$this->expectErrorMessage('There is no option for foobar');
110+
$this->expectExceptionMessage('There is no option for foobar');
111111

112112
$option = new GroupedOption([], []);
113113
$option->setDataOfOption('foobar', 'bar');
@@ -116,7 +116,7 @@ public function testSetUnknownOptionData(): void
116116
public function testSetLockOptionData(): void
117117
{
118118
$this->expectException(BadMethodCallException::class);
119-
$this->expectErrorMessage('The option lock can\'t be modified');
119+
$this->expectExceptionMessage('The option lock can\'t be modified');
120120

121121
$option = new GroupedOption(['lock' => new NamelessOption('foo')], [], ['lock']);
122122
$option->setDataOfOption('lock', 'bar');

tests/psalm/stubs/phpiredis.php

Lines changed: 18 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -30,130 +30,94 @@
3030
const PHPIREDIS_REPLY_STATUS = 5;
3131
const PHPIREDIS_REPLY_ERROR = 6;
3232

33-
function phpiredis_connect($host, $port = 6379): void
34-
{
35-
}
36-
function phpiredis_pconnect($host, $port = 6379): void
37-
{
38-
}
39-
function phpiredis_disconnect(): void
40-
{
41-
}
33+
function phpiredis_connect($host, $port = 6379): void {}
34+
function phpiredis_pconnect($host, $port = 6379): void {}
35+
function phpiredis_disconnect(): void {}
4236

4337
/**
4438
* @param resource $redis
4539
* @param string[] $command
4640
*
4741
* @return bool|string
4842
*/
49-
function phpiredis_command_bs($redis, array $command)
50-
{
51-
}
43+
function phpiredis_command_bs($redis, array $command) {}
5244

5345
/**
5446
* @param resource $redis
5547
*
5648
* @return bool|string
5749
*/
58-
function phpiredis_command($redis, string $command)
59-
{
60-
}
50+
function phpiredis_command($redis, string $command) {}
6151

6252
/**
6353
* @param resource $redis
6454
* @param array<string> $commands
6555
*
6656
* @return array<bool|string>
6757
*/
68-
function phpiredis_multi_command($redis, array $commands)
69-
{
70-
}
58+
function phpiredis_multi_command($redis, array $commands) {}
7159

7260
/**
7361
* @param resource $redis
7462
* @param array<array<string>> $commands
7563
*
7664
* @return array<bool|string>
7765
*/
78-
function phpiredis_multi_command_bs($redis, array $commands)
79-
{
80-
}
66+
function phpiredis_multi_command_bs($redis, array $commands) {}
8167

8268
/**
8369
* @param array<float|int|string> $args
8470
*/
85-
function phpiredis_format_command(array $args): string
86-
{
87-
}
71+
function phpiredis_format_command(array $args): string {}
8872

8973
/**
9074
* @return resource
9175
*/
92-
function phpiredis_reader_create()
93-
{
94-
}
76+
function phpiredis_reader_create() {}
9577

9678
/**
9779
* @param resource $reader
9880
*/
99-
function phpiredis_reader_reset($reader): void
100-
{
101-
}
81+
function phpiredis_reader_reset($reader): void {}
10282

10383
/**
10484
* @param resource $reader
10585
*/
106-
function phpiredis_reader_feed($reader, string $response): void
107-
{
108-
}
86+
function phpiredis_reader_feed($reader, string $response): void {}
10987

11088
/**
11189
* @param resource $reader
11290
*
11391
* @return bool|int
11492
*/
115-
function phpiredis_reader_get_state($reader)
116-
{
117-
}
93+
function phpiredis_reader_get_state($reader) {}
11894

11995
/**
12096
* @param resource $reader
12197
*
12298
* @return bool|string
12399
*/
124-
function phpiredis_reader_get_error($reader)
125-
{
126-
}
100+
function phpiredis_reader_get_error($reader) {}
127101

128102
/**
129103
* @param resource $reader
130104
*
131105
* @return array<array|bool|int|string>|bool|int|string
132106
*/
133-
function phpiredis_reader_get_reply($reader, int &$type)
134-
{
135-
}
107+
function phpiredis_reader_get_reply($reader, int &$type) {}
136108

137109
/**
138110
* @param resource $redis
139111
*/
140-
function phpiredis_reader_destroy($redis): void
141-
{
142-
}
112+
function phpiredis_reader_destroy($redis): void {}
143113

144114
/**
145115
* @param resource $reader
146116
*/
147-
function phpiredis_reader_set_error_handler($reader, ?callable $handler): void
148-
{
149-
}
117+
function phpiredis_reader_set_error_handler($reader, ?callable $handler): void {}
150118

151119
/**
152120
* @param resource $reader
153121
*/
154-
function phpiredis_reader_set_status_handler($reader, ?callable $handler): void
155-
{
156-
}
157-
function phpiredis_utils_crc16(string $data): int
158-
{
159-
}
122+
function phpiredis_reader_set_status_handler($reader, ?callable $handler): void {}
123+
function phpiredis_utils_crc16(string $data): int {}

0 commit comments

Comments
 (0)