Skip to content

Commit 6a96feb

Browse files
authored
PHPStan: raise to level 6 (#4223)
* PHPStan: cleanup setup * PHPStan: raise to level 6
1 parent 67ac857 commit 6a96feb

19 files changed

Lines changed: 48 additions & 38 deletions

contrib/cpanel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ function getCpanel()
179179
return $cpanel;
180180
}
181181

182-
function getDomainInfo()
182+
function getDomainInfo(): array
183183
{
184184
$domain = vsprintf(get('cpanel')['create_domain_format'], get('cpanel')['create_domain_values']);
185185
$cleanDomain = str_replace(['.', ',', ' ', '/', '-'], '', $domain);

contrib/ispmanager.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@
694694
}
695695
});
696696

697-
function ispmanagerRequest($method, $requestData)
697+
function ispmanagerRequest(string $method, array $requestData): mixed
698698
{
699699
$config = get('ispmanager');
700700
$dsnData = parse_url($config['api']['dsn']);
@@ -722,7 +722,7 @@ function ispmanagerRequest($method, $requestData)
722722
}
723723
}
724724

725-
function ispmanagerAuthRequest($url, $login, $pass)
725+
function ispmanagerAuthRequest(string $url, string $login, string $pass): void
726726
{
727727
$authRequestData = [
728728
'func' => 'auth',
@@ -743,7 +743,7 @@ function ispmanagerAuthRequest($url, $login, $pass)
743743
}
744744
}
745745

746-
function prepareRequest($requestData)
746+
function prepareRequest(array $requestData): array
747747
{
748748
$config = get('ispmanager');
749749
$dsnData = parse_url($config['api']['dsn']);
@@ -763,9 +763,9 @@ function prepareRequest($requestData)
763763
return $requestData;
764764
}
765765

766-
function generatePassword($lenght)
766+
function generatePassword(int $length): string
767767
{
768-
return substr(md5(uniqid()), 0, $lenght);
768+
return substr(md5(uniqid()), 0, $length);
769769
}
770770

771771
// Callbacks before actions under domains

contrib/sentry.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ static function (&$value) use ($config) {
184184
},
185185
);
186186

187-
function getPreviousReleaseRevision()
187+
function getPreviousReleaseRevision(): ?string
188188
{
189189
switch (get('update_code_strategy')) {
190190
case 'local_archive':
@@ -206,7 +206,7 @@ function getPreviousReleaseRevision()
206206
}
207207
}
208208

209-
function getCurrentReleaseRevision()
209+
function getCurrentReleaseRevision(): string
210210
{
211211
switch (get('update_code_strategy')) {
212212
case 'local_archive':

contrib/slack.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
set('slack_failure_color', '#ff0909');
8888
set('slack_rollback_color', '#eba211');
8989

90-
function checkSlackAnswer($result)
90+
function checkSlackAnswer(mixed $result): bool
9191
{
9292
if ('invalid_token' === $result) {
9393
warning('Invalid Slack token');

contrib/supervisord-monitor.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191

9292
use Deployer\Utility\Httpie;
9393

94-
function supervisordCheckConfig()
94+
function supervisordCheckConfig(): void
9595
{
9696
$config = get('supervisord', []);
9797
foreach ($config as $key => $value) {
@@ -108,12 +108,12 @@ function supervisordCheckConfig()
108108
}
109109
}
110110

111-
function supervisordGetBasicAuthToken()
111+
function supervisordGetBasicAuthToken(): string
112112
{
113113
return 'Basic ' . base64_encode(get('supervisord_basic_auth_user') . ':' . get('supervisord_basic_auth_password'));
114114
}
115115

116-
function supervisordIsAuthenticated()
116+
function supervisordIsAuthenticated(): bool
117117
{
118118
supervisordCheckConfig();
119119

@@ -123,7 +123,7 @@ function supervisordIsAuthenticated()
123123
return $authResponseInfo['http_code'] === 200;
124124
}
125125

126-
function supervisordControlAction($name, $action = 'stop')
126+
function supervisordControlAction(string $name, string $action = 'stop'): bool
127127
{
128128
$stopResponseInfo = [];
129129
Httpie::post(get('supervisord_uri') . '/control/' . $action . '/localhost/' . $name)->header('Authorization', supervisordGetBasicAuthToken())->send($stopResponseInfo);

phpstan.neon

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ includes:
22
- tests/phpstan-baseline.neon
33

44
parameters:
5-
level: 5
5+
level: 6
66
paths:
77
- bin
88
- src
@@ -23,3 +23,7 @@ parameters:
2323
- "#^Constant MASTER_TOKEN not found\\.$#"
2424
- "#CpanelPhp#"
2525
- "#AMQPMessage#"
26+
- identifier: missingType.iterableValue
27+
-
28+
identifier: missingType.generics
29+
path: src/Component/Pimple/Container.php

recipe/codeigniter4.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function spark($command, $options = [])
8080
};
8181
}
8282

83-
function codeigniter4_version_compare($version, $comparator)
83+
function codeigniter4_version_compare(string $version, string $comparator): bool
8484
{
8585
return version_compare(get('codeigniter4_version'), $version, $comparator);
8686
}

recipe/laravel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function artisan($command, $options = [])
7474
};
7575
}
7676

77-
function laravel_version_compare($version, $comparator)
77+
function laravel_version_compare(string $version, string $comparator): bool
7878
{
7979
return version_compare(get('laravel_version'), $version, $comparator);
8080
}

recipe/magento2.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@
253253
*
254254
* @throws ConfigurationException
255255
*/
256-
function magentoDeployAssetsSplit(string $area)
256+
function magentoDeployAssetsSplit(string $area): void
257257
{
258258
if (!in_array($area, ['frontend', 'backend'], true)) {
259259
throw new ConfigurationException("\$area must be either 'frontend' or 'backend', '$area' given");

src/Collection/Collection.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
use Countable;
1414
use IteratorAggregate;
1515

16+
/**
17+
* @implements IteratorAggregate<string, mixed>
18+
*/
1619
class Collection implements Countable, IteratorAggregate
1720
{
1821
protected array $values = [];
@@ -35,7 +38,7 @@ public function has(string $name): bool
3538
return array_key_exists($name, $this->values);
3639
}
3740

38-
public function set(string $name, mixed $object)
41+
public function set(string $name, mixed $object): void
3942
{
4043
$this->values[$name] = $object;
4144
}

0 commit comments

Comments
 (0)