Skip to content

Commit 8f0a23c

Browse files
add typehint to every properties
1 parent f00cf6c commit 8f0a23c

33 files changed

+77
-169
lines changed

src/bref/bref/Context.php

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,14 @@
1111
*/
1212
final class Context implements \JsonSerializable
1313
{
14-
/** @var string */
15-
private $awsRequestId;
16-
17-
/** @var int Holds the deadline Unix timestamp in millis */
18-
private $deadlineMs;
19-
20-
/** @var string */
21-
private $invokedFunctionArn;
22-
23-
/** @var string */
24-
private $traceId;
25-
26-
public function __construct(string $awsRequestId, int $deadlineMs, string $invokedFunctionArn, string $traceId)
14+
public function __construct(
15+
private string $awsRequestId,
16+
/** @var int Holds the deadline Unix timestamp in millis */
17+
private int $deadlineMs,
18+
private string $invokedFunctionArn,
19+
private string $traceId
20+
)
2721
{
28-
$this->awsRequestId = $awsRequestId;
29-
$this->deadlineMs = $deadlineMs;
30-
$this->invokedFunctionArn = $invokedFunctionArn;
31-
$this->traceId = $traceId;
3222
}
3323

3424
/**

src/bref/src/BrefRunner.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,8 @@
1313
*/
1414
class BrefRunner implements RunnerInterface
1515
{
16-
private $handler;
17-
private $loopMax;
18-
19-
public function __construct(Handler $handler, int $loopMax)
16+
public function __construct(private Handler $handler, private int $loopMax)
2017
{
21-
$this->handler = $handler;
22-
$this->loopMax = $loopMax;
2318
}
2419

2520
public function run(): int

src/bref/src/ConsoleApplicationHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
class ConsoleApplicationHandler implements Handler
1717
{
18-
private $application;
18+
private Application $application;
1919

2020
public function __construct(Application $application)
2121
{

src/bref/src/ConsoleApplicationRunner.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@
1313
*/
1414
class ConsoleApplicationRunner implements RunnerInterface
1515
{
16-
private $handler;
17-
private $loopMax;
16+
private ConsoleApplicationHandler $handler;
1817

19-
public function __construct(Application $application, int $loopMax = 1)
18+
public function __construct(Application $application, private int $loopMax = 1)
2019
{
2120
$this->handler = new ConsoleApplicationHandler($application);
22-
$this->loopMax = $loopMax;
2321
}
2422

2523
public function run(): int

src/bref/src/Lambda/ContextBuilder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
final class ContextBuilder
1111
{
1212
/** @var string */
13-
private $awsRequestId;
13+
private string $awsRequestId;
1414

1515
/** @var int */
16-
private $deadlineMs;
16+
private int $deadlineMs;
1717

1818
/** @var string */
19-
private $invokedFunctionArn;
19+
private string $invokedFunctionArn;
2020

2121
/** @var string */
22-
private $traceId;
22+
private string $traceId;
2323

2424
public function __construct()
2525
{

src/bref/src/Lambda/LambdaClient.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,20 @@ final class LambdaClient
3838
private $returnHandler;
3939

4040
/** @var string */
41-
private $apiUrl;
42-
43-
/** @var string */
44-
private $layer;
41+
private string $apiUrl;
4542

4643
public static function fromEnvironmentVariable(string $layer): self
4744
{
4845
return new self((string) getenv('AWS_LAMBDA_RUNTIME_API'), $layer);
4946
}
5047

51-
public function __construct(string $apiUrl, string $layer)
48+
public function __construct(string $apiUrl, private string $layer)
5249
{
5350
if ('' === $apiUrl) {
5451
exit('At the moment lambdas can only be executed in an Lambda environment');
5552
}
5653

5754
$this->apiUrl = $apiUrl;
58-
$this->layer = $layer;
5955
}
6056

6157
public function __destruct()

src/bref/src/LaravelHttpHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
class LaravelHttpHandler extends HttpHandler
1818
{
19-
private $kernel;
19+
private Kernel $kernel;
2020

2121
public function __construct(Kernel $kernel)
2222
{

src/bref/src/LocalRunner.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,8 @@
1313
*/
1414
class LocalRunner implements RunnerInterface
1515
{
16-
private $handler;
17-
private $data;
18-
19-
public function __construct(Handler $handler, $data)
16+
public function __construct(private Handler $handler, private mixed $data)
2017
{
21-
$this->handler = $handler;
22-
$this->data = $data;
2318
}
2419

2520
public function run(): int

src/bref/src/SymfonyHttpHandler.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,8 @@
1717
*/
1818
class SymfonyHttpHandler extends HttpHandler
1919
{
20-
private $kernel;
21-
22-
public function __construct(HttpKernelInterface $kernel)
20+
public function __construct(private HttpKernelInterface $kernel)
2321
{
24-
$this->kernel = $kernel;
25-
2622
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);
2723
}
2824

src/bref/tests/Lambda/LambdaClientTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
class LambdaClientTest extends TestCase
1818
{
1919
/** @var LambdaClient */
20-
private $lambda;
20+
private LambdaClient $lambda;
2121

2222
protected function setUp(): void
2323
{

src/google-cloud/google/CloudEvent.php

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,39 +20,20 @@
2020

2121
class CloudEvent implements \JsonSerializable
2222
{
23-
// Required Fields
24-
private $id;
25-
private $source;
26-
private $specversion;
27-
private $type;
28-
29-
// Optional Fields
30-
private $datacontenttype;
31-
private $dataschema;
32-
private $subject;
33-
private $time;
34-
private $data;
35-
3623
final public function __construct(
37-
string $id,
38-
string $source,
39-
string $specversion,
40-
string $type,
41-
?string $datacontenttype,
42-
?string $dataschema,
43-
?string $subject,
44-
?string $time,
45-
$data,
46-
) {
47-
$this->id = $id;
48-
$this->source = $source;
49-
$this->specversion = $specversion;
50-
$this->type = $type;
51-
$this->datacontenttype = $datacontenttype;
52-
$this->dataschema = $dataschema;
53-
$this->subject = $subject;
54-
$this->time = $time;
55-
$this->data = $data;
24+
// Required Fields
25+
private string $id,
26+
private string $source,
27+
private string $specversion,
28+
private string $type,
29+
// Optional Fields
30+
private ?string $datacontenttype,
31+
private ?string $dataschema,
32+
private ?string $subject,
33+
private ?string $time,
34+
private mixed $data
35+
)
36+
{
5637
}
5738

5839
public function getId(): string

src/google-cloud/google/Context.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,8 @@
2020

2121
class Context
2222
{
23-
private $eventId;
24-
private $timestamp;
25-
private $eventType;
26-
private $resource;
27-
28-
final public function __construct(
29-
?string $eventId,
30-
?string $timestamp,
31-
?string $eventType,
32-
?array $resource,
33-
) {
34-
$this->eventId = $eventId;
35-
$this->timestamp = $timestamp;
36-
$this->eventType = $eventType;
37-
$this->resource = $resource;
23+
final public function __construct(private ?string $eventId, private ?string $timestamp, private ?string $eventType, private ?array $resource)
24+
{
3825
}
3926

4027
public function getEventId(): ?string

src/google-cloud/google/LegacyEventMapper.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class LegacyEventMapper
2323
// Maps background/legacy event types to their equivalent CloudEvent types.
2424
// For more info on event mappings see
2525
// https://github.com/GoogleCloudPlatform/functions-framework-conformance/blob/master/docs/mapping.md
26-
private static $ceTypeMap = [
26+
private static array $ceTypeMap = [
2727
'google.pubsub.topic.publish' => 'google.cloud.pubsub.topic.v1.messagePublished',
2828
'providers/cloud.pubsub/eventTypes/topic.publish' => 'google.cloud.pubsub.topic.v1.messagePublished',
2929
'google.storage.object.finalize' => 'google.cloud.storage.object.v1.finalized',
@@ -53,7 +53,7 @@ class LegacyEventMapper
5353
private const STORAGE_CE_SERVICE = 'storage.googleapis.com';
5454

5555
// Maps background event services to their equivalent CloudEvent services.
56-
private static $ceServiceMap = [
56+
private static array $ceServiceMap = [
5757
'providers/cloud.firestore/' => self::FIRESTORE_CE_SERVICE,
5858
'providers/google.firebase.analytics/' => self::FIREBASE_CE_SERVICE,
5959
'providers/firebase.auth/' => self::FIREBASE_AUTH_CE_SERVICE,
@@ -66,7 +66,7 @@ class LegacyEventMapper
6666
// event resource string into CloudEvent resource and subject strings. Each regex
6767
// must have exactly two capture groups: the first for the resource and the second
6868
// for the subject.
69-
private static $ceResourceRegexMap = [
69+
private static array $ceResourceRegexMap = [
7070
self::FIREBASE_CE_SERVICE => '#^(projects/[^/]+)/(events/[^/]+)$#',
7171
self::FIREBASE_DB_CE_SERVICE => '#^(projects/_/instances/[^/]+)/(refs/.+)$#',
7272
self::FIRESTORE_CE_SERVICE => '#^(projects/[^/]+/databases/\(default\))/(documents/.+)$#',
@@ -75,7 +75,7 @@ class LegacyEventMapper
7575

7676
// Maps Firebase Auth background event metadata field names to their equivalent
7777
// CloudEvent field names.
78-
private static $firebaseAuthMetadataFieldMap = [
78+
private static array $firebaseAuthMetadataFieldMap = [
7979
'createdAt' => 'createTime',
8080
'lastSignedInAt' => 'lastSignInTime',
8181
];

src/google-cloud/src/Runtime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Runtime extends GenericRuntime
1818
// from this list because the header 'ce-datacontenttype' is not permitted;
1919
// that data comes from the 'Content-Type' header instead. For more info see
2020
// https://github.com/cloudevents/spec/blob/v1.0.1/http-protocol-binding.md#311-http-content-type
21-
private static $binaryModeHeaderAttrs = [
21+
private static array $binaryModeHeaderAttrs = [
2222
'id',
2323
'source',
2424
'specversion',

src/laravel/src/ConsoleApplicationRunner.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,9 @@
1212
*/
1313
class ConsoleApplicationRunner implements RunnerInterface
1414
{
15-
private $application;
16-
private $input;
17-
private $output;
1815

19-
public function __construct(ConsoleKernel $application, InputInterface $input, ?OutputInterface $output = null)
16+
public function __construct(private ConsoleKernel $application, private InputInterface $input, private ?OutputInterface $output = null)
2017
{
21-
$this->application = $application;
22-
$this->input = $input;
23-
$this->output = $output;
2418
}
2519

2620
public function run(): int

src/laravel/src/HttpKernelRunner.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
class HttpKernelRunner implements RunnerInterface
1010
{
11-
private $kernel;
12-
private $request;
11+
private Kernel $kernel;
12+
private Request $request;
1313

1414
public function __construct(Kernel $kernel, Request $request)
1515
{

src/psr-17/src/Runtime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Runtime extends GenericRuntime
1919
/**
2020
* @var ServerRequestCreator|null
2121
*/
22-
private $requestCreator;
22+
private ?ServerRequestCreator $requestCreator = null;
2323

2424
/**
2525
* @param array{

src/psr-laminas/src/Emitter.php

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

33
namespace Runtime\PsrLaminas;
44

5+
use Laminas\HttpHandlerRunner\Emitter\EmitterInterface;
56
use Laminas\HttpHandlerRunner\Emitter\SapiEmitter;
67
use Psr\Http\Message\ResponseInterface;
78
use Psr\Http\Message\ServerRequestInterface;
@@ -13,10 +14,10 @@
1314
*/
1415
class Emitter implements RunnerInterface
1516
{
16-
private $requestHandler;
17-
private $response;
18-
private $request;
19-
private $emitter;
17+
private ?RequestHandlerInterface $requestHandler = null;
18+
private ?ResponseInterface $response = null;
19+
private ?ServerRequestInterface $request = null;
20+
private EmitterInterface $emitter;
2021

2122
private function __construct(array $options)
2223
{

src/psr-nyholm-laminas/src/LaminasEmitter.php

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

33
namespace Runtime\PsrNyholmLaminas;
44

5+
use Laminas\HttpHandlerRunner\Emitter\EmitterInterface;
56
use Laminas\HttpHandlerRunner\Emitter\SapiEmitter;
67
use Psr\Http\Message\ResponseInterface;
78
use Psr\Http\Message\ServerRequestInterface;
@@ -13,10 +14,10 @@
1314
*/
1415
class LaminasEmitter implements RunnerInterface
1516
{
16-
private $requestHandler;
17-
private $response;
18-
private $request;
19-
private $emitter;
17+
private ?RequestHandlerInterface $requestHandler = null;
18+
private ?ResponseInterface $response = null;
19+
private ?ServerRequestInterface $request = null;
20+
private EmitterInterface $emitter;
2021

2122
private function __construct(array $options)
2223
{

src/psr-nyholm-laminas/src/Runtime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Runtime extends GenericRuntime
2020
/**
2121
* @var ServerRequestCreator|null
2222
*/
23-
private $requestCreator;
23+
private ?ServerRequestCreator $requestCreator = null;
2424

2525
/**
2626
* @param array{

src/psr-nyholm/src/Emitter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
*/
1313
class Emitter implements RunnerInterface
1414
{
15-
private $requestHandler;
16-
private $response;
17-
private $request;
15+
private ?RequestHandlerInterface $requestHandler = null;
16+
private ?ResponseInterface $response = null;
17+
private ?ServerRequestInterface $request = null;
1818

1919
private function __construct()
2020
{

0 commit comments

Comments
 (0)