Skip to content

Commit b4856e2

Browse files
authored
Upgrade phpstan and phpunit configuration (#13)
1 parent c40e5fb commit b4856e2

File tree

6 files changed

+90
-88
lines changed

6 files changed

+90
-88
lines changed

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
"require-dev": {
2525
"friendsofphp/php-cs-fixer": "^3.11",
2626
"phpstan/extension-installer": "^1.0",
27-
"phpstan/phpstan": "^0.12.14",
28-
"phpstan/phpstan-phpunit": "^0.12.6",
29-
"phpstan/phpstan-symfony": "^0.12.4",
30-
"phpunit/phpunit": "^9.0"
27+
"phpstan/phpstan": "^1.8",
28+
"phpstan/phpstan-phpunit": "^1.1",
29+
"phpstan/phpstan-symfony": "^1.2",
30+
"phpunit/phpunit": "^9.5"
3131
},
3232
"autoload": {
3333
"psr-4": {

composer.lock

Lines changed: 43 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpunit.xml.dist

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,19 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
32
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
4-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
6-
backupGlobals="false"
7-
colors="true"
8-
bootstrap="vendor/autoload.php"
9-
beStrictAboutChangesToGlobalState="true"
10-
beStrictAboutOutputDuringTests="true"
11-
>
12-
<php>
13-
<ini name="error_reporting" value="-1" />
14-
<server name="APP_ENV" value="test" force="true" />
15-
<server name="SHELL_VERBOSITY" value="-1" />
16-
</php>
17-
18-
<testsuites>
19-
<testsuite name="unit">
20-
<directory>tests/Unit</directory>
21-
</testsuite>
22-
</testsuites>
23-
24-
<filter>
25-
<whitelist>
26-
<directory>./src</directory>
27-
</whitelist>
28-
</filter>
3+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="vendor/autoload.php" beStrictAboutChangesToGlobalState="true" beStrictAboutOutputDuringTests="true">
4+
<coverage>
5+
<include>
6+
<directory>./src</directory>
7+
</include>
8+
</coverage>
9+
<php>
10+
<ini name="error_reporting" value="-1"/>
11+
<server name="APP_ENV" value="test" force="true"/>
12+
<server name="SHELL_VERBOSITY" value="-1"/>
13+
</php>
14+
<testsuites>
15+
<testsuite name="unit">
16+
<directory>tests/Unit</directory>
17+
</testsuite>
18+
</testsuites>
2919
</phpunit>

src/Command/DebugCheckCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ protected function configure(): void
3333

3434
protected function execute(InputInterface $input, OutputInterface $output)
3535
{
36-
$check = $this->agent->check((string) $input->getOption('name'));
36+
$name = $input->getOption('name');
37+
if (!is_string($name)) {
38+
throw new \InvalidArgumentException('Option \'name\' must be a string.');
39+
}
40+
$check = $this->agent->check($name);
3741

3842
if ($check->status() === 'passing') {
3943
$output->writeln(sprintf('<fg=green>Status: %s<fg=default>', $check->status()));

src/Command/DeregisterServiceCommand.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ protected function configure(): void
3333

3434
protected function execute(InputInterface $input, OutputInterface $output)
3535
{
36-
$this->agent->deregisterService((string) $input->getOption('name'));
36+
$name = $input->getOption('name');
37+
if (!is_string($name)) {
38+
throw new \InvalidArgumentException('Option \'name\' must be a string.');
39+
}
40+
$this->agent->deregisterService($name);
3741

38-
$output->writeln(sprintf('Service %s deregistered from Consul', (string) $input->getOption('name')));
42+
$output->writeln(sprintf('Service %s deregistered from Consul', $name));
3943

4044
return 0;
4145
}

src/Command/RegisterServiceCommand.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,22 @@ protected function configure(): void
3939

4040
protected function execute(InputInterface $input, OutputInterface $output)
4141
{
42-
$this->agent->registerService(
43-
(string) $input->getOption('name'),
44-
(string) $input->getOption('host'),
45-
(int) $input->getOption('port')
46-
);
47-
48-
$output->writeln(sprintf('Service %s registered in Consul', (string) $input->getOption('name')));
42+
$name = $input->getOption('name');
43+
$host = $input->getOption('host');
44+
$port = $input->getOption('port');
45+
if (!is_string($name)) {
46+
throw new \InvalidArgumentException('Option \'name\' must be a string.');
47+
}
48+
if (!is_string($host)) {
49+
throw new \InvalidArgumentException('Option \'host\' must be a string.');
50+
}
51+
if (!is_numeric($port)) {
52+
throw new \InvalidArgumentException('Option \'port\' must be numeric.');
53+
}
54+
55+
$this->agent->registerService($name, $host, (int) $port);
56+
57+
$output->writeln(sprintf('Service %s registered in Consul', $name));
4958

5059
return 0;
5160
}

0 commit comments

Comments
 (0)