Skip to content

Commit ba68ef9

Browse files
committed
Introduce PHPStan
Fixes webimpress#52
1 parent 1a2e7f7 commit ba68ef9

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ install:
6666
script:
6767
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else composer test ; fi
6868
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi
69+
- |
70+
if [[ $(phpenv version-name) == '7.3' ]]; then
71+
composer require --dev "phpstan/phpstan:^0.12.7"
72+
wget -qO- https://github.com/squizlabs/PHP_CodeSniffer/commit/2ecd8dc15364cdd6e5089e82ffef2b205c98c412.patch | patch -d vendor/squizlabs/php_codesniffer/ -p 1
73+
vendor/bin/phpstan analyze
74+
fi
6975
7076
after_script:
7177
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry php vendor/bin/php-coveralls -v ; fi

phpstan.neon.dist

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
includes:
2+
- phar://phpstan.phar/conf/bleedingEdge.neon
3+
parameters:
4+
level: 2
5+
# TODO Reach level MAX!
6+
# level: 4
7+
# level: max
8+
inferPrivatePropertyTypeFromConstructor: true
9+
paths:
10+
- src/
11+
# TODO Test tests!
12+
# - test/
13+
autoload_files:
14+
- vendor/squizlabs/php_codesniffer/autoload.php
15+
ignoreErrors:
16+
# TODO These are way too easy to fix!
17+
- '#^Access to an undefined property WebimpressCodingStandard\\\S+\.$#'
18+
- '#^Variable \$\S+ might not be defined\.$#'

src/WebimpressCodingStandard/Sniffs/Functions/ReturnTypeSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class ReturnTypeSniff implements Sniff
9696
use MethodsTrait;
9797

9898
/**
99-
* @var string
99+
* @var int|null
100100
*/
101101
private $returnDoc;
102102

src/WebimpressCodingStandard/Sniffs/Namespaces/AlphabeticallySortedUsesSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public function process(File $phpcsFile, $stackPtr)
147147
}
148148

149149
/**
150-
* @return string[][]
150+
* @return array<int, array{ptrUse:int, name:string, ptrEnd:int, string:string, type:string}>
151151
*/
152152
private function getUseStatements(File $phpcsFile, int $scopePtr) : array
153153
{
@@ -231,7 +231,7 @@ private function clearName(string $name) : string
231231
}
232232

233233
/**
234-
* @param string[][] $uses
234+
* @param array<int, array{ptrUse:int, name:string, ptrEnd:int, string:string, type:string}> $uses
235235
*/
236236
private function fixAlphabeticalOrder(File $phpcsFile, array $uses) : void
237237
{

src/WebimpressCodingStandard/Sniffs/PHP/DisallowFqnSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ private function import(string $type, string $fqn, string $alias) : array
594594
}
595595

596596
/**
597-
* @param string[][] $references
597+
* @param array<string, string> $references
598598
*/
599599
private function importReferences(File $phpcsFile, int $namespacePtr, array $references) : void
600600
{

0 commit comments

Comments
 (0)