Skip to content

Fix deprecation warning with PHP 8.1+ #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/Query/Builder/QueryElementDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,4 @@

namespace MacFJA\RediSearch\Query\Builder;

interface QueryElementDecorator extends QueryElement
{
}
interface QueryElementDecorator extends QueryElement {}
2 changes: 1 addition & 1 deletion src/Query/Builder/QueryElementVector.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
class QueryElementVector implements QueryElementDecorator
{
private const PARAMETERS = [
'EF_RUNTIME' => 'int',
'EF_RUNTIME' => 'integer',
];

/** @var QueryElement */
Expand Down
1 change: 1 addition & 0 deletions src/Redis/Client/PhpredisClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public function executeRaw(...$args)
if (count($args) < 1) {
return null;
}

// @phpstan-ignore-next-line
return $this->redis->rawCommand(...$args);
}
Expand Down
4 changes: 1 addition & 3 deletions src/Redis/Command/AggregateCommand/LimitOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,4 @@

namespace MacFJA\RediSearch\Redis\Command\AggregateCommand;

class LimitOption extends \MacFJA\RediSearch\Redis\Command\SearchCommand\LimitOption
{
}
class LimitOption extends \MacFJA\RediSearch\Redis\Command\SearchCommand\LimitOption {}
3 changes: 1 addition & 2 deletions src/Redis/Command/CreateCommand/VectorFieldOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ public function addAttribute(string $type, int $dimension, string $distanceMetri
+ (is_int($blockSize) ? 2 : 0)
+ (is_int($maxEdge) ? 2 : 0)
+ (is_int($efConstruction) ? 2 : 0)
+ (is_int($efRuntime) ? 2 : 0)
;
+ (is_int($efRuntime) ? 2 : 0);

/** @var int $count */
$count = $this->getDataOfOption('count') ?? 0;
Expand Down
3 changes: 3 additions & 0 deletions src/Redis/Command/Option/DecoratedOptionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public function getVersionConstraint(): string
return $this->decorated->getVersionConstraint();
}

/**
* @return array<float|int|string>
*/
public function render(?string $version = null): array
{
return $this->decorated->render($version);
Expand Down
3 changes: 1 addition & 2 deletions src/Redis/Command/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,7 @@ public function parseResponse($data)
+ (true === $useScores ? 1 : 0)
+ (true === $usePayloads ? 1 : 0)
+ (true === $useSortKeys ? 1 : 0)
- (true === $noContent ? 1 : 0)
;
- (true === $noContent ? 1 : 0);

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

Expand Down
4 changes: 1 addition & 3 deletions src/Redis/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,4 @@

namespace MacFJA\RediSearch\Redis;

interface Response
{
}
interface Response {}
1 change: 1 addition & 0 deletions src/Redis/Response/AggregateResponseItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public function getValue(string $fieldName, $default = null)
__METHOD__,
__CLASS__
), E_USER_DEPRECATED);

