Skip to content
Closed
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
9 changes: 8 additions & 1 deletion src/Redis/Initializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,14 @@ public static function registerCommandsRediska(): void

public static function getRediSearchVersion(Client $client): ?string
{
$modules = $client->executeRaw('module', 'list') ?? [];
try {
$modules = $client->executeRaw('module', 'list') ?? [];
} catch (\Throwable $exception) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\Throwable should be imported (see PHP-CS-Fixer error: https://github.com/MacFJA/php-redisearch/runs/7054519075?check_suite_focus=true)

if (strpos($exception->getMessage(), 'unknown command') === false) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yoda style test is used (see PHP-CS-Fixer error: https://github.com/MacFJA/php-redisearch/runs/7054519075?check_suite_focus=true)

Suggested change
if (strpos($exception->getMessage(), 'unknown command') === false) {
if (false === strpos($exception->getMessage(), 'unknown command')) {

throw $exception;
}
$modules = [];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can return null directly, because the foreach will have nothing to run

Suggested change
$modules = [];
return null;

}

foreach ($modules as $module) {
$data = array_column(
Expand Down