From 61fc44b74c9810b9554177c9b7d9e342a7931c68 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Wed, 24 Sep 2025 07:05:00 +0200 Subject: [PATCH] [Agent] Replace string concatenation with sprintf in exception messages --- src/agent/tests/AgentTest.php | 4 ++-- .../tests/InputProcessor/ModelOverrideInputProcessorTest.php | 2 +- src/agent/tests/Toolbox/ToolboxTest.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/agent/tests/AgentTest.php b/src/agent/tests/AgentTest.php index c507d94b8..052599f7d 100644 --- a/src/agent/tests/AgentTest.php +++ b/src/agent/tests/AgentTest.php @@ -92,7 +92,7 @@ public function testConstructorThrowsExceptionForInvalidInputProcessor() $invalidProcessor = new \stdClass(); $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Processor "stdClass" must implement "'.InputProcessorInterface::class.'".'); + $this->expectExceptionMessage(\sprintf('Processor "stdClass" must implement "%s".', InputProcessorInterface::class)); /* @phpstan-ignore-next-line */ new Agent($platform, $model, [$invalidProcessor]); @@ -105,7 +105,7 @@ public function testConstructorThrowsExceptionForInvalidOutputProcessor() $invalidProcessor = new \stdClass(); $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Processor "stdClass" must implement "'.OutputProcessorInterface::class.'".'); + $this->expectExceptionMessage(\sprintf('Processor "stdClass" must implement "%s".', OutputProcessorInterface::class)); /* @phpstan-ignore-next-line */ new Agent($platform, $model, [], [$invalidProcessor]); diff --git a/src/agent/tests/InputProcessor/ModelOverrideInputProcessorTest.php b/src/agent/tests/InputProcessor/ModelOverrideInputProcessorTest.php index 4ab9b1709..b6b741316 100644 --- a/src/agent/tests/InputProcessor/ModelOverrideInputProcessorTest.php +++ b/src/agent/tests/InputProcessor/ModelOverrideInputProcessorTest.php @@ -48,7 +48,7 @@ public function testProcessInputWithoutModelOption() public function testProcessInputWithInvalidModelOption() { $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Option "model" must be an instance of "'.Model::class.'".'); + $this->expectExceptionMessage(\sprintf('Option "model" must be an instance of "%s".', Model::class)); $gpt = new Gpt(Gpt::GPT_4O); $model = new MessageBag(); diff --git a/src/agent/tests/Toolbox/ToolboxTest.php b/src/agent/tests/Toolbox/ToolboxTest.php index d50f641d9..0a4d0ada2 100644 --- a/src/agent/tests/Toolbox/ToolboxTest.php +++ b/src/agent/tests/Toolbox/ToolboxTest.php @@ -154,7 +154,7 @@ public function testExecuteWithUnknownTool() public function testExecuteWithMisconfiguredTool() { $this->expectException(ToolConfigurationException::class); - $this->expectExceptionMessage('Method "foo" not found in tool "'.ToolMisconfigured::class.'".'); + $this->expectExceptionMessage(\sprintf('Method "foo" not found in tool "%s".', ToolMisconfigured::class)); $toolbox = new Toolbox([new ToolMisconfigured()], new ReflectionToolFactory());