From 45f679aaff507b2f6fd962b99211f609323678f1 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Sat, 22 Nov 2025 23:35:19 +0100 Subject: [PATCH] Make LoaderInterface::load() source parameter optional The source parameter in LoaderInterface::load() is now optional with a default value of null. This change makes the API more flexible, particularly for the InMemoryLoader which doesn't require a source. Updated the interface and all implementations: - LoaderInterface - InMemoryLoader - RssFeedLoader - TextFileLoader --- src/store/src/Document/Loader/InMemoryLoader.php | 2 +- src/store/src/Document/Loader/RssFeedLoader.php | 2 +- src/store/src/Document/Loader/TextFileLoader.php | 2 +- src/store/src/Document/LoaderInterface.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/store/src/Document/Loader/InMemoryLoader.php b/src/store/src/Document/Loader/InMemoryLoader.php index c08b31f5f..81525c426 100644 --- a/src/store/src/Document/Loader/InMemoryLoader.php +++ b/src/store/src/Document/Loader/InMemoryLoader.php @@ -30,7 +30,7 @@ public function __construct( ) { } - public function load(?string $source, array $options = []): iterable + public function load(?string $source = null, array $options = []): iterable { yield from $this->documents; } diff --git a/src/store/src/Document/Loader/RssFeedLoader.php b/src/store/src/Document/Loader/RssFeedLoader.php index 5bd9ba7aa..927e47287 100644 --- a/src/store/src/Document/Loader/RssFeedLoader.php +++ b/src/store/src/Document/Loader/RssFeedLoader.php @@ -41,7 +41,7 @@ public function __construct( /** * @param array{uuid_namespace?: string} $options */ - public function load(?string $source, array $options = []): iterable + public function load(?string $source = null, array $options = []): iterable { if (!class_exists(Crawler::class)) { throw new RuntimeException('For using the RSS loader, the Symfony DomCrawler component is required. Try running "composer require symfony/dom-crawler".'); diff --git a/src/store/src/Document/Loader/TextFileLoader.php b/src/store/src/Document/Loader/TextFileLoader.php index 28e0dc552..18cec8cb5 100644 --- a/src/store/src/Document/Loader/TextFileLoader.php +++ b/src/store/src/Document/Loader/TextFileLoader.php @@ -23,7 +23,7 @@ */ final class TextFileLoader implements LoaderInterface { - public function load(?string $source, array $options = []): iterable + public function load(?string $source = null, array $options = []): iterable { if (null === $source) { throw new InvalidArgumentException('TextFileLoader requires a file path as source, null given.'); diff --git a/src/store/src/Document/LoaderInterface.php b/src/store/src/Document/LoaderInterface.php index 123f4eab2..97de1f2ca 100644 --- a/src/store/src/Document/LoaderInterface.php +++ b/src/store/src/Document/LoaderInterface.php @@ -22,5 +22,5 @@ interface LoaderInterface * * @return iterable iterable of embeddable documents loaded from the source */ - public function load(?string $source, array $options = []): iterable; + public function load(?string $source = null, array $options = []): iterable; }