Skip to content

Commit f88a344

Browse files
committed
Improve typing
1 parent e651a85 commit f88a344

File tree

5 files changed

+24
-26
lines changed

5 files changed

+24
-26
lines changed

templates/php/src/Client.php.twig

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@ class Client
1414
const METHOD_CONNECT = 'CONNECT';
1515
const METHOD_TRACE = 'TRACE';
1616
17-
const CHUNK_SIZE = 5*1024*1024;
17+
const CHUNK_SIZE = 5 * 1024 * 1024;
1818
1919
/**
2020
* Is Self Signed Certificates Allowed?
2121
*
2222
* @var bool
2323
*/
24-
protected $selfSigned = false;
24+
protected bool $selfSigned = false;
2525
2626
/**
2727
* Service host name
2828
*
2929
* @var string
3030
*/
31-
protected $endpoint = '{{spec.endpoint}}';
31+
protected string $endpoint = '{{spec.endpoint}}';
3232
3333
/**
3434
* Global Headers
3535
*
3636
* @var array
3737
*/
38-
protected $headers = [
38+
protected array $headers = [
3939
'content-type' => '',
4040
'user-agent' => '{{spec.title | caseUcfirst}}{{ language.name | caseUcfirst }}SDK/{{ sdk.version }} ({{deviceInfo}})',
4141
'x-sdk-name'=> '{{ sdk.name }}',
@@ -45,7 +45,7 @@ class Client
4545
];
4646
4747
/**
48-
* SDK constructor.
48+
* Client constructor.
4949
*/
5050
public function __construct()
5151
{
@@ -66,7 +66,7 @@ class Client
6666
*
6767
* @return Client
6868
*/
69-
public function set{{header.key | caseUcfirst}}($value)
69+
public function set{{header.key | caseUcfirst}}(string $value): Client
7070
{
7171
$this->addHeader('{{header.name}}', $value);
7272
@@ -79,7 +79,7 @@ class Client
7979
* @param bool $status
8080
* @return $this
8181
*/
82-
public function setSelfSigned($status = true)
82+
public function setSelfSigned(bool $status = true): Client
8383
{
8484
$this->selfSigned = $status;
8585
@@ -90,7 +90,7 @@ class Client
9090
* @param $endpoint
9191
* @return $this
9292
*/
93-
public function setEndpoint($endpoint)
93+
public function setEndpoint(string $endpoint): Client
9494
{
9595
$this->endpoint = $endpoint;
9696
@@ -101,7 +101,7 @@ class Client
101101
* @param $key
102102
* @param $value
103103
*/
104-
public function addHeader($key, $value)
104+
public function addHeader(string $key, string $value): Client
105105
{
106106
$this->headers[strtolower($key)] = $value;
107107
@@ -224,7 +224,7 @@ class Client
224224
* @param string $prefix
225225
* @return array
226226
*/
227-
protected function flatten(array $data, $prefix = '') {
227+
protected function flatten(array $data, string $prefix = ''): array {
228228
$output = [];
229229
230230
foreach($data as $key => $value) {

templates/php/src/InputFile.php.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class InputFile {
2929
return $this->filename;
3030
}
3131
32-
public static function withPath(string $path, ?string $mimeType = null, ?string $filename = null)
32+
public static function withPath(string $path, ?string $mimeType = null, ?string $filename = null): InputFile
3333
{
3434
$instance = new InputFile();
3535
$instance->path = $path;
@@ -39,7 +39,7 @@ class InputFile {
3939
return $instance;
4040
}
4141
42-
public static function withData(string $data, ?string $mimeType = null, ?string $filename = null)
42+
public static function withData(string $data, ?string $mimeType = null, ?string $filename = null): InputFile
4343
{
4444
$instance = new InputFile();
4545
$instance->path = null;

templates/php/src/Permission.php.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,22 @@ class Permission
88
{
99
return "read(\"$role\")";
1010
}
11+
1112
public static function write(string $role): string
1213
{
1314
return "write(\"$role\")";
1415
}
16+
1517
public static function create(string $role): string
1618
{
1719
return "create(\"$role\")";
1820
}
21+
1922
public static function update(string $role): string
2023
{
2124
return "update(\"$role\")";
2225
}
26+
2327
public static function delete(string $role): string
2428
{
2529
return "delete(\"$role\")";

templates/php/src/Query.php.twig

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Query implements \JsonSerializable
4242
* @param mixed $value
4343
* @return string
4444
*/
45-
public static function equal(string $attribute, $value): string
45+
public static function equal(string $attribute, mixed $value): string
4646
{
4747
return (new Query('equal', $attribute, $value))->__toString();
4848
}
@@ -54,7 +54,7 @@ class Query implements \JsonSerializable
5454
* @param mixed $value
5555
* @return string
5656
*/
57-
public static function notEqual(string $attribute, $value): string
57+
public static function notEqual(string $attribute, mixed $value): string
5858
{
5959
return (new Query('notEqual', $attribute, $value))->__toString();
6060
}
@@ -66,7 +66,7 @@ class Query implements \JsonSerializable
6666
* @param mixed $value
6767
* @return string
6868
*/
69-
public static function lessThan(string $attribute, $value): string
69+
public static function lessThan(string $attribute, mixed $value): string
7070
{
7171
return (new Query('lessThan', $attribute, $value))->__toString();
7272
}
@@ -78,7 +78,7 @@ class Query implements \JsonSerializable
7878
* @param mixed $value
7979
* @return string
8080
*/
81-
public static function lessThanEqual(string $attribute, $value): string
81+
public static function lessThanEqual(string $attribute, mixed $value): string
8282
{
8383
return (new Query('lessThanEqual', $attribute, $value))->__toString();
8484
}
@@ -90,7 +90,7 @@ class Query implements \JsonSerializable
9090
* @param mixed $value
9191
* @return string
9292
*/
93-
public static function greaterThan(string $attribute, $value): string
93+
public static function greaterThan(string $attribute, mixed $value): string
9494
{
9595
return (new Query('greaterThan', $attribute, $value))->__toString();
9696
}
@@ -102,7 +102,7 @@ class Query implements \JsonSerializable
102102
* @param mixed $value
103103
* @return string
104104
*/
105-
public static function greaterThanEqual(string $attribute, $value): string
105+
public static function greaterThanEqual(string $attribute, mixed $value): string
106106
{
107107
return (new Query('greaterThanEqual', $attribute, $value))->__toString();
108108
}
@@ -149,7 +149,7 @@ class Query implements \JsonSerializable
149149
* @param string|int|float $end
150150
* @return string
151151
*/
152-
public static function between(string $attribute, $start, $end): string
152+
public static function between(string $attribute, mixed $start, mixed $end): string
153153
{
154154
return (new Query('between', $attribute, [$start, $end]))->__toString();
155155
}

templates/php/src/Service.php.twig

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,8 @@ namespace {{ spec.title | caseUcfirst }};
44
55
abstract class Service
66
{
7-
/**
8-
* @var Client
9-
*/
10-
protected $client;
7+
protected Client $client;
118
12-
/**
13-
* @param Client $client
14-
*/
159
public function __construct(Client $client)
1610
{
1711
$this->client = $client;

0 commit comments

Comments
 (0)