Skip to content

Commit 0ab6618

Browse files
authored
chore: format against modern pint defaults (#750)
1 parent 6a5456d commit 0ab6618

25 files changed

+92
-73
lines changed

src/Responses/Audio/SpeechStreamResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static function fake(?string $content = null, ?MetaInformation $meta = nu
4141
$response = $psr17Factory->createResponse()
4242
->withBody($psr17Factory->createStream($content ?? (string) file_get_contents(__DIR__.'/../../Testing/Responses/Fixtures/Audio/speech-streamed.mp3')));
4343

44-
if ($meta instanceof \OpenAI\Responses\Meta\MetaInformation) {
44+
if ($meta instanceof MetaInformation) {
4545
foreach ($meta->toArray() as $key => $value) {
4646
if (is_scalar($value)) {
4747
$response = $response->withHeader($key, (string) $value);

src/Responses/Batches/BatchResponseErrors.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static function from(array $attributes): self
3535
return new self(
3636
$attributes['object'],
3737
array_map(
38-
fn (array $data): \OpenAI\Responses\Batches\BatchResponseErrorsData => BatchResponseErrorsData::from($data),
38+
fn (array $data): BatchResponseErrorsData => BatchResponseErrorsData::from($data),
3939
$attributes['data']
4040
)
4141
);

src/Responses/Threads/Messages/Delta/ThreadMessageDeltaResponseContentText.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class ThreadMessageDeltaResponseContentText implements ResponseContract
2323
use Fakeable;
2424

2525
/**
26-
* @param \OpenAI\Responses\Threads\Messages\ThreadMessageResponseContentTextAnnotationFilePathObject[]|\OpenAI\Responses\Threads\Messages\ThreadMessageResponseContentTextAnnotationFileCitationObject[] $annotations
26+
* @param ThreadMessageResponseContentTextAnnotationFilePathObject[]|ThreadMessageResponseContentTextAnnotationFileCitationObject[] $annotations
2727
*/
2828
private function __construct(
2929
public ?string $value,

src/Responses/Threads/Runs/Steps/ThreadRunStepResponseCodeInterpreter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class ThreadRunStepResponseCodeInterpreter implements ResponseContract
2121
use Fakeable;
2222

2323
/**
24-
* @param \OpenAI\Responses\Threads\Runs\Steps\ThreadRunStepResponseCodeInterpreterOutputLogs[]|\OpenAI\Responses\Threads\Runs\Steps\ThreadRunStepResponseCodeInterpreterOutputImage[]|null $outputs
24+
* @param ThreadRunStepResponseCodeInterpreterOutputLogs[]|ThreadRunStepResponseCodeInterpreterOutputImage[]|null $outputs
2525
*/
2626
private function __construct(
2727
public ?string $input,
@@ -36,7 +36,7 @@ private function __construct(
3636
public static function from(array $attributes): self
3737
{
3838
$outputs = array_map(
39-
fn (array $output): \OpenAI\Responses\Threads\Runs\Steps\ThreadRunStepResponseCodeInterpreterOutputImage|\OpenAI\Responses\Threads\Runs\Steps\ThreadRunStepResponseCodeInterpreterOutputLogs => match ($output['type']) {
39+
fn (array $output): ThreadRunStepResponseCodeInterpreterOutputImage|\OpenAI\Responses\Threads\Runs\Steps\ThreadRunStepResponseCodeInterpreterOutputLogs => match ($output['type']) {
4040
'image' => ThreadRunStepResponseCodeInterpreterOutputImage::from($output),
4141
'logs' => ThreadRunStepResponseCodeInterpreterOutputLogs::from($output),
4242
},

src/Responses/Threads/Runs/ThreadRunResponseToolChoice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function toArray(): array
4747
'type' => $this->type,
4848
];
4949

50-
if ($this->function instanceof \OpenAI\Responses\Threads\Runs\ThreadRunResponseToolChoiceFunction) {
50+
if ($this->function instanceof ThreadRunResponseToolChoiceFunction) {
5151
$response['function'] = $this->function->toArray();
5252
}
5353

src/Transporters/HttpTransporter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function requestObject(Payload $payload): Response
5858
{
5959
$request = $payload->toRequest($this->baseUri, $this->headers, $this->queryParams);
6060

61-
$response = $this->sendRequest(fn (): \Psr\Http\Message\ResponseInterface => $this->client->sendRequest($request));
61+
$response = $this->sendRequest(fn (): ResponseInterface => $this->client->sendRequest($request));
6262

6363
$contents = (string) $response->getBody();
6464

@@ -82,7 +82,7 @@ public function requestStringOrObject(Payload $payload): AdaptableResponse
8282
{
8383
$request = $payload->toRequest($this->baseUri, $this->headers, $this->queryParams);
8484

85-
$response = $this->sendRequest(fn (): \Psr\Http\Message\ResponseInterface => $this->client->sendRequest($request));
85+
$response = $this->sendRequest(fn (): ResponseInterface => $this->client->sendRequest($request));
8686

8787
$contents = (string) $response->getBody();
8888

@@ -110,7 +110,7 @@ public function requestContent(Payload $payload): string
110110
{
111111
$request = $payload->toRequest($this->baseUri, $this->headers, $this->queryParams);
112112

113-
$response = $this->sendRequest(fn (): \Psr\Http\Message\ResponseInterface => $this->client->sendRequest($request));
113+
$response = $this->sendRequest(fn (): ResponseInterface => $this->client->sendRequest($request));
114114

115115
$contents = (string) $response->getBody();
116116

tests/Resources/Batches.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use OpenAI\Responses\Batches\BatchListResponse;
44
use OpenAI\Responses\Batches\BatchResponse;
5+
use OpenAI\Responses\Batches\BatchResponseRequestCounts;
56
use OpenAI\Responses\Meta\MetaInformation;
67
use OpenAI\ValueObjects\Transporter\Response;
78

@@ -44,7 +45,7 @@
4445
->errors->toBeNull()
4546
->status->toBe('completed')
4647
->completionWindow->toBe('24h')
47-
->requestCounts->toBeInstanceOf(\OpenAI\Responses\Batches\BatchResponseRequestCounts::class)
48+
->requestCounts->toBeInstanceOf(BatchResponseRequestCounts::class)
4849
->requestCounts->total->toBe(100)
4950
->metadata->toBeArray()->toHaveCount(2);
5051

@@ -65,7 +66,7 @@
6566
->errors->toBeNull()
6667
->status->toBe('completed')
6768
->completionWindow->toBe('24h')
68-
->requestCounts->toBeInstanceOf(\OpenAI\Responses\Batches\BatchResponseRequestCounts::class)
69+
->requestCounts->toBeInstanceOf(BatchResponseRequestCounts::class)
6970
->requestCounts->total->toBe(100)
7071
->metadata->toBeArray()->toHaveCount(2);
7172

@@ -86,7 +87,7 @@
8687
->errors->toBeNull()
8788
->status->toBe('completed')
8889
->completionWindow->toBe('24h')
89-
->requestCounts->toBeInstanceOf(\OpenAI\Responses\Batches\BatchResponseRequestCounts::class)
90+
->requestCounts->toBeInstanceOf(BatchResponseRequestCounts::class)
9091
->requestCounts->total->toBe(100)
9192
->metadata->toBeArray()->toHaveCount(2);
9293

tests/Resources/Chat.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
use GuzzleHttp\Psr7\Response;
44
use GuzzleHttp\Psr7\Stream;
5+
use OpenAI\Exceptions\ErrorException;
6+
use OpenAI\Exceptions\InvalidArgumentException;
57
use OpenAI\Responses\Chat\CreateResponse;
68
use OpenAI\Responses\Chat\CreateResponseChoice;
79
use OpenAI\Responses\Chat\CreateResponseUsage;
@@ -14,7 +16,7 @@
1416
$client = mockClient('POST', 'chat/completions', [
1517
'model' => 'gpt-3.5-turbo',
1618
'messages' => ['role' => 'user', 'content' => 'Hello!'],
17-
], \OpenAI\ValueObjects\Transporter\Response::from(chatCompletion(), metaHeaders()));
19+
], OpenAI\ValueObjects\Transporter\Response::from(chatCompletion(), metaHeaders()));
1820

1921
$result = $client->chat()->create([
2022
'model' => 'gpt-3.5-turbo',
@@ -53,7 +55,7 @@
5355
'messages' => ['role' => 'user', 'content' => 'Hello!'],
5456
'stream' => true,
5557
]);
56-
})->throws(OpenAI\Exceptions\InvalidArgumentException::class, 'Stream option is not supported. Please use the createStreamed() method instead.');
58+
})->throws(InvalidArgumentException::class, 'Stream option is not supported. Please use the createStreamed() method instead.');
5759

5860
test('create streamed', function () {
5961
$response = new Response(
@@ -168,7 +170,7 @@
168170
]);
169171

170172
expect(fn () => $result->getIterator()->current())
171-
->toThrow(function (OpenAI\Exceptions\ErrorException $e) {
173+
->toThrow(function (ErrorException $e) {
172174
expect($e->getMessage())->toBe('The server had an error while processing your request. Sorry about that!')
173175
->and($e->getErrorMessage())->toBe('The server had an error while processing your request. Sorry about that!')
174176
->and($e->getErrorCode())->toBeNull()

tests/Resources/Completions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
$client = mockClient('POST', 'completions', [
1515
'model' => 'da-vince',
1616
'prompt' => 'hi',
17-
], \OpenAI\ValueObjects\Transporter\Response::from(completion(), metaHeaders()));
17+
], OpenAI\ValueObjects\Transporter\Response::from(completion(), metaHeaders()));
1818

1919
$result = $client->completions()->create([
2020
'model' => 'da-vince',

tests/Resources/Containers.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
use OpenAI\Responses\Containers\Objects\ExpiresAfter;
77
use OpenAI\Responses\Containers\RetrieveContainer;
88
use OpenAI\Responses\Meta\MetaInformation;
9+
use OpenAI\ValueObjects\Transporter\Response;
910

1011
test('create', function () {
1112
$client = mockClient('POST', 'containers', [
1213
'name' => 'Test Container',
13-
], \OpenAI\ValueObjects\Transporter\Response::from(createContainerResource(), metaHeaders()));
14+
], Response::from(createContainerResource(), metaHeaders()));
1415

1516
$result = $client->containers()->create([
1617
'name' => 'Test Container',
@@ -36,7 +37,7 @@
3637

3738
test('retrieve', function () {
3839
$client = mockClient('GET', 'containers/container_abc123', [],
39-
\OpenAI\ValueObjects\Transporter\Response::from(retrieveContainerResource(), metaHeaders()));
40+
Response::from(retrieveContainerResource(), metaHeaders()));
4041

4142
$result = $client->containers()->retrieve('container_abc123');
4243

@@ -60,7 +61,7 @@
6061

6162
test('delete', function () {
6263
$client = mockClient('DELETE', 'containers/container_abc123', [],
63-
\OpenAI\ValueObjects\Transporter\Response::from(deleteContainerResource(), metaHeaders()));
64+
Response::from(deleteContainerResource(), metaHeaders()));
6465

6566
$result = $client->containers()->delete('container_abc123');
6667

@@ -76,7 +77,7 @@
7677

7778
test('list', function () {
7879
$client = mockClient('GET', 'containers', [],
79-
\OpenAI\ValueObjects\Transporter\Response::from(listContainersResource(), metaHeaders()));
80+
Response::from(listContainersResource(), metaHeaders()));
8081

8182
$result = $client->containers()->list();
8283

@@ -104,7 +105,7 @@
104105

105106
test('list with parameters', function () {
106107
$client = mockClient('GET', 'containers', ['limit' => 2],
107-
\OpenAI\ValueObjects\Transporter\Response::from(listContainersResource(), metaHeaders()));
108+
Response::from(listContainersResource(), metaHeaders()));
108109

109110
$result = $client->containers()->list([
110111
'limit' => 2,

0 commit comments

Comments
 (0)