Skip to content

Commit f48a0bc

Browse files
alexandre-dauboischr-hertel
authored andcommitted
chore: remove occurrences of empty() (#374)
`empty()` is used less and less in favor of bool casts on arrays. Symfony, for example, banned it from its codebase. I suggest we remove them from here as well.
1 parent daa3204 commit f48a0bc

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

src/Bridge/Anthropic/Contract/AssistantMessageNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function normalize(mixed $data, ?string $format = null, array $context =
5858
'type' => 'tool_use',
5959
'id' => $toolCall->id,
6060
'name' => $toolCall->name,
61-
'input' => empty($toolCall->arguments) ? new \stdClass() : $toolCall->arguments,
61+
'input' => 0 !== \count($toolCall->arguments) ? $toolCall->arguments : new \stdClass(),
6262
];
6363
}, $data->toolCalls),
6464
];

src/Bridge/Anthropic/ResponseConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function convert(ResponseInterface $response, array $options = []): LlmRe
5757
throw new RuntimeException('Response content does not contain any text nor tool calls.');
5858
}
5959

60-
if (!empty($toolCalls)) {
60+
if (0 !== \count($toolCalls)) {
6161
return new ToolCallResponse(...$toolCalls);
6262
}
6363

src/Bridge/Bedrock/Anthropic/ClaudeHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function convert(InvokeModelResponse $bedrockResponse): LlmResponse
8080
$toolCalls[] = new ToolCall($content['id'], $content['name'], $content['input']);
8181
}
8282
}
83-
if (!empty($toolCalls)) {
83+
if (0 !== \count($toolCalls)) {
8484
return new ToolCallResponse(...$toolCalls);
8585
}
8686

src/Bridge/Bedrock/Nova/Contract/AssistantMessageNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function normalize(mixed $data, ?string $format = null, array $context =
5757
'toolUse' => [
5858
'toolUseId' => $toolCall->id,
5959
'name' => $toolCall->name,
60-
'input' => empty($toolCall->arguments) ? new \stdClass() : $toolCall->arguments,
60+
'input' => 0 !== \count($toolCall->arguments) ? $toolCall->arguments : new \stdClass(),
6161
],
6262
];
6363
}, $data->toolCalls),

src/Bridge/Bedrock/Nova/NovaHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function convert(InvokeModelResponse $bedrockResponse): LlmResponse
8181
$toolCalls[] = new ToolCall($content['toolUse']['toolUseId'], $content['toolUse']['name'], $content['toolUse']['input']);
8282
}
8383
}
84-
if (!empty($toolCalls)) {
84+
if (0 !== \count($toolCalls)) {
8585
return new ToolCallResponse(...$toolCalls);
8686
}
8787

0 commit comments

Comments
 (0)