From 96f824fb2db3eca4f780ac3dd8638345d4262b30 Mon Sep 17 00:00:00 2001 From: Christopher Hertel Date: Mon, 22 Sep 2025 22:36:12 +0200 Subject: [PATCH] Use imports instead of FQCN inline --- src/agent/tests/ChatTest.php | 5 +++-- src/ai-bundle/src/Command/ChatCommand.php | 3 ++- src/platform/tests/Bridge/Ollama/OllamaClientTest.php | 8 +++++--- src/store/tests/Document/VectorizerTest.php | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/agent/tests/ChatTest.php b/src/agent/tests/ChatTest.php index e5052bc17..3cd403eb8 100644 --- a/src/agent/tests/ChatTest.php +++ b/src/agent/tests/ChatTest.php @@ -14,6 +14,7 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Small; use PHPUnit\Framework\Attributes\UsesClass; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\AI\Agent\AgentInterface; use Symfony\AI\Agent\Chat; @@ -30,8 +31,8 @@ #[Small] final class ChatTest extends TestCase { - private AgentInterface&\PHPUnit\Framework\MockObject\MockObject $agent; - private MessageStoreInterface&\PHPUnit\Framework\MockObject\MockObject $store; + private AgentInterface&MockObject $agent; + private MessageStoreInterface&MockObject $store; private Chat $chat; protected function setUp(): void diff --git a/src/ai-bundle/src/Command/ChatCommand.php b/src/ai-bundle/src/Command/ChatCommand.php index 46a970bdb..a58cb77f7 100644 --- a/src/ai-bundle/src/Command/ChatCommand.php +++ b/src/ai-bundle/src/Command/ChatCommand.php @@ -20,6 +20,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Completion\CompletionInput; use Symfony\Component\Console\Completion\CompletionSuggestions; +use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -96,7 +97,7 @@ protected function interact(InputInterface $input, OutputInterface $output): voi ); $question->setErrorMessage('Agent %s is invalid.'); - /** @var \Symfony\Component\Console\Helper\QuestionHelper $helper */ + /** @var QuestionHelper $helper */ $helper = $this->getHelper('question'); $selectedAgent = $helper->ask($input, $output, $question); diff --git a/src/platform/tests/Bridge/Ollama/OllamaClientTest.php b/src/platform/tests/Bridge/Ollama/OllamaClientTest.php index 02d457f76..0d144030f 100644 --- a/src/platform/tests/Bridge/Ollama/OllamaClientTest.php +++ b/src/platform/tests/Bridge/Ollama/OllamaClientTest.php @@ -16,8 +16,10 @@ use PHPUnit\Framework\TestCase; use Symfony\AI\Platform\Bridge\Ollama\Ollama; use Symfony\AI\Platform\Bridge\Ollama\OllamaClient; +use Symfony\AI\Platform\Bridge\Ollama\OllamaResultConverter; use Symfony\AI\Platform\Bridge\Ollama\PlatformFactory; use Symfony\AI\Platform\Model; +use Symfony\AI\Platform\Result\RawHttpResult; use Symfony\AI\Platform\Result\StreamResult; use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\HttpClient\Response\JsonMockResponse; @@ -153,8 +155,8 @@ public function testStreamingConverterWithDirectResponse() ]); $mockResponse = $mockHttpClient->request('GET', 'http://test.example'); - $rawResult = new \Symfony\AI\Platform\Result\RawHttpResult($mockResponse); - $converter = new \Symfony\AI\Platform\Bridge\Ollama\OllamaResultConverter(); + $rawResult = new RawHttpResult($mockResponse); + $converter = new OllamaResultConverter(); $result = $converter->convert($rawResult, ['stream' => true]); @@ -170,7 +172,7 @@ public function testStreamingConverterWithDirectResponse() ]); $regularMockResponse = $regularMockHttpClient->request('GET', 'http://test.example'); - $regularRawResult = new \Symfony\AI\Platform\Result\RawHttpResult($regularMockResponse); + $regularRawResult = new RawHttpResult($regularMockResponse); $regularResult = $converter->convert($regularRawResult, ['stream' => false]); $this->assertNotInstanceOf(StreamResult::class, $regularResult); diff --git a/src/store/tests/Document/VectorizerTest.php b/src/store/tests/Document/VectorizerTest.php index f253a14ec..a55c81241 100644 --- a/src/store/tests/Document/VectorizerTest.php +++ b/src/store/tests/Document/VectorizerTest.php @@ -33,6 +33,7 @@ use Symfony\AI\Store\Document\TextDocument; use Symfony\AI\Store\Document\VectorDocument; use Symfony\AI\Store\Document\Vectorizer; +use Symfony\AI\Store\Exception\RuntimeException; use Symfony\AI\Store\Tests\Double\PlatformTestHandler; use Symfony\Component\HttpClient\Response\MockResponse; use Symfony\Component\Uid\Uuid; @@ -375,7 +376,7 @@ public function testVectorizeStringThrowsExceptionWhenNoVectorReturned() $vectorizer = new Vectorizer($platform, $model); - $this->expectException(\Symfony\AI\Store\Exception\RuntimeException::class); + $this->expectException(RuntimeException::class); $this->expectExceptionMessage('No vector returned for string vectorization.'); $vectorizer->vectorize($text);