Skip to content

Commit ba2321e

Browse files
committed
feature #951 Make LoaderInterface::load() $source parameter optional (OskarStark)
This PR was merged into the main branch. Discussion ---------- Make `LoaderInterface::load()` `$source` parameter optional | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | Docs? | no | Issues | -- | License | MIT 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 and other loaders which doesn't require a source. Commits ------- 45f679a Make LoaderInterface::load() source parameter optional
2 parents f9ee763 + 45f679a commit ba2321e

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/store/src/Document/Loader/InMemoryLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct(
3030
) {
3131
}
3232

33-
public function load(?string $source, array $options = []): iterable
33+
public function load(?string $source = null, array $options = []): iterable
3434
{
3535
yield from $this->documents;
3636
}

src/store/src/Document/Loader/RssFeedLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(
4141
/**
4242
* @param array{uuid_namespace?: string} $options
4343
*/
44-
public function load(?string $source, array $options = []): iterable
44+
public function load(?string $source = null, array $options = []): iterable
4545
{
4646
if (!class_exists(Crawler::class)) {
4747
throw new RuntimeException('For using the RSS loader, the Symfony DomCrawler component is required. Try running "composer require symfony/dom-crawler".');

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
final class TextFileLoader implements LoaderInterface
2525
{
26-
public function load(?string $source, array $options = []): iterable
26+
public function load(?string $source = null, array $options = []): iterable
2727
{
2828
if (null === $source) {
2929
throw new InvalidArgumentException('TextFileLoader requires a file path as source, null given.');

src/store/src/Document/LoaderInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ interface LoaderInterface
2222
*
2323
* @return iterable<EmbeddableDocumentInterface> iterable of embeddable documents loaded from the source
2424
*/
25-
public function load(?string $source, array $options = []): iterable;
25+
public function load(?string $source = null, array $options = []): iterable;
2626
}

0 commit comments

Comments
 (0)