Skip to content

Commit ddce4cd

Browse files
authored
Add PHP 8.2 support (#83)
* Use AllowDynamicProperties to remove whitelist messages a few classes for dynamic property access * Update failing tag test * Make test config's REDIS_PORT match docker compose config * Add a "dev" helper script to simplify starting docker image for testing
1 parent 6664c08 commit ddce4cd

File tree

7 files changed

+26
-7
lines changed

7 files changed

+26
-7
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"minimum-stability": "dev",
2222
"prefer-stable": true,
2323
"require": {
24-
"php": ">=8.0",
24+
"php": ">=8.2",
2525
"psr/log": "^3.0.0",
2626
"ethanhann/redis-raw": "^2.1.0"
2727
},

dev

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
docker compose up

docker-compose.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: '3.8'
2+
3+
services:
4+
redis:
5+
container_name: redis
6+
image: 'redis/redis-stack'
7+
ports:
8+
- '6381:6379'

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<php>
2525
<env name="REDIS_LIBRARY" value="Predis" />
2626
<env name="REDIS_HOST" value="localhost" />
27-
<env name="REDIS_PORT" value="6379" />
27+
<env name="REDIS_PORT" value="6381" />
2828
<env name="REDIS_DB" value="0" />
2929
<env name="LOG_FILE" value="./tests.log" />
3030
<env name="IS_LOGGING_ENABLED" value="true" />

src/Document/Document.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
namespace Ehann\RediSearch\Document;
44

5+
use AllowDynamicProperties;
56
use Ehann\RediSearch\Exceptions\OutOfRangeDocumentScoreException;
67
use Ehann\RediSearch\Fields\FieldInterface;
78

9+
#[AllowDynamicProperties]
810
class Document implements DocumentInterface
911
{
1012
protected $id;

tests/RediSearch/IndexTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,26 +172,30 @@ public function testCreateIndexWithTagField()
172172

173173
public function testGetTagValues()
174174
{
175+
$expectedTagCount = 2;
176+
$blue = 'blue';
177+
$red = 'red';
175178
$this->subject->create();
176179
$this->subject->add([
177180
new TextField('title', 'How to be awesome.'),
178181
new TextField('author', 'Jack'),
179182
new NumericField('price', 9.99),
180183
new NumericField('stock', 231),
181-
new TagField('color', 'red'),
184+
new TagField('color', $red),
182185
]);
183186
$this->subject->add([
184187
new TextField('title', 'F.O.W.L'),
185188
new TextField('author', 'Jill'),
186189
new NumericField('price', 19.99),
187190
new NumericField('stock', 31),
188-
new TagField('color', 'blue'),
191+
new TagField('color', $blue),
189192
]);
190-
$expected = ['red', 'blue'];
191193

192194
$actual = $this->subject->tagValues('color');
193195

194-
$this->assertEquals($expected, $actual);
196+
$this->assertContains($blue, $actual);
197+
$this->assertContains($red, $actual);
198+
$this->assertEquals($expectedTagCount, count($actual));
195199
}
196200

197201
public function testAddDocumentWithZeroScore()
@@ -381,7 +385,7 @@ public function testAddDocumentFromHash()
381385
$this->assertTrue($result);
382386
}
383387

384-
public function testFindDocumentAddedWithHash ()
388+
public function testFindDocumentAddedWithHash()
385389
{
386390
$this->subject->create();
387391
$title = 'How to be awesome';

tests/Stubs/TestIndex.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
namespace Ehann\Tests\Stubs;
44

5+
use AllowDynamicProperties;
56
use Ehann\RediSearch\Index;
67

8+
#[AllowDynamicProperties]
79
class TestIndex extends Index
810
{
911
}

0 commit comments

Comments
 (0)