Skip to content

Commit 1222c37

Browse files
committed
Increase PHPStan level to 5
1 parent 3849cba commit 1222c37

24 files changed

+87
-70
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
| grep -v tests/TestCase.php \
5252
&& (echo "UNKNOWN FILES DETECTED" && travis_terminate 1) || echo "NO UNKNOWN FILES"
5353
- ./check_trailing_spaces.sh || travis_terminate 1
54-
- php -d auto_prepend_file=dev-tools/vendor/autoload.php ./dev-tools/tools/phpstan analyse
54+
- dev-tools/vendor/bin/phpstan analyse
5555
- if [ -n "$CHANGED_PHP_FILES" ]; then ./dev-tools/vendor/bin/phpmd `echo "$CHANGED_PHP_FILES" | xargs | sed 's/ /,/g'` text phpmd.xml || travis_terminate 1; fi
5656
- ./dev-tools/tools/composer-require-checker check composer.json --config-file $(realpath .composer-require-checker.json) || travis_terminate 1
5757
- ./dev-tools/tools/composer-normalize composer.json --dry-run

dev-tools/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"jangregor/phpstan-prophecy": "^0.6",
88
"mi-schi/phpmd-extension": "^4.3",
99
"phpmd/phpmd": "^2.6",
10+
"phpstan/phpstan": "0.12.18",
1011
"phpstan/phpstan-phpunit": "^0.12"
1112
},
1213
"conflict": {

dev-tools/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fi
3939
bin/phive --version
4040

4141
echo λλλ phive packages
42-
./bin/phive install --trust-gpg-keys D2CCAC42F6295E7D,8E730BA25823D8B5,C00543248C87FB13,CF1A108D0E7AE720
42+
./bin/phive install --trust-gpg-keys D2CCAC42F6295E7D,8E730BA25823D8B5,C00543248C87FB13
4343

4444
echo λλλ checkbashisms
4545
if [ ! -x bin/checkbashisms ]; then

dev-tools/phive.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
<phive xmlns="https://phar.io/phive">
33
<phar name="composer-normalize" version="^2.1.2" installed="2.1.2" location="./tools/composer-normalize" copy="false"/>
44
<phar name="composer-require-checker" version="^2.0" installed="2.0.0" location="./tools/composer-require-checker" copy="false"/>
5-
<phar name="phpstan" version="^0.12" installed="0.12.9" location="./tools/phpstan" copy="true"/>
65
</phive>

phpstan.neon

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
includes:
22
- dev-tools/vendor/jangregor/phpstan-prophecy/src/extension.neon
3+
- dev-tools/vendor/phpstan/phpstan/conf/bleedingEdge.neon
34
- dev-tools/vendor/phpstan/phpstan-phpunit/extension.neon
45

56
parameters:
6-
level: 3
7+
level: 5
78
paths:
89
- src
910
- tests
@@ -16,3 +17,33 @@ parameters:
1617
-
1718
message: '/^Unsafe usage of new static\(\)\.$/'
1819
path: src/Config.php
20+
-
21+
message: '/^Else branch is unreachable because previous condition is always true\.$/'
22+
path: src/Event/Event.php
23+
-
24+
message: '/^Strict comparison using !== between ''@git-commit@'' and ''@git-commit@'' will always evaluate to false\.$/'
25+
path: src/Console/Application.php
26+
-
27+
message: '/^Result of && is always false\.$/'
28+
path: src/Config.php
29+
-
30+
message: '/^Strict comparison using === between false and true will always evaluate to false\.$/'
31+
path: src/Config.php
32+
-
33+
message: '/^Else branch is unreachable because ternary operator condition is always true\.$/'
34+
paths:
35+
- src/Config.php
36+
- src/Tokenizer/Token.php
37+
-
38+
message: '/^Parameter #1 \$fixers of method PhpCsFixer\\Config::registerCustomFixers\(\) expects iterable<PhpCsFixer\\Fixer\\FixerInterface>, string given\.$/'
39+
path: tests/ConfigTest.php
40+
-
41+
message: '/^Parameter #1 \$options of method PhpCsFixer\\FixerConfiguration\\FixerConfigurationResolverRootless::resolve\(\) expects array<string, mixed>, array<int, string> given\.$/'
42+
path: tests/FixerConfiguration/FixerConfigurationResolverRootlessTest.php
43+
-
44+
message: '/^Parameter #1 \$function of function register_shutdown_function expects callable\(\): void, array\(\$this\(PhpCsFixer\\FileRemoval\), ''clean''\) given\.$/'
45+
path: src/FileRemoval.php
46+
-
47+
message: '/^Parameter #1 \$finder of method PhpCsFixer\\Config::setFinder\(\) expects iterable<string>, int given\.$/'
48+
path: tests/ConfigTest.php
49+
tipsOfTheDay: false

src/AbstractNoUselessElseFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private function isInConditionWithoutBraces(Tokens $tokens, $index, $lowerLimitI
162162
return true;
163163
}
164164

165-
if ($token->equals(';', '}')) {
165+
if ($token->equals(';')) {
166166
return false;
167167
}
168168
if ($token->equals('{')) {

src/Cache/Cache.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,6 @@ public function get($file)
5555

5656
public function set($file, $hash)
5757
{
58-
if (!\is_int($hash)) {
59-
throw new \InvalidArgumentException(sprintf(
60-
'Value needs to be an integer, got "%s".',
61-
\is_object($hash) ? \get_class($hash) : \gettype($hash)
62-
));
63-
}
64-
6558
$this->hashes[$file] = $hash;
6659
}
6760

@@ -105,7 +98,7 @@ public static function fromJson($json)
10598
if (null === $data && JSON_ERROR_NONE !== json_last_error()) {
10699
throw new \InvalidArgumentException(sprintf(
107100
'Value needs to be a valid JSON string, got "%s", error: "%s".',
108-
\is_object($json) ? \get_class($json) : \gettype($json),
101+
$json,
109102
json_last_error_msg()
110103
));
111104
}

src/ConfigurationException/InvalidConfigurationException.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
class InvalidConfigurationException extends \InvalidArgumentException
2626
{
2727
/**
28-
* @param string $message
29-
* @param null|int $code
28+
* @param string $message
29+
* @param null|int $code
30+
* @param null|\Throwable $previous
3031
*/
31-
public function __construct($message, $code = null, \Exception $previous = null)
32+
public function __construct($message, $code = null, $previous = null)
3233
{
3334
parent::__construct(
3435
$message,

src/ConfigurationException/InvalidFixerConfigurationException.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ class InvalidFixerConfigurationException extends InvalidConfigurationException
3030
private $fixerName;
3131

3232
/**
33-
* @param string $fixerName
34-
* @param string $message
33+
* @param string $fixerName
34+
* @param string $message
35+
* @param null|\Throwable $previous
3536
*/
36-
public function __construct($fixerName, $message, \Exception $previous = null)
37+
public function __construct($fixerName, $message, $previous = null)
3738
{
3839
parent::__construct(
3940
sprintf('[%s] %s', $fixerName, $message),

src/Console/Application.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ public function doRun(InputInterface $input, OutputInterface $output)
9797
*/
9898
public function getLongVersion()
9999
{
100-
$version = parent::getLongVersion();
101-
if (self::VERSION_CODENAME) {
102-
$version .= ' <info>'.self::VERSION_CODENAME.'</info>';
103-
}
104-
$version .= ' by <comment>Fabien Potencier</comment> and <comment>Dariusz Ruminski</comment>';
100+
$version = sprintf(
101+
'%s <info>%s</info> by <comment>Fabien Potencier</comment> and <comment>Dariusz Ruminski</comment>',
102+
parent::getLongVersion(),
103+
self::VERSION_CODENAME
104+
);
105105

106106
$commit = '@git-commit@';
107107

0 commit comments

Comments
 (0)