From 3eaa085fa413b5499c4c6abceb8553fcbab4ee5b Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Sat, 19 Dec 2015 10:56:13 +0100 Subject: [PATCH] Static analysis with PHPStan --- .travis.yml | 2 +- .../AlphabeticallySortedUsesSniff.php | 3 +- build.xml | 28 ++++++++++++++++++- composer.json | 1 + phpstan.neon | 3 ++ 5 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 phpstan.neon diff --git a/.travis.yml b/.travis.yml index bc4166459..c18098faf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ php: before_script: - composer self-update script: - - composer install + - composer install --ignore-platform-reqs - vendor/bin/phing after_script: - php vendor/bin/coveralls -v diff --git a/SlevomatCodingStandard/Sniffs/Namespaces/AlphabeticallySortedUsesSniff.php b/SlevomatCodingStandard/Sniffs/Namespaces/AlphabeticallySortedUsesSniff.php index d82c18d6d..a45da342d 100644 --- a/SlevomatCodingStandard/Sniffs/Namespaces/AlphabeticallySortedUsesSniff.php +++ b/SlevomatCodingStandard/Sniffs/Namespaces/AlphabeticallySortedUsesSniff.php @@ -99,7 +99,8 @@ private function fixAlphabeticalOrder( */ private function compareStrings($a, $b) { - for ($i = 0; $i < min(strlen($a), strlen($b)); $i++) { + $i = 0; + for (; $i < min(strlen($a), strlen($b)); $i++) { if ($this->isSpecialCharacter($a[$i]) && !$this->isSpecialCharacter($b[$i])) { return -1; } elseif (!$this->isSpecialCharacter($a[$i]) && $this->isSpecialCharacter($b[$i])) { diff --git a/build.xml b/build.xml index bbd8b4b5b..698885026 100644 --- a/build.xml +++ b/build.xml @@ -5,7 +5,8 @@ composer, lint, cs, - tests + tests, + phpstan "/> @@ -16,6 +17,7 @@ checkreturn="true" > + @@ -81,4 +83,28 @@ + + + + + + + + + + + + + + + + + + + diff --git a/composer.json b/composer.json index 376d56e89..8f7c8b859 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,7 @@ "require-dev": { "consistence/coding-standard": "^0.10", "phing/phing": "^2.9", + "phpstan/phpstan": "dev-dev#1cb3904e17", "phpunit/phpunit": "^5.0", "satooshi/php-coveralls": "dev-master" }, diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 000000000..0928e5160 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,3 @@ +parameters: + excludes_analyse: + - */tests/*/data/*