Skip to content

Commit 3e9b615

Browse files
committed
Added PHP STAN
1 parent 1ccc0ff commit 3e9b615

File tree

80 files changed

+632
-95
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+632
-95
lines changed

.gitlab-ci.yml

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,38 @@ lint:php:
1313
- composer install
1414
script:
1515
- ./vendor/bin/parallel-lint --exclude vendor/ .
16-
tags:
17-
- k8s-tbk
1816

1917
lint:php-codestyle:
2018
stage: lint
2119
before_script:
2220
- composer install
2321
script:
24-
- ./vendor/bin/php-cs-fixer fix -v --dry-run --using-cache=no . --config .php_cs.dist
25-
tags:
26-
- k8s-tbk
22+
- ./vendor/bin/php-cs-fixer fix -v --dry-run --using-cache=no
23+
24+
lint:php-stan:
25+
stage: lint
26+
before_script:
27+
- composer install
28+
script:
29+
- ./vendor/bin/phpstan --no-progress --memory-limit="2G" --error-format=gitlab > phpstan-report.json || (cat phpstan-report.json && exit 1)
2730

2831
lint:composer:
2932
stage: lint
3033
script:
3134
- composer validate --no-interaction --strict
32-
tags:
33-
- k8s-tbk
3435

3536
lint:secretsscan:
3637
image: '$IMAGE_URL_PYTHON'
3738
stage: lint
3839
script:
3940
- ci/scan_secrets.sh
40-
tags:
41-
- k8s-tbk
4241

4342
validate:tag-message:
4443
stage: validate
4544
only:
4645
- tags
4746
script:
4847
- ci/validate_tag_message.sh $CI_COMMIT_TAG
49-
tags:
50-
- k8s-tbk
5148

5249
validate:tag-version-consistency:
5350
stage: validate
@@ -56,17 +53,13 @@ validate:tag-version-consistency:
5653
script:
5754
- composer dump-autoload
5855
- php ci/ValidateTagVersionConsistency.php $CI_COMMIT_TAG
59-
tags:
60-
- k8s-tbk
6156

6257
deploy:deploy-to-github:
6358
stage: deploy
6459
only:
6560
- tags
6661
script:
6762
- ci/deploy_to_github.sh
68-
tags:
69-
- k8s-tbk
7063

7164
release:release-to-github:
7265
image: '$IMAGE_URL_PYTHON'
@@ -75,5 +68,3 @@ release:release-to-github:
7568
- tags
7669
script:
7770
- ci/release_to_github.sh $CI_COMMIT_TAG
78-
tags:
79-
- k8s-tbk

.php-cs-fixer.dist.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
$finder = Symfony\Component\Finder\Finder::create()
4+
->in('.')
5+
->files()
6+
->name('*.php')
7+
->ignoreDotFiles(true)
8+
->ignoreVCS(true)
9+
->exclude('vendor');
10+
11+
return (new PhpCsFixer\Config)
12+
->setRules([
13+
'@PSR2' => true,
14+
'array_syntax' => ['syntax' => 'short'],
15+
])
16+
->setFinder($finder);

.php_cs.dist

Lines changed: 0 additions & 14 deletions
This file was deleted.

