Skip to content

Commit 9a2845f

Browse files
committed
bug #1177 [AI Bundle] Fix PHPDoc type for collected platform call data (camilleislasse)
This PR was merged into the main branch. Discussion ---------- [AI Bundle] Fix PHPDoc type for collected platform call data | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Docs? | no | Issues | - | License | MIT This PR fixes the PHPDoc type for `DataCollector::getPlatformCalls()`. ## Problem The `PlatformCallData` type (defined in `TraceablePlatform`) declares `result: DeferredResult`. However, after `DataCollector::lateCollect()` processes the data through `awaitCallResults()`, the `result` field is transformed to `string|iterable|object|null` and a `metadata` field is added. This causes PHPStan errors when testing code that accesses the transformed data (e.g., `assertNull($dataCollector->getPlatformCalls()[0]['result'])`). ## Solution Introduce a new PHPDoc type `CollectedPlatformCallData` that accurately describes the data returned by `getPlatformCalls()` after transformation: ```php `@phpstan`-type CollectedPlatformCallData array{ model: string, input: array<mixed>|string|object, options: array<string, mixed>, result: string|iterable<mixed>|object|null, metadata: Metadata, } ``` Commits ------- 78243f1 Fix PHPDoc type for collected platform call data
2 parents 03ab03c + 78243f1 commit 9a2845f

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/ai-bundle/src/Profiler/DataCollector.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@
2525
* @phpstan-import-type PlatformCallData from TraceablePlatform
2626
* @phpstan-import-type MessageStoreData from TraceableMessageStore
2727
* @phpstan-import-type ChatData from TraceableChat
28+
*
29+
* @phpstan-type CollectedPlatformCallData array{
30+
* model: string,
31+
* input: array<mixed>|string|object,
32+
* options: array<string, mixed>,
33+
* result: string|iterable<mixed>|object|null,
34+
* metadata: Metadata,
35+
* }
2836
*/
2937
final class DataCollector extends AbstractDataCollector implements LateDataCollectorInterface
3038
{
@@ -88,7 +96,7 @@ public static function getTemplate(): string
8896
}
8997

9098
/**
91-
* @return PlatformCallData[]
99+
* @return CollectedPlatformCallData[]
92100
*/
93101
public function getPlatformCalls(): array
94102
{
@@ -136,13 +144,7 @@ private function getAllTools(): array
136144
}
137145

138146
/**
139-
* @return array{
140-
* model: string,
141-
* input: array<mixed>|string|object,
142-
* options: array<string, mixed>,
143-
* result: string|iterable<mixed>|object|null,
144-
* metadata: Metadata,
145-
* }[]
147+
* @return CollectedPlatformCallData[]
146148
*/
147149
private function awaitCallResults(TraceablePlatform $platform): array
148150
{

0 commit comments

Comments
 (0)