// @phpstan-ignore-next-line
return $this->getFieldValue($fieldName, $default);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Redis/Response/PaginatedResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function __construct(PaginatedCommand $command, int $totalCount, array $i
/**
* @return array<ResponseItem>
*/
public function current()
public function current(): array
{
if ($this->requestedOffset === ($this->lastCommand->getOffset() ?? 0) && ($this->requestedSize === $this->getPageSize())) {
$this->requestedOffset = null;
Expand Down Expand Up @@ -101,7 +101,7 @@ public function getPageCount(): int
return (int) ceil($this->totalCount / $this->getPageSize());
}

public function key()
public function key(): int
{
if (0 === $this->getPageSize()) {
return 0;
Expand All @@ -110,7 +110,7 @@ public function key()
return (int) floor(($this->lastCommand->getOffset() ?? $this->requestedOffset ?? 0) / $this->getPageSize());
}

public function valid()
public function valid(): bool
{
return (
null === $this->requestedOffset
Expand All @@ -133,7 +133,7 @@ public function getTotalCount(): int
return $this->totalCount;
}

public function count()
public function count(): int
{
return $this->getPageCount();
}
Expand Down
3 changes: 1 addition & 2 deletions tests/Query/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,7 @@ public function testDocExample3(): void
$expected = 'hello|world';
$builder = new Builder();

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

static::assertSame($expected, $builder->render());
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Redis/Command/Option/GroupedOptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function testGetOptionsName(): void
public function testSetUnknownOptionData(): void
{
$this->expectException(OutOfRangeException::class);
$this->expectErrorMessage('There is no option for foobar');
$this->expectExceptionMessage('There is no option for foobar');

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

$option = new GroupedOption(['lock' => new NamelessOption('foo')], [], ['lock']);
$option->setDataOfOption('lock', 'bar');
Expand Down
72 changes: 18 additions & 54 deletions tests/psalm/stubs/phpiredis.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,130 +30,94 @@
const PHPIREDIS_REPLY_STATUS = 5;
const PHPIREDIS_REPLY_ERROR = 6;

function phpiredis_connect($host, $port = 6379): void
{
}
function phpiredis_pconnect($host, $port = 6379): void
{
}
function phpiredis_disconnect(): void
{
}
function phpiredis_connect($host, $port = 6379): void {}
function phpiredis_pconnect($host, $port = 6379): void {}
function phpiredis_disconnect(): void {}

/**
* @param resource $redis
* @param string[] $command
*
* @return bool|string
*/
function phpiredis_command_bs($redis, array $command)
{
}
function phpiredis_command_bs($redis, array $command) {}

/**
* @param resource $redis
*
* @return bool|string
*/
function phpiredis_command($redis, string $command)
{
}
function phpiredis_command($redis, string $command) {}

/**
* @param resource $redis
* @param array<string> $commands
*
* @return array<bool|string>
*/
function phpiredis_multi_command($redis, array $commands)
{
}
function phpiredis_multi_command($redis, array $commands) {}

/**
* @param resource $redis
* @param array<array<string>> $commands
*
* @return array<bool|string>
*/
function phpiredis_multi_command_bs($redis, array $commands)
{
}
function phpiredis_multi_command_bs($redis, array $commands) {}

/**
* @param array<float|int|string> $args
*/
function phpiredis_format_command(array $args): string
{
}
function phpiredis_format_command(array $args): string {}

/**
* @return resource
*/
function phpiredis_reader_create()
{
}
function phpiredis_reader_create() {}

/**
* @param resource $reader
*/
function phpiredis_reader_reset($reader): void
{
}
function phpiredis_reader_reset($reader): void {}

/**
* @param resource $reader
*/
function phpiredis_reader_feed($reader, string $response): void
{
}
function phpiredis_reader_feed($reader, string $response): void {}

/**
* @param resource $reader
*
* @return bool|int
*/
function phpiredis_reader_get_state($reader)
{
}
function phpiredis_reader_get_state($reader) {}

/**
* @param resource $reader
*
* @return bool|string
*/
function phpiredis_reader_get_error($reader)
{
}
function phpiredis_reader_get_error($reader) {}

/**
* @param resource $reader
*
* @return array<array|bool|int|string>|bool|int|string
*/
function phpiredis_reader_get_reply($reader, int &$type)
{
}
function phpiredis_reader_get_reply($reader, int &$type) {}

/**
* @param resource $redis
*/
function phpiredis_reader_destroy($redis): void
{
}
function phpiredis_reader_destroy($redis): void {}

/**
* @param resource $reader
*/
function phpiredis_reader_set_error_handler($reader, ?callable $handler): void
{
}
function phpiredis_reader_set_error_handler($reader, ?callable $handler): void {}

/**
* @param resource $reader
*/
function phpiredis_reader_set_status_handler($reader, ?callable $handler): void
{
}
function phpiredis_utils_crc16(string $data): int
{
}
function phpiredis_reader_set_status_handler($reader, ?callable $handler): void {}
function phpiredis_utils_crc16(string $data): int {}