Skip to content

Commit a782449

Browse files
committed
Update to PHP 8 + format
1 parent 295f2b9 commit a782449

27 files changed

+590
-902
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"psr-4": {"Tests\\": "tests"}
2525
},
2626
"require": {
27-
"php": ">=7.0.0",
27+
"php": ">=8.0",
2828
"ext-curl": "*",
2929
"ext-mbstring": "*",
3030
"ext-json": "*",

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/SDK/Language.php

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

33
namespace Appwrite\SDK;
44

5-
abstract class Language {
6-
5+
abstract class Language
6+
{
77
const TYPE_INTEGER = 'integer';
88
const TYPE_NUMBER = 'number';
99
const TYPE_STRING = 'string';
@@ -20,22 +20,22 @@ abstract class Language {
2020
/**
2121
* @return string
2222
*/
23-
abstract public function getName();
23+
abstract public function getName(): string;
2424

2525
/**
26-
* @return array
26+
* @return array<string>
2727
*/
28-
abstract public function getKeywords();
28+
abstract public function getKeywords(): array;
2929

3030
/**
31-
* @return array
31+
* @return array<string>
3232
*/
33-
abstract public function getIdentifierOverrides();
33+
abstract public function getIdentifierOverrides(): array;
3434

3535
/**
36-
* @return array
36+
* @return array<array>
3737
*/
38-
abstract public function getFiles();
38+
abstract public function getFiles(): array;
3939

4040
/**
4141
* @param $type
@@ -47,20 +47,20 @@ abstract public function getTypeName($type);
4747
* @param array $param
4848
* @return string
4949
*/
50-
abstract public function getParamDefault(array $param);
50+
abstract public function getParamDefault(array $param): string;
5151

5252
/**
5353
* @param array $param
5454
* @return string
5555
*/
56-
abstract public function getParamExample(array $param);
56+
abstract public function getParamExample(array $param): string;
5757

5858
/**
5959
* @param string $key
6060
* @param string $value
6161
* @return Language
6262
*/
63-
public function setParam($key, $value)
63+
public function setParam(string $key, string $value): Language
6464
{
6565
$this->params[$key] = $value;
6666

@@ -70,17 +70,17 @@ public function setParam($key, $value)
7070
/**
7171
* @return array
7272
*/
73-
public function getParams()
73+
public function getParams(): array
7474
{
7575
return $this->params;
7676
}
7777

7878
/**
7979
* Language specific filters.
80-
* @return array
80+
* @return array
8181
*/
8282
public function getFilters(): array
8383
{
8484
return [];
8585
}
86-
}
86+
}

src/SDK/Language/Android.php

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

33
namespace Appwrite\SDK\Language;
44

5-
6-
class Android extends Kotlin {
7-
5+
class Android extends Kotlin
6+
{
87
/**
98
* @return string
109
*/
11-
public function getName()
10+
public function getName(): string
1211
{
1312
return 'Android';
1413
}
1514

1615
/**
1716
* @return array
1817
*/
19-
public function getFiles()
18+
public function getFiles(): array
2019
{
2120
return [
22-
// Config for root project
21+
// Config for root project
2322
[
2423
'scope' => 'copy',
2524
'destination' => '.github/workflows/publish.yml',
@@ -100,7 +99,7 @@ public function getFiles()
10099
'destination' => 'settings.gradle',
101100
'template' => '/android/settings.gradle',
102101
],
103-
// Config for project :library
102+
// Config for project :library
104103
[
105104
'scope' => 'default',
106105
'destination' => '/library/src/main/java/{{ sdk.namespace | caseSlash }}/Client.kt',

src/SDK/Language/CLI.php

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
class CLI extends Node
66
{
7-
87
/**
98
* @var array
109
*/
@@ -19,7 +18,7 @@ class CLI extends Node
1918
* @param string $name
2019
* @return $this
2120
*/
22-
public function setExecutableName($name)
21+
public function setExecutableName(string $name): CLI
2322
{
2423
$this->setParam('executableName', $name);
2524

@@ -30,7 +29,7 @@ public function setExecutableName($name)
3029
* @param string $logo
3130
* @return $this
3231
*/
33-
public function setLogo($logo)
32+
public function setLogo(string $logo): CLI
3433
{
3534
$this->setParam('logo', $logo);
3635

@@ -41,7 +40,7 @@ public function setLogo($logo)
4140
* @param string $logo
4241
* @return $this
4342
*/
44-
public function setLogoUnescaped($logo)
43+
public function setLogoUnescaped(string $logo): CLI
4544
{
4645
$this->setParam('logoUnescaped', $logo);
4746

@@ -51,142 +50,121 @@ public function setLogoUnescaped($logo)
5150
/**
5251
* @return string
5352
*/
54-
public function getName()
53+
public function getName(): string
5554
{
5655
return 'cli';
5756
}
5857

5958
/**
6059
* @return array
6160
*/
62-
public function getFiles()
61+
public function getFiles(): array
6362
{
6463
return [
6564
[
6665
'scope' => 'default',
6766
'destination' => 'README.md',
6867
'template' => 'cli/README.md.twig',
69-
'minify' => false,
7068
],
7169
[
7270
'scope' => 'default',
7371
'destination' => 'package.json',
7472
'template' => 'cli/package.json.twig',
75-
'minify' => false,
7673
],
7774
[
7875
'scope' => 'default',
7976
'destination' => 'LICENSE.md',
8077
'template' => 'cli/LICENSE.md.twig',
81-
'minify' => false,
8278
],
8379
[
8480
'scope' => 'default',
8581
'destination' => 'install.sh',
8682
'template' => 'cli/install.sh.twig',
87-
'minify' => false,
8883
],
8984
[
9085
'scope' => 'default',
9186
'destination' => 'install.ps1',
9287
'template' => 'cli/install.ps1.twig',
93-
'minify' => false,
9488
],
9589
[
9690
'scope' => 'default',
9791
'destination' => 'index.js',
9892
'template' => 'cli/index.js.twig',
99-
'minify' => false,
10093
],
10194
[
10295
'scope' => 'method',
10396
'destination' => 'docs/examples/{{service.name | caseLower}}/{{method.name | caseDash}}.md',
10497
'template' => 'cli/docs/example.md.twig',
105-
'minify' => false,
10698
],
10799
[
108100
'scope' => 'default',
109101
'destination' => '.gitignore',
110102
'template' => 'cli/.gitignore',
111-
'minify' => false,
112103
],
113104
[
114105
'scope' => 'method',
115106
'destination' => 'Formula/{{ language.params.executableName }}.rb',
116107
'template' => 'cli/Formula/formula.rb.twig',
117-
'minify' => false,
118108
],
119109
[
120110
'scope' => 'copy',
121111
'destination' => '.github/workflows/npm-publish.yml',
122112
'template' => 'cli/.github/workflows/npm-publish.yml',
123-
'minify' => false,
124113
],
125114
[
126115
'scope' => 'default',
127116
'destination' => 'lib/sdks.js',
128117
'template' => 'cli/lib/sdks.js.twig',
129-
'minify' => false,
130118
],
131119
[
132120
'scope' => 'default',
133121
'destination' => 'lib/questions.js',
134122
'template' => 'cli/lib/questions.js.twig',
135-
'minify' => false,
136123
],
137124
[
138125
'scope' => 'default',
139126
'destination' => 'lib/parser.js',
140127
'template' => 'cli/lib/parser.js.twig',
141-
'minify' => false,
142128
],
143129
[
144130
'scope' => 'default',
145131
'destination' => 'lib/exception.js',
146132
'template' => 'cli/lib/exception.js.twig',
147-
'minify' => false,
148133
],
149134
[
150135
'scope' => 'default',
151136
'destination' => 'lib/config.js',
152137
'template' => 'cli/lib/config.js.twig',
153-
'minify' => false,
154138
],
155139
[
156140
'scope' => 'default',
157141
'destination' => 'lib/client.js',
158142
'template' => 'cli/lib/client.js.twig',
159-
'minify' => false,
160143
],
161144
[
162145
'scope' => 'default',
163146
'destination' => 'lib/utils.js',
164147
'template' => 'cli/lib/utils.js.twig',
165-
'minify' => false,
166148
],
167149
[
168150
'scope' => 'default',
169151
'destination' => 'lib/commands/init.js',
170152
'template' => 'cli/lib/commands/init.js.twig',
171-
'minify' => false,
172153
],
173154
[
174155
'scope' => 'default',
175156
'destination' => 'lib/commands/deploy.js',
176157
'template' => 'cli/lib/commands/deploy.js.twig',
177-
'minify' => false,
178158
],
179159
[
180160
'scope' => 'service',
181161
'destination' => '/lib/commands/{{service.name | caseDash}}.js',
182162
'template' => 'cli/lib/commands/command.js.twig',
183-
'minify' => false,
184163
],
185164
[
186165
'scope' => 'default',
187166
'destination' => 'lib/commands/generic.js',
188167
'template' => 'cli/lib/commands/generic.js.twig',
189-
'minify' => false,
190168
]
191169
];
192170
}
@@ -195,14 +173,14 @@ public function getFiles()
195173
* @param array $param
196174
* @return string
197175
*/
198-
public function getParamExample(array $param)
176+
public function getParamExample(array $param): string
199177
{
200178
$type = $param['type'] ?? '';
201179
$example = $param['example'] ?? '';
202180

203181
$output = '';
204182

205-
if(empty($example) && $example !== 0 && $example !== false) {
183+
if (empty($example) && $example !== 0 && $example !== false) {
206184
switch ($type) {
207185
case self::TYPE_NUMBER:
208186
case self::TYPE_INTEGER:
@@ -222,11 +200,10 @@ public function getParamExample(array $param)
222200
$output .= "'path/to/file.png'";
223201
break;
224202
}
225-
}
226-
else {
203+
} else {
227204
switch ($type) {
228205
case self::TYPE_ARRAY:
229-
if(strpos($example, '[') !== false && strpos($example, ']') !== false) {
206+
if (str_contains($example, '[') && str_contains($example, ']')) {
230207
$trimmed = substr($example, 1, -1);
231208
$split = explode(',', $trimmed);
232209
$output .= implode(' ', $split);

0 commit comments

Comments
 (0)