Use phpstan/phpstan-phpunit

This commit is contained in:
Vincent Langlet
2025-12-21 21:11:29 +01:00
committed by Oskar Stark
parent 5fde2b9ee5
commit cf536a33f3
4 changed files with 18 additions and 2 deletions

View File

@@ -46,6 +46,9 @@ final class AssistantMessageNormalizerTest extends TestCase
$this->assertSame([AssistantMessage::class => true], $this->normalizer->getSupportedTypes(null));
}
/**
* @param array{role: Role::Assistant, content: string, tool_calls: list<array{type: 'function', function: array{name: string, arguments: array<string, mixed>}}>} $expectedOutput
*/
#[DataProvider('normalizeDataProvider')]
public function testNormalize(AssistantMessage $message, array $expectedOutput)
{

View File

@@ -217,6 +217,9 @@ final class OllamaResultConverterTest extends TestCase
$this->assertArrayHasKey('total_duration', $chunks->current()->raw);
}
/**
* @return iterable<array<string, mixed>>
*/
private function generateConvertStreamingStream(): iterable
{
yield ['model' => 'deepseek-r1:latest', 'created_at' => '2025-10-29T17:15:49.631700779Z', 'message' => ['role' => 'assistant', 'content' => 'Hello'], 'done' => false];
@@ -224,6 +227,9 @@ final class OllamaResultConverterTest extends TestCase
'done_reason' => 'stop', 'total_duration' => 100, 'load_duration' => 10, 'prompt_eval_count' => 42, 'prompt_eval_duration' => 30, 'eval_count' => 17, 'eval_duration' => 60];
}
/**
* @return iterable<array<string, mixed>>
*/
private function generateConvertThinkingStreamingStream(): iterable
{
yield ['model' => 'deepseek-r1:latest', 'created_at' => '2025-10-29T17:15:49.631700779Z', 'message' => ['role' => 'assistant', 'content' => '', 'thinking' => 'Thinking'], 'done' => false];

View File

@@ -31,6 +31,7 @@
},
"require-dev": {
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^11.5.46"
},

View File

@@ -1,4 +1,5 @@
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- ../../../../../.phpstan/extension.neon
parameters:
@@ -14,10 +15,15 @@ parameters:
message: "#^Method .*::test.*\\(\\) has no return type specified\\.$#"
reportUnmatched: false
-
identifier: missingType.iterableValue
path: Tests/*
message: '#^Call to( static)? method PHPUnit\\Framework\\Assert::.* will always evaluate to true\.$#'
reportUnmatched: false
-
identifier: 'symfonyAi.forbidNativeException'
path: Tests/*
reportUnmatched: false
services:
- # Conditionally enabled by bleeding edge in phpstan/phpstan-phpunit 2.x
class: PHPStan\Type\PHPUnit\DataProviderReturnTypeIgnoreExtension
tags:
- phpstan.ignoreErrorExtension