Skip to content

Commit 058de76

Browse files
committed
minor #72 chore: remove occurrences of empty() (alexandre-daubois, chr-hertel)
This PR was merged into the main branch. Discussion ---------- chore: remove occurrences of `empty()` | Q | A | ------------- | --- | Bug fix? | no | New feature? |no | Docs? | no | Issues | | License | MIT Cherry picking php-llm/llm-chain#374 Commits ------- c0d688f chore: use [] checks instead of count with zero on array fb3d1a8 chore: use isset instead of bool cast on $_ENV 14c448c chore: remove occurrences of `empty()` (#374)
2 parents 61b5241 + 905c561 commit 058de76

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/Toolbox/Tool/SimilaritySearch.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __invoke(string $searchTerm): string
4343
$vectors = $this->platform->request($this->model, $searchTerm)->asVectors();
4444
$this->usedDocuments = $this->vectorStore->query($vectors[0]);
4545

46-
if (0 === \count($this->usedDocuments)) {
46+
if ([] === $this->usedDocuments) {
4747
return 'No results found';
4848
}
4949

src/Toolbox/Tool/Wikipedia.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function search(string $query): string
4141

4242
$titles = array_map(fn (array $item) => $item['title'], $result['query']['search']);
4343

44-
if (empty($titles)) {
44+
if ([] === $titles) {
4545
return 'No articles were found on Wikipedia.';
4646
}
4747

src/Toolbox/ToolFactory/ReflectionToolFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function getTool(string $reference): iterable
3333
$reflectionClass = new \ReflectionClass($reference);
3434
$attributes = $reflectionClass->getAttributes(AsTool::class);
3535

36-
if (0 === \count($attributes)) {
36+
if ([] === $attributes) {
3737
throw ToolException::missingAttribute($reference);
3838
}
3939

0 commit comments

Comments
 (0)