Skip to content

Commit c9df0e9

Browse files
Upgrade deps (#81)
* Upgrade deps * Add php 8.1 * Update deps Co-authored-by: Ethan Hann <[email protected]>
1 parent e4656bf commit c9df0e9

File tree

13 files changed

+82
-51
lines changed

13 files changed

+82
-51
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/vendor/
22
.idea/
3-
.php_cs.cache
3+
.php-cs-fixer.cache
44
composer.lock
55
composer.phar
66
tests.log

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ php:
88
- 7.3
99
- 7.4
1010
- 8.0
11+
- 8.1
1112
before_script:
1213
- printf "yes\n" | pecl install igbinary
1314
- composer install

RoboFile.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
<?php
22

3+
use Robo\Collection\CollectionBuilder;
4+
use Robo\Result;
35
use Robo\Tasks;
46
use Robo\Collection\Collection;
57

68
require_once 'vendor/autoload.php';
79

810
class RoboFile extends Tasks
911
{
10-
function build()
12+
public function build(): Result
1113
{
1214
return (new Collection())
1315
->add($this->taskFixCodeStyle())
1416
->add($this->taskPhpUnit())
1517
->run();
1618
}
1719

18-
function test()
20+
public function test(): Result
1921
{
2022
return $this->taskPhpUnit()->run();
2123
}
2224

23-
function testAll()
25+
public function testAll(): Result
2426
{
2527
return (new Collection())
2628
->add($this->taskTestPredis())
@@ -29,41 +31,41 @@ function testAll()
2931
->run();
3032
}
3133

32-
function testPredis()
34+
public function testPredis(): Result
3335
{
3436
return $this->taskTestPredis()->run();
3537
}
3638

37-
function testPhpRedis()
39+
public function testPhpRedis(): Result
3840
{
3941
return $this->taskTestPhpRedis()->run();
4042
}
4143

42-
function testRedisClient()
44+
public function testRedisClient(): Result
4345
{
4446
return $this->taskTestRedisClient()->run();
4547
}
4648

47-
function taskFixCodeStyle()
49+
public function taskFixCodeStyle(): CollectionBuilder
4850
{
4951
return $this->taskExec('./vendor/bin/php-cs-fixer fix src');
5052
}
5153

52-
function taskTestPredis()
54+
public function taskTestPredis(): CollectionBuilder
5355
{
5456
$task = $this->taskPhpUnit();
5557
$task->env('REDIS_LIBRARY', 'Predis');
5658
return $task;
5759
}
5860

59-
function taskTestPhpRedis()
61+
public function taskTestPhpRedis(): CollectionBuilder
6062
{
6163
$task = $this->taskPhpUnit();
6264
$task->env('REDIS_LIBRARY', 'PhpRedis');
6365
return $task;
6466
}
6567

66-
function taskTestRedisClient()
68+
public function taskTestRedisClient(): CollectionBuilder
6769
{
6870
$task = $this->taskPhpUnit();
6971
$task->env('REDIS_LIBRARY', 'RedisClient');

composer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@
2121
"minimum-stability": "dev",
2222
"prefer-stable": true,
2323
"require": {
24-
"php": ">=7.3||>=8.0",
25-
"psr/log": "^1.0",
26-
"ethanhann/redis-raw": "v1.x-dev"
24+
"php": ">=8.0",
25+
"psr/log": "^3.0.0",
26+
"ethanhann/redis-raw": "^2.1.0"
2727
},
2828
"require-dev": {
29-
"phpunit/phpunit": "^8.0",
30-
"mockery/mockery": "^0.9.9",
31-
"predis/predis": "^1.1",
32-
"friendsofphp/php-cs-fixer": "^2.2",
33-
"consolidation/robo": "^2.0",
34-
"monolog/monolog": "^1.23",
29+
"phpunit/phpunit": "^9.5.23",
30+
"mockery/mockery": "^1.5.0",
31+
"predis/predis": "^v2.0.0",
32+
"friendsofphp/php-cs-fixer": "^v3.10.0",
33+
"consolidation/robo": "^4.0.0-alpha1",
34+
"monolog/monolog": "^3.2.0",
3535
"ukko/phpredis-phpdoc": "^5.0@beta",
3636
"cheprasov/php-redis-client": "^1.9"
3737
}

src/Exceptions/UnsupportedRediSearchLanguageException.php

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

45
use Exception;

src/Index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ public function setNoFrequenciesEnabled(bool $noFrequenciesEnabled): IndexInterf
291291
$this->noFrequenciesEnabled = $noFrequenciesEnabled;
292292
return $this;
293293
}
294-
294+
295295
/**
296296
* @param array $stopWords
297297
* @return IndexInterface

src/Query/Builder.php

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class Builder implements BuilderInterface
99
{
10-
const GEO_FILTER_UNITS = ['m', 'km', 'mi', 'ft'];
10+
public const GEO_FILTER_UNITS = ['m', 'km', 'mi', 'ft'];
1111

1212
protected $return = '';
1313
protected $summarize = '';
@@ -181,6 +181,11 @@ public function language(string $languageName): BuilderInterface
181181
return $this;
182182
}
183183

184+
protected function explodeArgument(?string $argument): array
185+
{
186+
return explode(' ', $argument ?? '');
187+
}
188+
184189
public function makeSearchCommandArguments(string $query): array
185190
{
186191
$queryParts = array_merge([$query], $this->tagFilters, $this->numericFilters, $this->geoFilters);
@@ -189,25 +194,25 @@ public function makeSearchCommandArguments(string $query): array
189194
return array_filter(
190195
array_merge(
191196
trim($queryWithFilters) === '' ? [$this->indexName] : [$this->indexName, $queryWithFilters],
192-
explode(' ', $this->limit),
193-
explode(' ', $this->slop),
197+
$this->explodeArgument($this->limit),
198+
$this->explodeArgument($this->slop),
194199
[
195200
$this->verbatim,
196201
$this->withScores,
197202
$this->withPayloads,
198203
$this->noStopWords,
199204
$this->noContent,
200205
],
201-
explode(' ', $this->inFields),
202-
explode(' ', $this->inKeys),
203-
explode(' ', $this->return),
204-
explode(' ', $this->summarize),
205-
explode(' ', $this->highlight),
206-
explode(' ', $this->sortBy),
207-
explode(' ', $this->scorer),
208-
explode(' ', $this->language),
209-
explode(' ', $this->expander),
210-
explode(' ', $this->payload)
206+
$this->explodeArgument($this->inFields),
207+
$this->explodeArgument($this->inKeys),
208+
$this->explodeArgument($this->return),
209+
$this->explodeArgument($this->summarize),
210+
$this->explodeArgument($this->highlight),
211+
$this->explodeArgument($this->sortBy),
212+
$this->explodeArgument($this->scorer),
213+
$this->explodeArgument($this->language),
214+
$this->explodeArgument($this->expander),
215+
$this->explodeArgument($this->payload),
211216
),
212217
function ($item) {
213218
return !is_null($item) && $item !== '';

src/RediSearchRedisClient.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,19 @@ public function __construct(RedisRawClientInterface $redis)
2525
$this->redis = $redis;
2626
}
2727

28-
public function validateRawCommandResults($payload, string $command, array $arguments)
28+
/**
29+
* @throws RediSearchException
30+
* @throws DocumentAlreadyInIndexException
31+
* @throws UnknownIndexNameException
32+
* @throws UnsupportedRediSearchLanguageException
33+
* @throws AliasDoesNotExistException
34+
* @throws UnknownRediSearchCommandException
35+
* @throws UnknownIndexNameOrNameIsAnAliasItselfException
36+
*/
37+
public function validateRawCommandResults($rawResult, string $command, array $arguments)
2938
{
30-
$isPayloadException = $payload instanceof Exception;
31-
$message = $isPayloadException ? $payload->getMessage() : $payload;
39+
$isRawResultException = $rawResult instanceof Exception;
40+
$message = $isRawResultException ? $rawResult->getMessage() : $rawResult;
3241

3342
if (!is_string($message)) {
3443
return;
@@ -60,12 +69,13 @@ public function validateRawCommandResults($payload, string $command, array $argu
6069
throw new DocumentAlreadyInIndexException($arguments[0], $arguments[1]);
6170
}
6271

63-
throw new RediSearchException($payload);
72+
throw new RediSearchException($rawResult);
6473
}
6574

6675
public function connect($hostname = '127.0.0.1', $port = 6379, $db = 0, $password = null): RedisRawClientInterface
6776
{
6877
$this->redis->connect($hostname, $port, $db, $password);
78+
return $this;
6979
}
7080

7181
public function flushAll()
@@ -78,6 +88,15 @@ public function multi(bool $usePipeline = false)
7888
return $this->redis->multi($usePipeline);
7989
}
8090

91+
/**
92+
* @throws RediSearchException
93+
* @throws DocumentAlreadyInIndexException
94+
* @throws UnknownIndexNameException
95+
* @throws UnsupportedRediSearchLanguageException
96+
* @throws AliasDoesNotExistException
97+
* @throws UnknownRediSearchCommandException
98+
* @throws UnknownIndexNameOrNameIsAnAliasItselfException
99+
*/
81100
public function rawCommand(string $command, array $arguments = [])
82101
{
83102
try {

src/Suggestion.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
class Suggestion extends AbstractIndex
66
{
7-
87
/**
98
* Add a suggestion string to an auto-complete suggestion dictionary.
109
* This is disconnected from the index definitions,

tests/RediSearch/Aggregate/BuilderTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,17 +286,18 @@ public function testGetQuantile()
286286

287287
$result = $this->subject
288288
->groupBy('title')
289-
->quantile('price', 0.5)
289+
->quantile('price', 1)
290290
->search();
291291

292-
$this->assertEquals($expected1, $result->getDocuments()[0]->quantile_price);
293-
$this->assertEquals($expected2, $result->getDocuments()[1]->quantile_price);
294-
$this->assertEquals($expected3, $result->getDocuments()[2]->quantile_price);
292+
$documents = $result->getDocuments();
293+
$this->assertEquals($expected1, $documents[0]->quantile_price);
294+
$this->assertEquals($expected2, $documents[1]->quantile_price);
295+
$this->assertEquals($expected3, $documents[2]->quantile_price);
295296
}
296297

297298
public function testGetAbsoluteQuantile()
298299
{
299-
$expected = 38.85;
300+
$expected = 18.85;
300301

301302
$result = $this->subject
302303
->groupBy()

0 commit comments

Comments
 (0)