.phpstan-bootstrap.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
$autoloader = __DIR__ . '/vendor/autoload.php';
4+
if (!file_exists($autoloader)) {
5+
fwrite(
6+
STDERR,
7+
'You need to set up the project dependencies using Composer:' . PHP_EOL . PHP_EOL .
8+
' composer install' . PHP_EOL . PHP_EOL .
9+
'You can learn all about Composer on https://getcomposer.org/.' . PHP_EOL
10+
);
11+
12+
die(1);
13+
}
14+
15+
include $autoloader;

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
"psr/cache": "^1.0.1|^3.0"
1919
},
2020
"require-dev": {
21-
"friendsofphp/php-cs-fixer": "^2.17",
22-
"php-parallel-lint/php-parallel-lint": "^1.2"
21+
"friendsofphp/php-cs-fixer": "^3.0",
22+
"php-parallel-lint/php-parallel-lint": "^1.2",
23+
"phpstan/phpstan": "^1.5"
2324
},
2425
"autoload": {
2526
"psr-4": {

phpstan.neon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
bootstrapFiles:
3+
- .phpstan-bootstrap.php
4+
level: 8
5+
paths:
6+
- src

src/Entity/AbstractEntity.php

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

55
class AbstractEntity implements \JsonSerializable
66
{
7+
/**
8+
* @param mixed[] $valueArray
9+
*/
710
public function __construct(array $valueArray = [])
811
{
912
foreach ($valueArray as $field => $value) {

src/Entity/Colocation.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Colocation extends AbstractEntity
1010
protected $name;
1111

1212
/**
13-
* @var array $ipRanges
13+
* @var string[] $ipRanges
1414
*/
1515
protected $ipRanges;
1616

@@ -19,6 +19,9 @@ public function getName(): string
1919
return $this->name;
2020
}
2121

22+
/**
23+
* @return string[]
24+
*/
2225
public function getIpRanges(): array
2326
{
2427
return $this->ipRanges;

src/Entity/Domain.php

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Domain extends AbstractEntity
5858
protected $hasAutoDns;
5959

6060
/**
61-
* @var array $tags
61+
* @var string[] $tags
6262
*/
6363
protected $tags = [];
6464

@@ -77,6 +77,9 @@ class Domain extends AbstractEntity
7777
*/
7878
protected $contacts = [];
7979

80+
/**
81+
* @param mixed[] $valueArray
82+
*/
8083
public function __construct(array $valueArray = [])
8184
{
8285
foreach ($valueArray as $field => $value) {
@@ -96,14 +99,22 @@ public function __construct(array $valueArray = [])
9699
}
97100
}
98101

99-
private function initNameservers(array $nameservers = [])
102+
/**
103+
* @param mixed[] $nameservers
104+
* @return void
105+
*/
106+
private function initNameservers(array $nameservers = []): void
100107
{
101108
$this->nameservers = array_map(static function ($nameserver) {
102109
return new Nameserver(($nameserver));
103110
}, $nameservers);
104111
}
105112

106-
private function initContacts(array $contacts = [])
113+
/**
114+
* @param mixed[] $contacts
115+
* @return void
116+
*/
117+
private function initContacts(array $contacts = []): void
107118
{
108119
$this->contacts = array_map(static function ($contact) {
109120
return new WhoisContact($contact);
@@ -155,6 +166,9 @@ public function isDnsOnly(): bool
155166
return $this->isDnsOnly;
156167
}
157168

169+
/**
170+
* @return string[]
171+
*/
158172
public function getTags(): array
159173
{
160174
return $this->tags;
@@ -172,6 +186,10 @@ public function setIsWhitelabel(bool $isWhitelabel): Domain
172186
return $this;
173187
}
174188

189+
/**
190+
* @param string[] $tags
191+
* @return self
192+
*/
175193
public function setTags(array $tags): Domain
176194
{
177195
$this->tags = $tags;
@@ -220,31 +238,31 @@ public function setStatus(string $status): void
220238
/**
221239
* @return Nameserver[]
222240
*/
223-
public function getNameservers()
241+
public function getNameservers(): array
224242
{
225243
return $this->nameservers;
226244
}
227245

228246
/**
229247
* @param Nameserver[] $nameservers
230248
*/
231-
public function setNameservers($nameservers): void
249+
public function setNameservers(array $nameservers): void
232250
{
233251
$this->nameservers = $nameservers;
234252
}
235253

236254
/**
237-
* @return Contact[]
255+
* @return WhoisContact[]
238256
*/
239-
public function getContacts()
257+
public function getContacts(): array
240258
{
241259
return $this->contacts;
242260
}
243261

244262
/**
245-
* @param Contact[] $contacts
263+
* @param WhoisContact[] $contacts
246264
*/
247-
public function setContacts($contacts): void
265+
public function setContacts(array $contacts): void
248266
{
249267
$this->contacts = $contacts;
250268
}

src/Entity/Domain/DnsEntry.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ public function getContent(): string
8080
public function getRdata(): string
8181
{
8282
if (in_array($this->getType(), [self::TYPE_CAA,self::TYPE_TXT])) {
83-
return json_encode($this->content);
84-
} else {
85-
return $this->content;
83+
return (string)json_encode($this->content);
8684
}
85+
86+
return $this->content;
8787
}
8888

8989
public function setContent(string $content): DnsEntry

src/Entity/DomainCheckResult.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class DomainCheckResult extends AbstractEntity
2222
protected $status;
2323

2424
/**
25-
* @var array $actions
25+
* @var string[] $actions
2626
*/
2727
protected $actions;
2828

@@ -36,6 +36,9 @@ public function getStatus(): string
3636
return $this->status;
3737
}
3838

39+
/**
40+
* @return string[]
41+
*/
3942
public function getActions(): array
4043
{
4144
return $this->actions;

src/Entity/Haip.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,15 @@ public function getHttpHealthCheckPort(): string
147147
return $this->httpHealthCheckPort;
148148
}
149149

150+
/**
151+
* the returnType should have been int.
152+
* cannot correct this without introducing a breaking change.
153+
*
154+
* @return string
155+
*/
150156
public function getHttpHealthCheckSsl(): string
151157
{
152-
return $this->httpHealthCheckSsl;
158+
return (string)$this->httpHealthCheckSsl;
153159
}
154160

155161
public function getIpv4Address(): string
@@ -172,6 +178,9 @@ public function getPtrRecord(): string
172178
return $this->ptrRecord;
173179
}
174180

181+
/**
182+
* @return string[]
183+
*/
175184
public function getIpAddresses(): array
176185
{
177186
return $this->ipAddresses;

src/Entity/Invoice/InvoiceItem.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ class InvoiceItem extends AbstractEntity
5656
*/
5757
protected $discounts;
5858

59+
/**
60+
* @param mixed[] $valueArray
61+
*/
5962
public function __construct(array $valueArray = [])
6063
{
6164
parent::__construct($valueArray);

src/Entity/PrivateNetwork.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public function isLocked(): bool
4949
return $this->isLocked;
5050
}
5151

52+
/**
53+
* @return string[]
54+
*/
5255
public function getVpsNames(): array
5356
{
5457
return $this->vpsNames;

src/Entity/Tld.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Tld extends AbstractEntity
3030
protected $recurringPrice;
3131

3232
/**
33-
* @var array $capabilities
33+
* @var string[] $capabilities
3434
*/
3535
protected $capabilities;
3636

@@ -69,6 +69,9 @@ public function getRecurringPrice(): int
6969
return $this->recurringPrice;
7070
}
7171

72+
/**
73+
* @return string[]
74+
*/
7275
public function getCapabilities(): array
7376
{
7477
return $this->capabilities;

0 commit comments

Comments
 (0)