Skip to content

Commit 659778d

Browse files
committed
Remove void return types from test methods and fix code style
- Remove void return types from TextTrimTransformerTest methods - Apply PHP-CS-Fixer to ensure consistent code style across store component
1 parent 1b7fe71 commit 659778d

File tree

7 files changed

+21
-23
lines changed

7 files changed

+21
-23
lines changed

src/store/src/Document/Loader/TextFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function load(?string $source, array $options = []): iterable
2828
if (null === $source) {
2929
throw new InvalidArgumentException('TextFileLoader requires a file path as source, null given.');
3030
}
31-
31+
3232
if (!is_file($source)) {
3333
throw new RuntimeException(\sprintf('File "%s" does not exist.', $source));
3434
}

src/store/src/Document/Transformer/TextSplitTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(
3434
private int $overlap = 200,
3535
) {
3636
if ($this->overlap < 0 || $this->overlap >= $this->chunkSize) {
37-
throw new InvalidArgumentException(sprintf('Overlap must be non-negative and less than chunk size. Got chunk size: %d, overlap: %d.', $this->chunkSize, $this->overlap));
37+
throw new InvalidArgumentException(\sprintf('Overlap must be non-negative and less than chunk size. Got chunk size: %d, overlap: %d.', $this->chunkSize, $this->overlap));
3838
}
3939
}
4040

src/store/src/Indexer.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,29 @@
2525
final readonly class Indexer implements IndexerInterface
2626
{
2727
/**
28-
* @param null|string|array<string> $source
29-
* @param TransformerInterface[] $transformers
28+
* @param string|array<string>|null $source
29+
* @param TransformerInterface[] $transformers
3030
*/
3131
public function __construct(
3232
private LoaderInterface $loader,
3333
private VectorizerInterface $vectorizer,
3434
private StoreInterface $store,
35-
private null|string|array $source = null,
35+
private string|array|null $source = null,
3636
private array $transformers = [],
3737
private LoggerInterface $logger = new NullLogger(),
3838
) {
3939
}
4040

41-
public function index(null|string|array $source = null, array $options = []): void
41+
public function index(string|array|null $source = null, array $options = []): void
4242
{
4343
// Prevent conflicting sources
4444
if (null !== $source && null !== $this->source) {
4545
throw new \LogicException('Cannot provide a source when indexer already has a configured source. Use a different indexer instance or call index() without arguments.');
4646
}
47-
47+
4848
// Use configured source if no source is provided
4949
$source = $source ?? $this->source;
50-
50+
5151
$this->logger->debug('Starting document processing', ['source' => $source, 'options' => $options]);
5252

5353
$sources = null === $source ? [null] : (array) $source;
@@ -58,7 +58,7 @@ public function index(null|string|array $source = null, array $options = []): vo
5858

5959
if ([] === $documents) {
6060
$this->logger->debug('No documents to process', ['source' => $source]);
61-
61+
6262
return;
6363
}
6464

@@ -91,7 +91,7 @@ public function index(null|string|array $source = null, array $options = []): vo
9191
/**
9292
* @return TextDocument[]
9393
*/
94-
private function loadSource(null|string $source): array
94+
private function loadSource(?string $source): array
9595
{
9696
$documents = [];
9797

src/store/src/IndexerInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ interface IndexerInterface
2020
{
2121
/**
2222
* Process sources through the complete document pipeline: load → transform → vectorize → store.
23-
*
24-
* @param null|string|array<string> $source Source identifier (file path, URL, etc.), array of sources, or null if the loader does not need a source, e.g. InMemoryLoader
25-
* @param array{chunk_size?: int} $options Processing options
23+
*
24+
* @param string|array<string>|null $source Source identifier (file path, URL, etc.), array of sources, or null if the loader does not need a source, e.g. InMemoryLoader
25+
* @param array{chunk_size?: int} $options Processing options
2626
*/
27-
public function index(null|string|array $source = null, array $options = []): void;
27+
public function index(string|array|null $source = null, array $options = []): void;
2828
}

src/store/tests/Document/Loader/InMemoryLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testLoadIgnoresSourceParameter()
6464
{
6565
$document = new TextDocument(Uuid::v4(), 'Test content');
6666
$loader = new InMemoryLoader([$document]);
67-
67+
6868
// Source parameter should be ignored - same result regardless of value
6969
$documentsWithNull = iterator_to_array($loader->load(null));
7070
$documentsWithString = iterator_to_array($loader->load('ignored-source'));

src/store/tests/Document/Transformer/TextTrimTransformerTest.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\AI\Store\Tests\Document\Transformer;
1313

1414
use PHPUnit\Framework\Attributes\CoversClass;
15-
use PHPUnit\Framework\Attributes\DataProvider;
1615
use PHPUnit\Framework\Attributes\TestWith;
1716
use PHPUnit\Framework\TestCase;
1817
use Symfony\AI\Store\Document\Metadata;
@@ -34,7 +33,7 @@ final class TextTrimTransformerTest extends TestCase
3433
#[TestWith(['already trimmed', 'already trimmed'])]
3534
#[TestWith([' mixed whitespace ', 'mixed whitespace'])]
3635
#[TestWith(["\r\ncarriage return and newline\r\n", 'carriage return and newline'])]
37-
public function testTrim(string $input, string $expected): void
36+
public function testTrim(string $input, string $expected)
3837
{
3938
$transformer = new TextTrimTransformer();
4039
$document = new TextDocument(Uuid::v4(), $input);
@@ -45,17 +44,17 @@ public function testTrim(string $input, string $expected): void
4544
$this->assertSame($expected, $result[0]->content);
4645
}
4746

48-
public function testTrimHandlesOnlyWhitespace(): void
47+
public function testTrimHandlesOnlyWhitespace()
4948
{
5049
// Note: TextDocument doesn't allow empty content, so we can't test trimming to empty string
5150
// This test verifies that attempting to create a document with only whitespace throws an exception
5251
$this->expectException(InvalidArgumentException::class);
5352
$this->expectExceptionMessage('The content shall not be an empty string.');
54-
53+
5554
new TextDocument(Uuid::v4(), ' ');
5655
}
5756

58-
public function testTrimProcessesMultipleDocuments(): void
57+
public function testTrimProcessesMultipleDocuments()
5958
{
6059
$transformer = new TextTrimTransformer();
6160
$documents = [
@@ -72,7 +71,7 @@ public function testTrimProcessesMultipleDocuments(): void
7271
$this->assertSame('third', $result[2]->content);
7372
}
7473

75-
public function testTrimPreservesMetadata(): void
74+
public function testTrimPreservesMetadata()
7675
{
7776
$transformer = new TextTrimTransformer();
7877
$metadata = new Metadata(['key' => 'value']);
@@ -85,7 +84,7 @@ public function testTrimPreservesMetadata(): void
8584
$this->assertSame($metadata, $result[0]->metadata);
8685
}
8786

88-
public function testTrimPreservesDocumentId(): void
87+
public function testTrimPreservesDocumentId()
8988
{
9089
$transformer = new TextTrimTransformer();
9190
$id = Uuid::v4();

src/store/tests/IndexerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use PHPUnit\Framework\Attributes\Medium;
1616
use PHPUnit\Framework\Attributes\UsesClass;
1717
use PHPUnit\Framework\TestCase;
18-
use Psr\Log\LoggerInterface;
1918
use Symfony\AI\Platform\Bridge\OpenAi\Embeddings;
2019
use Symfony\AI\Platform\Message\ToolCallMessage;
2120
use Symfony\AI\Platform\Platform;

0 commit comments

Comments
 (0)