From 53e475732114395dcb5826c4940c1e716b18ba0b Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Wed, 2 Jul 2025 13:18:45 +0200 Subject: [PATCH] chore: remove occurrences of `empty()` --- examples/anthropic/chat.php | 2 +- examples/anthropic/image-input-binary.php | 2 +- examples/anthropic/image-input-url.php | 2 +- examples/anthropic/pdf-input-binary.php | 2 +- examples/anthropic/pdf-input-url.php | 2 +- examples/anthropic/stream.php | 2 +- examples/anthropic/toolcall.php | 2 +- examples/azure/audio-transcript.php | 2 +- examples/azure/chat-gpt.php | 2 +- examples/azure/chat-llama.php | 2 +- examples/azure/embeddings.php | 2 +- examples/bedrock/chat-claude.php | 2 +- examples/bedrock/chat-llama.php | 2 +- examples/bedrock/chat-nova.php | 2 +- examples/bedrock/image-claude-binary.php | 2 +- examples/bedrock/image-nova.php | 2 +- examples/bedrock/toolcall-claude.php | 2 +- examples/bedrock/toolcall-nova.php | 2 +- examples/chat-system-prompt.php | 2 +- examples/google/audio-input.php | 2 +- examples/google/chat.php | 2 +- examples/google/image-input.php | 2 +- examples/google/pdf-input-binary.php | 2 +- examples/google/server-tools.php | 2 +- examples/google/stream.php | 2 +- examples/google/structured-output-clock.php | 2 +- examples/google/structured-output-math.php | 2 +- examples/google/toolcall.php | 2 +- examples/huggingface/audio-classification.php | 2 +- examples/huggingface/automatic-speech-recognition.php | 2 +- examples/huggingface/chat-completion.php | 2 +- examples/huggingface/feature-extraction.php | 2 +- examples/huggingface/fill-mask.php | 2 +- examples/huggingface/image-classification.php | 2 +- examples/huggingface/image-segmentation.php | 2 +- examples/huggingface/image-to-text.php | 2 +- examples/huggingface/object-detection.php | 2 +- examples/huggingface/question-answering.php | 2 +- examples/huggingface/sentence-similarity.php | 2 +- examples/huggingface/summarization.php | 2 +- examples/huggingface/table-question-answering.php | 2 +- examples/huggingface/text-classification.php | 2 +- examples/huggingface/text-generation.php | 2 +- examples/huggingface/text-to-image.php | 2 +- examples/huggingface/token-classification.php | 2 +- examples/huggingface/translation.php | 2 +- examples/huggingface/zero-shot-classification.php | 2 +- examples/mistral/chat.php | 2 +- examples/mistral/embeddings.php | 2 +- examples/mistral/image.php | 2 +- examples/mistral/stream.php | 2 +- examples/mistral/structured-output-math.php | 2 +- examples/mistral/toolcall-stream.php | 2 +- examples/mistral/toolcall.php | 2 +- examples/ollama/chat-llama.php | 2 +- examples/openai/audio-input.php | 2 +- examples/openai/audio-transcript.php | 2 +- examples/openai/chat-o1.php | 4 ++-- examples/openai/chat.php | 2 +- examples/openai/embeddings.php | 2 +- examples/openai/image-input-binary.php | 2 +- examples/openai/image-input-url.php | 2 +- examples/openai/image-output-dall-e-2.php | 2 +- examples/openai/image-output-dall-e-3.php | 2 +- examples/openai/stream.php | 2 +- examples/openai/structured-output-clock.php | 2 +- examples/openai/structured-output-math.php | 2 +- examples/openai/token-metadata.php | 2 +- examples/openai/toolcall-stream.php | 2 +- examples/openai/toolcall.php | 2 +- examples/openrouter/chat-gemini.php | 2 +- examples/parallel-chat-gpt.php | 2 +- examples/parallel-embeddings.php | 2 +- examples/persistent-chat.php | 2 +- examples/replicate/chat-llama.php | 2 +- examples/store/document-vectorizing.php | 2 +- examples/store/mariadb-similarity-search-gemini.php | 2 +- examples/store/mariadb-similarity-search.php | 2 +- examples/store/mongodb-similarity-search.php | 2 +- examples/store/pinecone-similarity-search.php | 2 +- examples/toolbox/brave.php | 2 +- examples/toolbox/clock.php | 2 +- examples/toolbox/serpapi.php | 2 +- examples/toolbox/tavily.php | 2 +- examples/toolbox/weather-event.php | 2 +- examples/voyage/embeddings.php | 2 +- src/Chain/Toolbox/Tool/Wikipedia.php | 2 +- .../Bridge/Anthropic/Contract/AssistantMessageNormalizer.php | 2 +- src/Platform/Bridge/Anthropic/ResponseConverter.php | 2 +- src/Platform/Bridge/Bedrock/Anthropic/ClaudeHandler.php | 2 +- .../Bedrock/Nova/Contract/AssistantMessageNormalizer.php | 2 +- src/Platform/Bridge/Bedrock/Nova/NovaHandler.php | 2 +- 92 files changed, 93 insertions(+), 93 deletions(-) diff --git a/examples/anthropic/chat.php b/examples/anthropic/chat.php index 510cd78d..71ad6c66 100644 --- a/examples/anthropic/chat.php +++ b/examples/anthropic/chat.php @@ -10,7 +10,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['ANTHROPIC_API_KEY'])) { +if (!$_ENV['ANTHROPIC_API_KEY']) { echo 'Please set the ANTHROPIC_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/anthropic/image-input-binary.php b/examples/anthropic/image-input-binary.php index c2e7a3dc..2b0da28d 100644 --- a/examples/anthropic/image-input-binary.php +++ b/examples/anthropic/image-input-binary.php @@ -11,7 +11,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['ANTHROPIC_API_KEY'])) { +if (!$_ENV['ANTHROPIC_API_KEY']) { echo 'Please set the ANTHROPIC_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/anthropic/image-input-url.php b/examples/anthropic/image-input-url.php index 3ab59790..24ad0c56 100644 --- a/examples/anthropic/image-input-url.php +++ b/examples/anthropic/image-input-url.php @@ -11,7 +11,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['ANTHROPIC_API_KEY'])) { +if (!$_ENV['ANTHROPIC_API_KEY']) { echo 'Please set the ANTHROPIC_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/anthropic/pdf-input-binary.php b/examples/anthropic/pdf-input-binary.php index 936cfd68..75c83213 100644 --- a/examples/anthropic/pdf-input-binary.php +++ b/examples/anthropic/pdf-input-binary.php @@ -11,7 +11,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['ANTHROPIC_API_KEY'])) { +if (!$_ENV['ANTHROPIC_API_KEY']) { echo 'Please set the ANTHROPIC_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/anthropic/pdf-input-url.php b/examples/anthropic/pdf-input-url.php index 7af6d45d..18ad91be 100644 --- a/examples/anthropic/pdf-input-url.php +++ b/examples/anthropic/pdf-input-url.php @@ -11,7 +11,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['ANTHROPIC_API_KEY'])) { +if (!$_ENV['ANTHROPIC_API_KEY']) { echo 'Please set the ANTHROPIC_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/anthropic/stream.php b/examples/anthropic/stream.php index 6320cd63..73e1c59b 100644 --- a/examples/anthropic/stream.php +++ b/examples/anthropic/stream.php @@ -10,7 +10,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['ANTHROPIC_API_KEY'])) { +if (!$_ENV['ANTHROPIC_API_KEY']) { echo 'Please set the ANTHROPIC_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/anthropic/toolcall.php b/examples/anthropic/toolcall.php index a224d526..372ebee8 100644 --- a/examples/anthropic/toolcall.php +++ b/examples/anthropic/toolcall.php @@ -14,7 +14,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['ANTHROPIC_API_KEY'])) { +if (!$_ENV['ANTHROPIC_API_KEY']) { echo 'Please set the ANTHROPIC_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/azure/audio-transcript.php b/examples/azure/audio-transcript.php index 713f34d4..95680cce 100644 --- a/examples/azure/audio-transcript.php +++ b/examples/azure/audio-transcript.php @@ -8,7 +8,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['AZURE_OPENAI_BASEURL']) || empty($_ENV['AZURE_OPENAI_WHISPER_DEPLOYMENT']) || empty($_ENV['AZURE_OPENAI_WHISPER_API_VERSION']) || empty($_ENV['AZURE_OPENAI_KEY']) +if (!$_ENV['AZURE_OPENAI_BASEURL'] || !$_ENV['AZURE_OPENAI_WHISPER_DEPLOYMENT'] || !$_ENV['AZURE_OPENAI_WHISPER_API_VERSION'] || !$_ENV['AZURE_OPENAI_KEY'] ) { echo 'Please set the AZURE_OPENAI_BASEURL, AZURE_OPENAI_WHISPER_DEPLOYMENT, AZURE_OPENAI_WHISPER_API_VERSION, and AZURE_OPENAI_KEY environment variables.'.\PHP_EOL; exit(1); diff --git a/examples/azure/chat-gpt.php b/examples/azure/chat-gpt.php index 7b28aa6d..a0b19735 100644 --- a/examples/azure/chat-gpt.php +++ b/examples/azure/chat-gpt.php @@ -10,7 +10,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['AZURE_OPENAI_BASEURL']) || empty($_ENV['AZURE_OPENAI_GPT_DEPLOYMENT']) || empty($_ENV['AZURE_OPENAI_GPT_API_VERSION']) || empty($_ENV['AZURE_OPENAI_KEY']) +if (!$_ENV['AZURE_OPENAI_BASEURL'] || !$_ENV['AZURE_OPENAI_GPT_DEPLOYMENT'] || !$_ENV['AZURE_OPENAI_GPT_API_VERSION'] || !$_ENV['AZURE_OPENAI_KEY'] ) { echo 'Please set the AZURE_OPENAI_BASEURL, AZURE_OPENAI_GPT_DEPLOYMENT, AZURE_OPENAI_GPT_API_VERSION, and AZURE_OPENAI_KEY environment variables.'.\PHP_EOL; exit(1); diff --git a/examples/azure/chat-llama.php b/examples/azure/chat-llama.php index a895dc6a..685894ee 100644 --- a/examples/azure/chat-llama.php +++ b/examples/azure/chat-llama.php @@ -10,7 +10,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['AZURE_LLAMA_BASEURL']) || empty($_ENV['AZURE_LLAMA_KEY'])) { +if (!$_ENV['AZURE_LLAMA_BASEURL'] || !$_ENV['AZURE_LLAMA_KEY']) { echo 'Please set the AZURE_LLAMA_BASEURL and AZURE_LLAMA_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/azure/embeddings.php b/examples/azure/embeddings.php index d92eed99..3786349a 100644 --- a/examples/azure/embeddings.php +++ b/examples/azure/embeddings.php @@ -8,7 +8,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['AZURE_OPENAI_BASEURL']) || empty($_ENV['AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT']) || empty($_ENV['AZURE_OPENAI_EMBEDDINGS_API_VERSION']) || empty($_ENV['AZURE_OPENAI_KEY']) +if (!$_ENV['AZURE_OPENAI_BASEURL'] || !$_ENV['AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT'] || !$_ENV['AZURE_OPENAI_EMBEDDINGS_API_VERSION'] || !$_ENV['AZURE_OPENAI_KEY'] ) { echo 'Please set the AZURE_OPENAI_BASEURL, AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT, AZURE_OPENAI_EMBEDDINGS_API_VERSION, and AZURE_OPENAI_KEY environment variables.'.\PHP_EOL; exit(1); diff --git a/examples/bedrock/chat-claude.php b/examples/bedrock/chat-claude.php index b8fece13..b7c362af 100644 --- a/examples/bedrock/chat-claude.php +++ b/examples/bedrock/chat-claude.php @@ -10,7 +10,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['AWS_ACCESS_KEY_ID']) || empty($_ENV['AWS_SECRET_ACCESS_KEY']) || empty($_ENV['AWS_DEFAULT_REGION']) +if (!$_ENV['AWS_ACCESS_KEY_ID'] || !$_ENV['AWS_SECRET_ACCESS_KEY'] || !$_ENV['AWS_DEFAULT_REGION'] ) { echo 'Please set the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_DEFAULT_REGION environment variables.'.\PHP_EOL; exit(1); diff --git a/examples/bedrock/chat-llama.php b/examples/bedrock/chat-llama.php index 5ac723e3..c5a355b3 100644 --- a/examples/bedrock/chat-llama.php +++ b/examples/bedrock/chat-llama.php @@ -10,7 +10,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['AWS_ACCESS_KEY_ID']) || empty($_ENV['AWS_SECRET_ACCESS_KEY']) || empty($_ENV['AWS_DEFAULT_REGION']) +if (!$_ENV['AWS_ACCESS_KEY_ID'] || !$_ENV['AWS_SECRET_ACCESS_KEY'] || !$_ENV['AWS_DEFAULT_REGION'] ) { echo 'Please set the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_DEFAULT_REGION environment variables.'.\PHP_EOL; exit(1); diff --git a/examples/bedrock/chat-nova.php b/examples/bedrock/chat-nova.php index b68eaf8c..fb57796b 100644 --- a/examples/bedrock/chat-nova.php +++ b/examples/bedrock/chat-nova.php @@ -10,7 +10,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['AWS_ACCESS_KEY_ID']) || empty($_ENV['AWS_SECRET_ACCESS_KEY']) || empty($_ENV['AWS_DEFAULT_REGION']) +if (!$_ENV['AWS_ACCESS_KEY_ID'] || !$_ENV['AWS_SECRET_ACCESS_KEY'] || !$_ENV['AWS_DEFAULT_REGION'] ) { echo 'Please set the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_DEFAULT_REGION environment variables.'.\PHP_EOL; exit(1); diff --git a/examples/bedrock/image-claude-binary.php b/examples/bedrock/image-claude-binary.php index c229b9ad..e14360f5 100644 --- a/examples/bedrock/image-claude-binary.php +++ b/examples/bedrock/image-claude-binary.php @@ -11,7 +11,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['AWS_ACCESS_KEY_ID']) || empty($_ENV['AWS_SECRET_ACCESS_KEY']) || empty($_ENV['AWS_DEFAULT_REGION']) +if (!$_ENV['AWS_ACCESS_KEY_ID'] || !$_ENV['AWS_SECRET_ACCESS_KEY'] || !$_ENV['AWS_DEFAULT_REGION'] ) { echo 'Please set the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_DEFAULT_REGION environment variables.'.\PHP_EOL; exit(1); diff --git a/examples/bedrock/image-nova.php b/examples/bedrock/image-nova.php index 70bc654b..991b4716 100644 --- a/examples/bedrock/image-nova.php +++ b/examples/bedrock/image-nova.php @@ -11,7 +11,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['AWS_ACCESS_KEY_ID']) || empty($_ENV['AWS_SECRET_ACCESS_KEY']) || empty($_ENV['AWS_DEFAULT_REGION']) +if (!$_ENV['AWS_ACCESS_KEY_ID'] || !$_ENV['AWS_SECRET_ACCESS_KEY'] || !$_ENV['AWS_DEFAULT_REGION'] ) { echo 'Please set the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_DEFAULT_REGION environment variables.'.\PHP_EOL; exit(1); diff --git a/examples/bedrock/toolcall-claude.php b/examples/bedrock/toolcall-claude.php index 149a5cb1..c66a11af 100644 --- a/examples/bedrock/toolcall-claude.php +++ b/examples/bedrock/toolcall-claude.php @@ -14,7 +14,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['AWS_ACCESS_KEY_ID']) || empty($_ENV['AWS_SECRET_ACCESS_KEY']) || empty($_ENV['AWS_DEFAULT_REGION']) +if (!$_ENV['AWS_ACCESS_KEY_ID'] || !$_ENV['AWS_SECRET_ACCESS_KEY'] || !$_ENV['AWS_DEFAULT_REGION'] ) { echo 'Please set the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_DEFAULT_REGION environment variables.'.\PHP_EOL; exit(1); diff --git a/examples/bedrock/toolcall-nova.php b/examples/bedrock/toolcall-nova.php index f43302e5..4495c4be 100644 --- a/examples/bedrock/toolcall-nova.php +++ b/examples/bedrock/toolcall-nova.php @@ -14,7 +14,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['AWS_ACCESS_KEY_ID']) || empty($_ENV['AWS_SECRET_ACCESS_KEY']) || empty($_ENV['AWS_DEFAULT_REGION']) +if (!$_ENV['AWS_ACCESS_KEY_ID'] || !$_ENV['AWS_SECRET_ACCESS_KEY'] || !$_ENV['AWS_DEFAULT_REGION'] ) { echo 'Please set the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_DEFAULT_REGION environment variables.'.\PHP_EOL; exit(1); diff --git a/examples/chat-system-prompt.php b/examples/chat-system-prompt.php index 49886e0c..15bfdfda 100644 --- a/examples/chat-system-prompt.php +++ b/examples/chat-system-prompt.php @@ -11,7 +11,7 @@ require_once dirname(__DIR__).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/google/audio-input.php b/examples/google/audio-input.php index 6ad09a75..b859c1dd 100644 --- a/examples/google/audio-input.php +++ b/examples/google/audio-input.php @@ -11,7 +11,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['GOOGLE_API_KEY'])) { +if (!$_ENV['GOOGLE_API_KEY']) { echo 'Please set the GOOGLE_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/google/chat.php b/examples/google/chat.php index 133e1e76..0c813aff 100644 --- a/examples/google/chat.php +++ b/examples/google/chat.php @@ -10,7 +10,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['GOOGLE_API_KEY'])) { +if (!$_ENV['GOOGLE_API_KEY']) { echo 'Please set the GOOGLE_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/google/image-input.php b/examples/google/image-input.php index d6644a1f..6d10a391 100644 --- a/examples/google/image-input.php +++ b/examples/google/image-input.php @@ -11,7 +11,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['GOOGLE_API_KEY'])) { +if (!$_ENV['GOOGLE_API_KEY']) { echo 'Please set the GOOGLE_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/google/pdf-input-binary.php b/examples/google/pdf-input-binary.php index c10401ee..e10cc1cb 100644 --- a/examples/google/pdf-input-binary.php +++ b/examples/google/pdf-input-binary.php @@ -11,7 +11,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['GOOGLE_API_KEY'])) { +if (!$_ENV['GOOGLE_API_KEY']) { echo 'Please set the GOOGLE_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/google/server-tools.php b/examples/google/server-tools.php index 0b1d24a3..568120f4 100644 --- a/examples/google/server-tools.php +++ b/examples/google/server-tools.php @@ -13,7 +13,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['GOOGLE_API_KEY'])) { +if (!$_ENV['GOOGLE_API_KEY']) { echo 'Please set the GOOGLE_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/google/stream.php b/examples/google/stream.php index de9bc5d3..693d7718 100644 --- a/examples/google/stream.php +++ b/examples/google/stream.php @@ -10,7 +10,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['GOOGLE_API_KEY'])) { +if (!$_ENV['GOOGLE_API_KEY']) { echo 'Please set the GOOGLE_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/google/structured-output-clock.php b/examples/google/structured-output-clock.php index 5043db5b..6bbbc584 100644 --- a/examples/google/structured-output-clock.php +++ b/examples/google/structured-output-clock.php @@ -15,7 +15,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['GOOGLE_API_KEY'])) { +if (!$_ENV['GOOGLE_API_KEY']) { echo 'Please set the GOOGLE_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/google/structured-output-math.php b/examples/google/structured-output-math.php index 2168cde5..df75e01e 100644 --- a/examples/google/structured-output-math.php +++ b/examples/google/structured-output-math.php @@ -12,7 +12,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['GOOGLE_API_KEY'])) { +if (!$_ENV['GOOGLE_API_KEY']) { echo 'Please set the GOOGLE_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/google/toolcall.php b/examples/google/toolcall.php index 2e47b3a5..b344f74e 100644 --- a/examples/google/toolcall.php +++ b/examples/google/toolcall.php @@ -13,7 +13,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['GOOGLE_API_KEY'])) { +if (!$_ENV['GOOGLE_API_KEY']) { echo 'Please set the GOOGLE_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/huggingface/audio-classification.php b/examples/huggingface/audio-classification.php index d5d89c6d..07e4af9b 100644 --- a/examples/huggingface/audio-classification.php +++ b/examples/huggingface/audio-classification.php @@ -9,7 +9,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['HUGGINGFACE_KEY'])) { +if (!$_ENV['HUGGINGFACE_KEY']) { echo 'Please set the HUGGINGFACE_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/huggingface/automatic-speech-recognition.php b/examples/huggingface/automatic-speech-recognition.php index 943a55e3..cebe8750 100644 --- a/examples/huggingface/automatic-speech-recognition.php +++ b/examples/huggingface/automatic-speech-recognition.php @@ -9,7 +9,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['HUGGINGFACE_KEY'])) { +if (!$_ENV['HUGGINGFACE_KEY']) { echo 'Please set the HUGGINGFACE_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/huggingface/chat-completion.php b/examples/huggingface/chat-completion.php index 257ea999..fc471cb9 100644 --- a/examples/huggingface/chat-completion.php +++ b/examples/huggingface/chat-completion.php @@ -10,7 +10,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['HUGGINGFACE_KEY'])) { +if (!$_ENV['HUGGINGFACE_KEY']) { echo 'Please set the HUGGINGFACE_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/huggingface/feature-extraction.php b/examples/huggingface/feature-extraction.php index 32d437da..68258583 100644 --- a/examples/huggingface/feature-extraction.php +++ b/examples/huggingface/feature-extraction.php @@ -9,7 +9,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['HUGGINGFACE_KEY'])) { +if (!$_ENV['HUGGINGFACE_KEY']) { echo 'Please set the HUGGINGFACE_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/huggingface/fill-mask.php b/examples/huggingface/fill-mask.php index b04e959b..4b467e8f 100644 --- a/examples/huggingface/fill-mask.php +++ b/examples/huggingface/fill-mask.php @@ -8,7 +8,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['HUGGINGFACE_KEY'])) { +if (!$_ENV['HUGGINGFACE_KEY']) { echo 'Please set the HUGGINGFACE_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/huggingface/image-classification.php b/examples/huggingface/image-classification.php index a997a119..c038c4d9 100644 --- a/examples/huggingface/image-classification.php +++ b/examples/huggingface/image-classification.php @@ -9,7 +9,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['HUGGINGFACE_KEY'])) { +if (!$_ENV['HUGGINGFACE_KEY']) { echo 'Please set the HUGGINGFACE_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/huggingface/image-segmentation.php b/examples/huggingface/image-segmentation.php index 3447ad82..8f565397 100644 --- a/examples/huggingface/image-segmentation.php +++ b/examples/huggingface/image-segmentation.php @@ -9,7 +9,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['HUGGINGFACE_KEY'])) { +if (!$_ENV['HUGGINGFACE_KEY']) { echo 'Please set the HUGGINGFACE_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/huggingface/image-to-text.php b/examples/huggingface/image-to-text.php index 2c135efa..ee52b1f1 100644 --- a/examples/huggingface/image-to-text.php +++ b/examples/huggingface/image-to-text.php @@ -9,7 +9,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['HUGGINGFACE_KEY'])) { +if (!$_ENV['HUGGINGFACE_KEY']) { echo 'Please set the HUGGINGFACE_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/huggingface/object-detection.php b/examples/huggingface/object-detection.php index 72f35c82..2921de59 100644 --- a/examples/huggingface/object-detection.php +++ b/examples/huggingface/object-detection.php @@ -9,7 +9,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['HUGGINGFACE_KEY'])) { +if (!$_ENV['HUGGINGFACE_KEY']) { echo 'Please set the HUGGINGFACE_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/huggingface/question-answering.php b/examples/huggingface/question-answering.php index c1d71551..fa2d75b7 100644 --- a/examples/huggingface/question-answering.php +++ b/examples/huggingface/question-answering.php @@ -8,7 +8,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['HUGGINGFACE_KEY'])) { +if (!$_ENV['HUGGINGFACE_KEY']) { echo 'Please set the HUGGINGFACE_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/huggingface/sentence-similarity.php b/examples/huggingface/sentence-similarity.php index 40bbd95e..8ee77cc5 100644 --- a/examples/huggingface/sentence-similarity.php +++ b/examples/huggingface/sentence-similarity.php @@ -8,7 +8,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['HUGGINGFACE_KEY'])) { +if (!$_ENV['HUGGINGFACE_KEY']) { echo 'Please set the HUGGINGFACE_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/huggingface/summarization.php b/examples/huggingface/summarization.php index 5266d1f2..717bad9e 100644 --- a/examples/huggingface/summarization.php +++ b/examples/huggingface/summarization.php @@ -8,7 +8,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['HUGGINGFACE_KEY'])) { +if (!$_ENV['HUGGINGFACE_KEY']) { echo 'Please set the HUGGINGFACE_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/huggingface/table-question-answering.php b/examples/huggingface/table-question-answering.php index aa134937..1ca55e04 100644 --- a/examples/huggingface/table-question-answering.php +++ b/examples/huggingface/table-question-answering.php @@ -8,7 +8,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['HUGGINGFACE_KEY'])) { +if (!$_ENV['HUGGINGFACE_KEY']) { echo 'Please set the HUGGINGFACE_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/huggingface/text-classification.php b/examples/huggingface/text-classification.php index 29345190..95d509e1 100644 --- a/examples/huggingface/text-classification.php +++ b/examples/huggingface/text-classification.php @@ -8,7 +8,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['HUGGINGFACE_KEY'])) { +if (!$_ENV['HUGGINGFACE_KEY']) { echo 'Please set the HUGGINGFACE_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/huggingface/text-generation.php b/examples/huggingface/text-generation.php index f2257257..c8eb89fe 100644 --- a/examples/huggingface/text-generation.php +++ b/examples/huggingface/text-generation.php @@ -8,7 +8,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['HUGGINGFACE_KEY'])) { +if (!$_ENV['HUGGINGFACE_KEY']) { echo 'Please set the HUGGINGFACE_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/huggingface/text-to-image.php b/examples/huggingface/text-to-image.php index c30e093c..f53086d1 100644 --- a/examples/huggingface/text-to-image.php +++ b/examples/huggingface/text-to-image.php @@ -9,7 +9,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['HUGGINGFACE_KEY'])) { +if (!$_ENV['HUGGINGFACE_KEY']) { echo 'Please set the HUGGINGFACE_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/huggingface/token-classification.php b/examples/huggingface/token-classification.php index c782a3c5..062d7f96 100644 --- a/examples/huggingface/token-classification.php +++ b/examples/huggingface/token-classification.php @@ -8,7 +8,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['HUGGINGFACE_KEY'])) { +if (!$_ENV['HUGGINGFACE_KEY']) { echo 'Please set the HUGGINGFACE_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/huggingface/translation.php b/examples/huggingface/translation.php index e8a959e8..cb2d76fc 100644 --- a/examples/huggingface/translation.php +++ b/examples/huggingface/translation.php @@ -8,7 +8,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['HUGGINGFACE_KEY'])) { +if (!$_ENV['HUGGINGFACE_KEY']) { echo 'Please set the HUGGINGFACE_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/huggingface/zero-shot-classification.php b/examples/huggingface/zero-shot-classification.php index bfc31c9d..cf3290c4 100644 --- a/examples/huggingface/zero-shot-classification.php +++ b/examples/huggingface/zero-shot-classification.php @@ -8,7 +8,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['HUGGINGFACE_KEY'])) { +if (!$_ENV['HUGGINGFACE_KEY']) { echo 'Please set the HUGGINGFACE_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/mistral/chat.php b/examples/mistral/chat.php index 61fce699..b144c812 100644 --- a/examples/mistral/chat.php +++ b/examples/mistral/chat.php @@ -10,7 +10,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['MISTRAL_API_KEY'])) { +if (!$_ENV['MISTRAL_API_KEY']) { echo 'Please set the REPLICATE_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/mistral/embeddings.php b/examples/mistral/embeddings.php index 13f1eee6..e5f15e0f 100644 --- a/examples/mistral/embeddings.php +++ b/examples/mistral/embeddings.php @@ -8,7 +8,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['MISTRAL_API_KEY'])) { +if (!$_ENV['MISTRAL_API_KEY']) { echo 'Please set the MISTRAL_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/mistral/image.php b/examples/mistral/image.php index 300baee1..d45e9757 100644 --- a/examples/mistral/image.php +++ b/examples/mistral/image.php @@ -11,7 +11,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/mistral/stream.php b/examples/mistral/stream.php index 0778460b..b366c367 100644 --- a/examples/mistral/stream.php +++ b/examples/mistral/stream.php @@ -10,7 +10,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['MISTRAL_API_KEY'])) { +if (!$_ENV['MISTRAL_API_KEY']) { echo 'Please set the REPLICATE_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/mistral/structured-output-math.php b/examples/mistral/structured-output-math.php index 07b43498..c53a06df 100644 --- a/examples/mistral/structured-output-math.php +++ b/examples/mistral/structured-output-math.php @@ -16,7 +16,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['MISTRAL_API_KEY'])) { +if (!$_ENV['MISTRAL_API_KEY']) { echo 'Please set the MISTRAL_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/mistral/toolcall-stream.php b/examples/mistral/toolcall-stream.php index cb7814e8..ad53cf59 100644 --- a/examples/mistral/toolcall-stream.php +++ b/examples/mistral/toolcall-stream.php @@ -14,7 +14,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['MISTRAL_API_KEY'])) { +if (!$_ENV['MISTRAL_API_KEY']) { echo 'Please set the REPLICATE_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/mistral/toolcall.php b/examples/mistral/toolcall.php index 19e493d6..53492428 100644 --- a/examples/mistral/toolcall.php +++ b/examples/mistral/toolcall.php @@ -13,7 +13,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['MISTRAL_API_KEY'])) { +if (!$_ENV['MISTRAL_API_KEY']) { echo 'Please set the REPLICATE_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/ollama/chat-llama.php b/examples/ollama/chat-llama.php index 4df42d13..9ce6f552 100644 --- a/examples/ollama/chat-llama.php +++ b/examples/ollama/chat-llama.php @@ -10,7 +10,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OLLAMA_HOST_URL'])) { +if (!$_ENV['OLLAMA_HOST_URL']) { echo 'Please set the OLLAMA_HOST_URL environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/openai/audio-input.php b/examples/openai/audio-input.php index 572b3128..36ac5c33 100644 --- a/examples/openai/audio-input.php +++ b/examples/openai/audio-input.php @@ -11,7 +11,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/openai/audio-transcript.php b/examples/openai/audio-transcript.php index 3567cab0..1f00bc36 100644 --- a/examples/openai/audio-transcript.php +++ b/examples/openai/audio-transcript.php @@ -8,7 +8,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/openai/chat-o1.php b/examples/openai/chat-o1.php index 79ec0c91..59afcdaf 100644 --- a/examples/openai/chat-o1.php +++ b/examples/openai/chat-o1.php @@ -10,12 +10,12 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } -if (empty($_ENV['RUN_EXPENSIVE_EXAMPLES']) || false === filter_var($_ENV['RUN_EXPENSIVE_EXAMPLES'], \FILTER_VALIDATE_BOOLEAN)) { +if (!$_ENV['RUN_EXPENSIVE_EXAMPLES'] || false === filter_var($_ENV['RUN_EXPENSIVE_EXAMPLES'], \FILTER_VALIDATE_BOOLEAN)) { echo 'This example is marked as expensive and will not run unless RUN_EXPENSIVE_EXAMPLES is set to true.'.\PHP_EOL; exit(134); } diff --git a/examples/openai/chat.php b/examples/openai/chat.php index ae75ecc3..06f33029 100644 --- a/examples/openai/chat.php +++ b/examples/openai/chat.php @@ -10,7 +10,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/openai/embeddings.php b/examples/openai/embeddings.php index b483c94d..162dc082 100644 --- a/examples/openai/embeddings.php +++ b/examples/openai/embeddings.php @@ -8,7 +8,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/openai/image-input-binary.php b/examples/openai/image-input-binary.php index 2ff1aff3..b4408ccb 100644 --- a/examples/openai/image-input-binary.php +++ b/examples/openai/image-input-binary.php @@ -11,7 +11,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/openai/image-input-url.php b/examples/openai/image-input-url.php index d21ff853..9bc02da1 100644 --- a/examples/openai/image-input-url.php +++ b/examples/openai/image-input-url.php @@ -11,7 +11,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/openai/image-output-dall-e-2.php b/examples/openai/image-output-dall-e-2.php index a4ed8005..602aa98b 100644 --- a/examples/openai/image-output-dall-e-2.php +++ b/examples/openai/image-output-dall-e-2.php @@ -7,7 +7,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/openai/image-output-dall-e-3.php b/examples/openai/image-output-dall-e-3.php index c7799d5d..6e34187f 100644 --- a/examples/openai/image-output-dall-e-3.php +++ b/examples/openai/image-output-dall-e-3.php @@ -8,7 +8,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/openai/stream.php b/examples/openai/stream.php index aedcd227..78f2d9a7 100644 --- a/examples/openai/stream.php +++ b/examples/openai/stream.php @@ -10,7 +10,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/openai/structured-output-clock.php b/examples/openai/structured-output-clock.php index 7185b379..603970ea 100644 --- a/examples/openai/structured-output-clock.php +++ b/examples/openai/structured-output-clock.php @@ -15,7 +15,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/openai/structured-output-math.php b/examples/openai/structured-output-math.php index de6e8688..66fd4b44 100644 --- a/examples/openai/structured-output-math.php +++ b/examples/openai/structured-output-math.php @@ -12,7 +12,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/openai/token-metadata.php b/examples/openai/token-metadata.php index 2a365f53..44ea80e0 100644 --- a/examples/openai/token-metadata.php +++ b/examples/openai/token-metadata.php @@ -11,7 +11,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/openai/toolcall-stream.php b/examples/openai/toolcall-stream.php index b8244d18..a148a236 100644 --- a/examples/openai/toolcall-stream.php +++ b/examples/openai/toolcall-stream.php @@ -14,7 +14,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/openai/toolcall.php b/examples/openai/toolcall.php index 87f0c34e..dccff326 100644 --- a/examples/openai/toolcall.php +++ b/examples/openai/toolcall.php @@ -14,7 +14,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/openrouter/chat-gemini.php b/examples/openrouter/chat-gemini.php index 5e28a5f5..efbeb036 100644 --- a/examples/openrouter/chat-gemini.php +++ b/examples/openrouter/chat-gemini.php @@ -10,7 +10,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENROUTER_KEY'])) { +if (!$_ENV['OPENROUTER_KEY']) { echo 'Please set the OPENROUTER_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/parallel-chat-gpt.php b/examples/parallel-chat-gpt.php index 7bbeab50..77fd02e4 100644 --- a/examples/parallel-chat-gpt.php +++ b/examples/parallel-chat-gpt.php @@ -11,7 +11,7 @@ require_once dirname(__DIR__).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/parallel-embeddings.php b/examples/parallel-embeddings.php index eb63539c..08f70149 100644 --- a/examples/parallel-embeddings.php +++ b/examples/parallel-embeddings.php @@ -10,7 +10,7 @@ require_once dirname(__DIR__).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/persistent-chat.php b/examples/persistent-chat.php index 5be7eb34..1705c655 100644 --- a/examples/persistent-chat.php +++ b/examples/persistent-chat.php @@ -12,7 +12,7 @@ require_once dirname(__DIR__).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/replicate/chat-llama.php b/examples/replicate/chat-llama.php index 8173c844..b8a96e18 100644 --- a/examples/replicate/chat-llama.php +++ b/examples/replicate/chat-llama.php @@ -10,7 +10,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['REPLICATE_API_KEY'])) { +if (!$_ENV['REPLICATE_API_KEY']) { echo 'Please set the REPLICATE_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/store/document-vectorizing.php b/examples/store/document-vectorizing.php index 186b1239..2a3525d5 100644 --- a/examples/store/document-vectorizing.php +++ b/examples/store/document-vectorizing.php @@ -13,7 +13,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/store/mariadb-similarity-search-gemini.php b/examples/store/mariadb-similarity-search-gemini.php index 25df7003..8b69711b 100644 --- a/examples/store/mariadb-similarity-search-gemini.php +++ b/examples/store/mariadb-similarity-search-gemini.php @@ -23,7 +23,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['GOOGLE_API_KEY']) || empty($_ENV['MARIADB_URI'])) { +if (!$_ENV['GOOGLE_API_KEY'] || !$_ENV['MARIADB_URI']) { echo 'Please set GOOGLE_API_KEY and MARIADB_URI environment variables.'.\PHP_EOL; exit(1); } diff --git a/examples/store/mariadb-similarity-search.php b/examples/store/mariadb-similarity-search.php index b7e2cc93..46e6f64e 100644 --- a/examples/store/mariadb-similarity-search.php +++ b/examples/store/mariadb-similarity-search.php @@ -22,7 +22,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY']) || empty($_ENV['MARIADB_URI'])) { +if (!$_ENV['OPENAI_API_KEY'] || !$_ENV['MARIADB_URI']) { echo 'Please set OPENAI_API_KEY and MARIADB_URI environment variables.'.\PHP_EOL; exit(1); } diff --git a/examples/store/mongodb-similarity-search.php b/examples/store/mongodb-similarity-search.php index ed009e5e..64c6854d 100644 --- a/examples/store/mongodb-similarity-search.php +++ b/examples/store/mongodb-similarity-search.php @@ -21,7 +21,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY']) || empty($_ENV['MONGODB_URI'])) { +if (!$_ENV['OPENAI_API_KEY'] || !$_ENV['MONGODB_URI']) { echo 'Please set OPENAI_API_KEY and MONGODB_URI environment variables.'.\PHP_EOL; exit(1); } diff --git a/examples/store/pinecone-similarity-search.php b/examples/store/pinecone-similarity-search.php index ad6b0c9c..64fb10da 100644 --- a/examples/store/pinecone-similarity-search.php +++ b/examples/store/pinecone-similarity-search.php @@ -21,7 +21,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY']) || empty($_ENV['PINECONE_API_KEY']) || empty($_ENV['PINECONE_HOST'])) { +if (!$_ENV['OPENAI_API_KEY'] || !$_ENV['PINECONE_API_KEY'] || !$_ENV['PINECONE_HOST']) { echo 'Please set OPENAI_API_KEY, PINECONE_API_KEY and PINECONE_HOST environment variables.'.\PHP_EOL; exit(1); } diff --git a/examples/toolbox/brave.php b/examples/toolbox/brave.php index d971f916..96dc7e3d 100644 --- a/examples/toolbox/brave.php +++ b/examples/toolbox/brave.php @@ -15,7 +15,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY']) || empty($_ENV['BRAVE_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY'] || !$_ENV['BRAVE_API_KEY']) { echo 'Please set the OPENAI_API_KEY and BRAVE_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/toolbox/clock.php b/examples/toolbox/clock.php index 7972c3f2..2217b0a2 100644 --- a/examples/toolbox/clock.php +++ b/examples/toolbox/clock.php @@ -14,7 +14,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/toolbox/serpapi.php b/examples/toolbox/serpapi.php index c5348472..d510f229 100644 --- a/examples/toolbox/serpapi.php +++ b/examples/toolbox/serpapi.php @@ -14,7 +14,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY']) || empty($_ENV['SERP_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY'] || !$_ENV['SERP_API_KEY']) { echo 'Please set the OPENAI_API_KEY and SERP_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/toolbox/tavily.php b/examples/toolbox/tavily.php index e6245f71..d7a080c0 100644 --- a/examples/toolbox/tavily.php +++ b/examples/toolbox/tavily.php @@ -14,7 +14,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY']) || empty($_ENV['TAVILY_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY'] || !$_ENV['TAVILY_API_KEY']) { echo 'Please set the OPENAI_API_KEY and TAVILY_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/toolbox/weather-event.php b/examples/toolbox/weather-event.php index 3b05a49c..aeb9175a 100644 --- a/examples/toolbox/weather-event.php +++ b/examples/toolbox/weather-event.php @@ -17,7 +17,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['OPENAI_API_KEY'])) { +if (!$_ENV['OPENAI_API_KEY']) { echo 'Please set the OPENAI_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/examples/voyage/embeddings.php b/examples/voyage/embeddings.php index 10482bc6..6defc868 100644 --- a/examples/voyage/embeddings.php +++ b/examples/voyage/embeddings.php @@ -8,7 +8,7 @@ require_once dirname(__DIR__, 2).'/vendor/autoload.php'; (new Dotenv())->loadEnv(dirname(__DIR__, 2).'/.env'); -if (empty($_ENV['VOYAGE_API_KEY'])) { +if (!$_ENV['VOYAGE_API_KEY']) { echo 'Please set the VOYAGE_API_KEY environment variable.'.\PHP_EOL; exit(1); } diff --git a/src/Chain/Toolbox/Tool/Wikipedia.php b/src/Chain/Toolbox/Tool/Wikipedia.php index 6b392fe6..6ea9bb80 100644 --- a/src/Chain/Toolbox/Tool/Wikipedia.php +++ b/src/Chain/Toolbox/Tool/Wikipedia.php @@ -34,7 +34,7 @@ public function search(string $query): string $titles = array_map(fn (array $item) => $item['title'], $result['query']['search']); - if (empty($titles)) { + if (!$titles) { return 'No articles were found on Wikipedia.'; } diff --git a/src/Platform/Bridge/Anthropic/Contract/AssistantMessageNormalizer.php b/src/Platform/Bridge/Anthropic/Contract/AssistantMessageNormalizer.php index adbe74fb..298261f8 100644 --- a/src/Platform/Bridge/Anthropic/Contract/AssistantMessageNormalizer.php +++ b/src/Platform/Bridge/Anthropic/Contract/AssistantMessageNormalizer.php @@ -51,7 +51,7 @@ public function normalize(mixed $data, ?string $format = null, array $context = 'type' => 'tool_use', 'id' => $toolCall->id, 'name' => $toolCall->name, - 'input' => empty($toolCall->arguments) ? new \stdClass() : $toolCall->arguments, + 'input' => $toolCall->arguments ?: new \stdClass(), ]; }, $data->toolCalls), ]; diff --git a/src/Platform/Bridge/Anthropic/ResponseConverter.php b/src/Platform/Bridge/Anthropic/ResponseConverter.php index 030159b9..b31b0567 100644 --- a/src/Platform/Bridge/Anthropic/ResponseConverter.php +++ b/src/Platform/Bridge/Anthropic/ResponseConverter.php @@ -48,7 +48,7 @@ public function convert(ResponseInterface $response, array $options = []): LlmRe throw new RuntimeException('Response content does not contain any text nor tool calls.'); } - if (!empty($toolCalls)) { + if ($toolCalls) { return new ToolCallResponse(...$toolCalls); } diff --git a/src/Platform/Bridge/Bedrock/Anthropic/ClaudeHandler.php b/src/Platform/Bridge/Bedrock/Anthropic/ClaudeHandler.php index 3bbe8325..58e01000 100644 --- a/src/Platform/Bridge/Bedrock/Anthropic/ClaudeHandler.php +++ b/src/Platform/Bridge/Bedrock/Anthropic/ClaudeHandler.php @@ -73,7 +73,7 @@ public function convert(InvokeModelResponse $bedrockResponse): LlmResponse $toolCalls[] = new ToolCall($content['id'], $content['name'], $content['input']); } } - if (!empty($toolCalls)) { + if ($toolCalls) { return new ToolCallResponse(...$toolCalls); } diff --git a/src/Platform/Bridge/Bedrock/Nova/Contract/AssistantMessageNormalizer.php b/src/Platform/Bridge/Bedrock/Nova/Contract/AssistantMessageNormalizer.php index 15097f90..06ad7730 100644 --- a/src/Platform/Bridge/Bedrock/Nova/Contract/AssistantMessageNormalizer.php +++ b/src/Platform/Bridge/Bedrock/Nova/Contract/AssistantMessageNormalizer.php @@ -50,7 +50,7 @@ public function normalize(mixed $data, ?string $format = null, array $context = 'toolUse' => [ 'toolUseId' => $toolCall->id, 'name' => $toolCall->name, - 'input' => empty($toolCall->arguments) ? new \stdClass() : $toolCall->arguments, + 'input' => $toolCall->arguments ?: new \stdClass(), ], ]; }, $data->toolCalls), diff --git a/src/Platform/Bridge/Bedrock/Nova/NovaHandler.php b/src/Platform/Bridge/Bedrock/Nova/NovaHandler.php index e099013b..a8c4ce07 100644 --- a/src/Platform/Bridge/Bedrock/Nova/NovaHandler.php +++ b/src/Platform/Bridge/Bedrock/Nova/NovaHandler.php @@ -74,7 +74,7 @@ public function convert(InvokeModelResponse $bedrockResponse): LlmResponse $toolCalls[] = new ToolCall($content['toolUse']['toolUseId'], $content['toolUse']['name'], $content['toolUse']['input']); } } - if (!empty($toolCalls)) { + if ($toolCalls) { return new ToolCallResponse(...$toolCalls); }