Skip to content

Commit

Permalink
Introduce PHPStan
Browse files Browse the repository at this point in the history
  • Loading branch information
szepeviktor committed Jan 25, 2020
1 parent 1a2e7f7 commit ba68ef9
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ install:
script:
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else composer test ; fi
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi
- |
if [[ $(phpenv version-name) == '7.3' ]]; then
composer require --dev "phpstan/phpstan:^0.12.7"
wget -qO- https://github.com/squizlabs/PHP_CodeSniffer/commit/2ecd8dc15364cdd6e5089e82ffef2b205c98c412.patch | patch -d vendor/squizlabs/php_codesniffer/ -p 1
vendor/bin/phpstan analyze
fi
after_script:
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry php vendor/bin/php-coveralls -v ; fi
Expand Down
18 changes: 18 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
includes:
- phar://phpstan.phar/conf/bleedingEdge.neon
parameters:
level: 2
# TODO Reach level MAX!
# level: 4
# level: max
inferPrivatePropertyTypeFromConstructor: true
paths:
- src/
# TODO Test tests!
# - test/
autoload_files:
- vendor/squizlabs/php_codesniffer/autoload.php
ignoreErrors:
# TODO These are way too easy to fix!
- '#^Access to an undefined property WebimpressCodingStandard\\\S+\.$#'
- '#^Variable \$\S+ might not be defined\.$#'
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class ReturnTypeSniff implements Sniff
use MethodsTrait;

/**
* @var string
* @var int|null
*/
private $returnDoc;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function process(File $phpcsFile, $stackPtr)
}

/**
* @return string[][]
* @return array<int, array{ptrUse:int, name:string, ptrEnd:int, string:string, type:string}>
*/
private function getUseStatements(File $phpcsFile, int $scopePtr) : array
{
Expand Down Expand Up @@ -231,7 +231,7 @@ private function clearName(string $name) : string
}

/**
* @param string[][] $uses
* @param array<int, array{ptrUse:int, name:string, ptrEnd:int, string:string, type:string}> $uses
*/
private function fixAlphabeticalOrder(File $phpcsFile, array $uses) : void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ private function import(string $type, string $fqn, string $alias) : array
}

/**
* @param string[][] $references
* @param array<string, string> $references
*/
private function importReferences(File $phpcsFile, int $namespacePtr, array $references) : void
{
Expand Down

0 comments on commit ba68ef9

Please sign in to comment.