Skip to content

Commit 6644f61

Browse files
committed
Add phpstan and fix code
1 parent 80970bc commit 6644f61

File tree

11 files changed

+41
-22
lines changed

11 files changed

+41
-22
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ before_script:
1616
- mkdir -p build/logs
1717

1818
script:
19-
- composer cs
19+
- composer check
2020
- composer test -- --coverage-clover=build/logs/clover.xml --coverage-text
2121
- 'if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then ./vendor/bin/test-reporter; fi'

composer.json

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"phpunit/phpunit": "^6.1",
1212
"squizlabs/php_codesniffer": "^3.0",
1313
"codeclimate/php-test-reporter": "dev-master",
14-
"adlawson/vfs": "^0.12.1"
14+
"adlawson/vfs": "^0.12.1",
15+
"phpstan/phpstan": "^0.9.2",
16+
"jangregor/phpstan-prophecy": "^0.1.1"
1517
},
1618
"autoload": {
1719
"psr-4": {
@@ -35,7 +37,18 @@
3537
}
3638
],
3739
"scripts": {
40+
"check": [
41+
"@php-cs-src",
42+
"@php-cs-test",
43+
"@phpstan-src",
44+
"@phpstan-test"
45+
],
46+
3847
"test": "vendor/bin/phpunit tests/",
39-
"cs": "vendor/bin/phpcs --standard=PSR2 src/ && vendor/bin/phpcs --standard=PSR2 tests/"
48+
49+
"php-cs-src": "vendor/bin/phpcs --standard=PSR2 src/",
50+
"php-cs-test": "vendor/bin/phpcs --standard=PSR2 tests/",
51+
"phpstan-src": "vendor/bin/phpstan analyze --level=max src/",
52+
"phpstan-test": "vendor/bin/phpstan analyze tests/ --level=4 -c phpstan.neon"
4053
}
4154
}

phpstan.neon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
includes:
2+
- vendor/jangregor/phpstan-prophecy/src/extension.neon
3+
4+
parameters:
5+
ignoreErrors:
6+
- '#Call to an undefined method SystemCtl\\Template\\Section\\InstallSection::setFubar\(\)#'

src/Command/CommandDispatcherInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ public function setBinary(string $binary): CommandDispatcherInterface;
3535
* Dispatch given commands against implementers logic and creating a new command
3636
* to read results
3737
*
38-
* @param string[] $commands
38+
* @param string ...$commands
3939
*
4040
* @return CommandInterface
4141
* @throws CommandFailedException
4242
*/
43-
public function dispatch(...$commands): CommandInterface;
43+
public function dispatch(string ...$commands): CommandInterface;
4444
}

src/Command/SymfonyCommandDispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function setTimeout(int $timeout): CommandDispatcherInterface
3939
/**
4040
* @inheritDoc
4141
*/
42-
public function dispatch(...$commands): CommandInterface
42+
public function dispatch(string ...$commands): CommandInterface
4343
{
4444
$processBuilder = new ProcessBuilder();
4545
$processBuilder->setPrefix($this->binary);

src/SystemCtl.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public static function setAssetPath(string $assetPath): void
106106
* @param null|string $unitPrefix
107107
* @param string[] $unitTypes
108108
*
109-
* @return array|\string[]
109+
* @return array|string[]
110110
*/
111111
public function listUnits(?string $unitPrefix = null, array $unitTypes = self::SUPPORTED_UNITS): array
112112
{
@@ -144,8 +144,8 @@ public function getService(string $name): Service
144144
}
145145

146146
/**
147-
* @param string $unitName
148-
* @param array[] $units
147+
* @param string $unitName
148+
* @param string[] $units
149149
*
150150
* @return null|string
151151
*/

src/Template/AbstractUnitTemplate.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ public function getSections(): array
7979
/**
8080
* Convert properties to proper definitions in templates
8181
*
82-
* @param $properties
82+
* @param string[] $properties
8383
*
84-
* @return array
84+
* @return string[]
8585
*/
86-
protected function convertProperties($properties)
86+
protected function convertProperties(array $properties): array
8787
{
8888
return array_map([DefinitionConverter::class, 'convert'], $properties);
8989
}

src/Template/Section/AbstractSection.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,27 @@
1313
*/
1414
abstract class AbstractSection
1515
{
16-
/** @var array */
16+
/** @var string[] */
1717
protected $properties = [];
1818

1919
protected const PROPERTIES = [];
2020

2121
/**
22-
* @return array
22+
* @return string[]
2323
*/
2424
public function getProperties(): array
2525
{
2626
return $this->properties;
2727
}
2828

2929
/**
30-
* @param $name
31-
* @param $arguments
30+
* @param string $name
31+
* @param array $arguments
3232
*
3333
* @throws PropertyNotSupportedException
3434
* @return UnitSection|mixed
3535
*/
36-
public function __call($name, $arguments)
36+
public function __call(string $name, array $arguments)
3737
{
3838
preg_match('/(?<type>get|set)(?<property>.*)/', $name, $match);
3939

src/Unit/AbstractUnit.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ public function getInstanceName(): ?string
7373
abstract protected function getUnitSuffix(): string;
7474

7575
/**
76-
* @param array $commands
76+
* @param string ...$commands
7777
*
7878
* @return CommandInterface
7979
*/
80-
public function execute(...$commands): CommandInterface
80+
public function execute(string ...$commands): CommandInterface
8181
{
8282
$commands[] = implode(
8383
'.',

src/Unit/UnitInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ public function getInstanceName(): ?string;
3737
/**
3838
* Execute certain commands against the CommandDispatcher
3939
*
40-
* @param array $commands
40+
* @param string ...$commands
4141
*
4242
* @return CommandInterface
4343
*/
44-
public function execute(...$commands): CommandInterface;
44+
public function execute(string ...$commands): CommandInterface;
4545

4646
/**
4747
* Start command

0 commit comments

Comments
 (0)