Skip to content

Commit 871db84

Browse files
add return method value types
1 parent 8f0a23c commit 871db84

File tree

21 files changed

+54
-53
lines changed

21 files changed

+54
-53
lines changed

src/bref/src/ConsoleApplicationHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct(Application $application)
2323
$this->application->setAutoExit(false);
2424
}
2525

26-
public function handle($event, Context $context)
26+
public function handle($event, Context $context): array
2727
{
2828
$args = \Clue\Arguments\split((string) $event);
2929
array_unshift($args, 'command');

src/bref/src/Runtime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function getRunner(?object $application): RunnerInterface
4646
}
4747
}
4848

49-
private function tryToFindRunner(?object $application)
49+
private function tryToFindRunner(?object $application): RunnerInterface
5050
{
5151
if ($application instanceof ContainerInterface) {
5252
$handler = explode(':', $_SERVER['_HANDLER']);

src/bref/tests/Lambda/LambdaClientTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ protected function tearDown(): void
3232
ob_end_clean();
3333
}
3434

35-
public function test basic behavior()
35+
public function test basic behavior(): void
3636
{
3737
$this->givenAnEvent(['Hello' => 'world!']);
3838

3939
$output = $this->lambda->processNextEvent(new class implements Handler {
40-
public function handle($event, Context $context)
40+
public function handle($event, Context $context): array
4141
{
4242
return ['hello' => 'world'];
4343
}
@@ -47,12 +47,12 @@ public function handle($event, Context $context)
4747
$this->assertInvocationResult(['hello' => 'world']);
4848
}
4949

50-
public function test handler receives context()
50+
public function test handler receives context(): void
5151
{
5252
$this->givenAnEvent(['Hello' => 'world!']);
5353

5454
$this->lambda->processNextEvent(new class implements Handler {
55-
public function handle($event, Context $context)
55+
public function handle($event, Context $context): array
5656
{
5757
return ['hello' => 'world', 'received-function-arn' => $context->getInvokedFunctionArn()];
5858
}
@@ -64,7 +64,7 @@ public function handle($event, Context $context)
6464
]);
6565
}
6666

67-
public function test exceptions in the handler result in an invocation error()
67+
public function test exceptions in the handler result in an invocation error(): void
6868
{
6969
$this->givenAnEvent(['Hello' => 'world!']);
7070

@@ -80,7 +80,7 @@ public function handle($event, Context $context)
8080
$this->assertErrorInLogs('RuntimeException', 'This is an exception');
8181
}
8282

83-
public function test nested exceptions in the handler result in an invocation error()
83+
public function test nested exceptions in the handler result in an invocation error(): void
8484
{
8585
$this->givenAnEvent(['Hello' => 'world!']);
8686

@@ -99,7 +99,7 @@ public function handle($event, Context $context)
9999
]);
100100
}
101101

102-
public function test an error is thrown if the runtime API returns a wrong response()
102+
public function test an error is thrown if the runtime API returns a wrong response(): void
103103
{
104104
$this->expectExceptionMessage('Failed to fetch next Lambda invocation: The requested URL returned error: 404');
105105
Server::enqueue([
@@ -119,7 +119,7 @@ public function handle($event, Context $context)
119119
});
120120
}
121121

122-
public function test an error is thrown if the invocation id is missing()
122+
public function test an error is thrown if the invocation id is missing(): void
123123
{
124124
$this->expectExceptionMessage('Failed to determine the Lambda invocation ID');
125125
Server::enqueue([
@@ -137,7 +137,7 @@ public function handle($event, Context $context)
137137
});
138138
}
139139

140-
public function test an error is thrown if the invocation body is empty()
140+
public function test an error is thrown if the invocation body is empty(): void
141141
{
142142
$this->expectExceptionMessage('Empty Lambda runtime API response');
143143
Server::enqueue([
@@ -156,7 +156,7 @@ public function handle($event, Context $context)
156156
});
157157
}
158158

159-
public function test a wrong response from the runtime API turns the invocation into an error()
159+
public function test a wrong response from the runtime API turns the invocation into an error(): void
160160
{
161161
Server::enqueue([
162162
new Response( // lambda event
@@ -194,12 +194,12 @@ public function handle($event, Context $context)
194194
$this->assertErrorInLogs('Exception', 'Error while calling the Lambda runtime API: The requested URL returned error: 400');
195195
}
196196

197-
public function test function results that cannot be encoded are reported as invocation errors()
197+
public function test function results that cannot be encoded are reported as invocation errors(): void
198198
{
199199
$this->givenAnEvent(['hello' => 'world!']);
200200

201201
$this->lambda->processNextEvent(new class implements Handler {
202-
public function handle($event, Context $context)
202+
public function handle($event, Context $context): string
203203
{
204204
return "\xB1\x31";
205205
}
@@ -214,7 +214,7 @@ public function handle($event, Context $context)
214214
$this->assertErrorInLogs('Exception', $message);
215215
}
216216

217-
public function test generic event handler()
217+
public function test generic event handler(): void
218218
{
219219
$handler = new class implements Handler {
220220
public function handle($event, Context $context)
@@ -245,7 +245,7 @@ private function givenAnEvent($event): void
245245
]);
246246
}
247247

248-
private function assertInvocationResult($result)
248+
private function assertInvocationResult($result): void
249249
{
250250
$requests = Server::received();
251251
$this->assertCount(2, $requests);
@@ -258,7 +258,7 @@ private function assertInvocationResult($result)
258258
$this->assertEquals($result, json_decode($eventResponse->getBody()->__toString(), true));
259259
}
260260

261-
private function assertInvocationErrorResult(string $errorClass, string $errorMessage)
261+
private function assertInvocationErrorResult(string $errorClass, string $errorMessage): void
262262
{
263263
$requests = Server::received();
264264
$this->assertCount(2, $requests);
@@ -305,7 +305,7 @@ private function assertErrorInLogs(string $errorClass, string $errorMessage): vo
305305
$this->assertIsArray($invocationResult['stack']);
306306
}
307307

308-
private function assertPreviousErrorsInLogs(array $previousErrors)
308+
private function assertPreviousErrorsInLogs(array $previousErrors): void
309309
{
310310
// Decode the logs from stdout
311311
$stdout = $this->getActualOutput();

src/bref/tests/SymfonyRequestBridgeTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class SymfonyRequestBridgeTest extends TestCase
1313
{
14-
public function testClientIpFromForwardedFor()
14+
public function testClientIpFromForwardedFor(): void
1515
{
1616
$request = SymfonyRequestBridge::convertRequest(new HttpRequestEvent([
1717
'requestContext' => ['http' => ['method' => 'GET']],
@@ -23,7 +23,7 @@ public function testClientIpFromForwardedFor()
2323
/**
2424
* Raw content should only exist when there is no multipart content.
2525
*/
26-
public function testRawContent()
26+
public function testRawContent(): void
2727
{
2828
// No content type
2929
$request = SymfonyRequestBridge::convertRequest(new HttpRequestEvent([
@@ -67,7 +67,7 @@ public function testRawContent()
6767
$this->assertSame('', $request->getContent());
6868
}
6969

70-
public function testUploadedFile()
70+
public function testUploadedFile(): void
7171
{
7272
$request = SymfonyRequestBridge::convertRequest(new HttpRequestEvent([
7373
'requestContext' => ['http' => ['method' => 'POST']],
@@ -107,7 +107,7 @@ public function testUploadedFile()
107107
$this->assertSame('bar', $post['foo']);
108108
}
109109

110-
public function testEmptyUploadedFile()
110+
public function testEmptyUploadedFile(): void
111111
{
112112
$request = SymfonyRequestBridge::convertRequest(new HttpRequestEvent([
113113
'requestContext' => ['http' => ['method' => 'POST']],
@@ -136,7 +136,7 @@ public function testEmptyUploadedFile()
136136
$this->assertSame('bar', $post['foo']);
137137
}
138138

139-
public function testLambdaContext()
139+
public function testLambdaContext(): void
140140
{
141141
$requestContext = ['http' => ['method' => 'GET']];
142142
$request = SymfonyRequestBridge::convertRequest(new HttpRequestEvent([
@@ -149,7 +149,7 @@ public function testLambdaContext()
149149
$this->assertSame(json_encode($requestContext), $request->server->get('LAMBDA_REQUEST_CONTEXT'));
150150
}
151151

152-
private function getContext()
152+
private function getContext(): Context
153153
{
154154
// this is set in LaravelHttpHandler and SymfonyHttpHandler to allow overwrite of this value
155155
Request::setTrustedProxies(['127.0.0.1'], Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO);

src/google-cloud/google/CloudEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function getData()
8181
return $this->data;
8282
}
8383

84-
public static function fromArray(array $arr)
84+
public static function fromArray(array $arr): static
8585
{
8686
$args = [];
8787
$argKeys = [

src/google-cloud/google/Context.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function getResourceName(): ?string
5454
return $this->resource['name'] ?? null;
5555
}
5656

57-
public static function fromArray(array $arr)
57+
public static function fromArray(array $arr): static
5858
{
5959
// When "resource" is defined in the root (instead of in "context") it
6060
// is a string representing the resource name

src/google-cloud/src/Runtime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ protected function createCloudEvent(): ?CloudEvent
9090
}
9191
}
9292

93-
protected function sendHttpResponseAndExit(int $status, string $body, array $headers)
93+
protected function sendHttpResponseAndExit(int $status, string $body, array $headers): void
9494
{
9595
error_log($body);
9696
header('HTTP/1.1 '.$status);

src/google-cloud/tests/google/CloudEventTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727
class CloudEventTest extends TestCase
2828
{
29-
public function testJsonSerialize()
29+
public function testJsonSerialize(): void
3030
{
3131
$event = new CloudEvent(
3232
'1413058901901494',

src/google-cloud/tests/google/ContextTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727
class ContextTest extends TestCase
2828
{
29-
public function testFromArray()
29+
public function testFromArray(): void
3030
{
3131
$context = Context::fromArray([
3232
'eventId' => 'abc',
@@ -45,7 +45,7 @@ public function testFromArray()
4545
$this->assertEquals('mno', $context->getService());
4646
}
4747

48-
public function testFromEmptyArray()
48+
public function testFromEmptyArray(): void
4949
{
5050
$context = Context::fromArray([]);
5151
$this->assertEquals(null, $context->getEventId());

src/google-cloud/tests/google/LegacyEventMapperTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727
class LegacyEventMapperTest extends TestCase
2828
{
29-
public function testWithContextProperty()
29+
public function testWithContextProperty(): void
3030
{
3131
$mapper = new LegacyEventMapper();
3232
$jsonData = [
@@ -61,7 +61,7 @@ public function testWithContextProperty()
6161
$this->assertEquals(['message' => 'foo'], $cloudevent->getData());
6262
}
6363

64-
public function testWithoutContextProperty()
64+
public function testWithoutContextProperty(): void
6565
{
6666
$mapper = new LegacyEventMapper();
6767
$jsonData = [
@@ -95,7 +95,7 @@ public function testWithoutContextProperty()
9595
$this->assertEquals(['message' => 'foo'], $cloudevent->getData());
9696
}
9797

98-
public function testResourceAsString()
98+
public function testResourceAsString(): void
9999
{
100100
$mapper = new LegacyEventMapper();
101101
$jsonData = [
@@ -126,7 +126,7 @@ public function testResourceAsString()
126126
$this->assertEquals(['message' => 'foo'], $cloudevent->getData());
127127
}
128128

129-
public function testCloudStorage()
129+
public function testCloudStorage(): void
130130
{
131131
$mapper = new LegacyEventMapper();
132132
$jsonData = [
@@ -163,7 +163,7 @@ public function testCloudStorage()
163163
$this->assertEquals('foo', $cloudevent->getData());
164164
}
165165

166-
public function testFirebaseAuth()
166+
public function testFirebaseAuth(): void
167167
{
168168
$mapper = new LegacyEventMapper();
169169
$jsonData = [

0 commit comments

Comments
 (0)