Skip to content

Commit

Permalink
Static analysis with PHPStan
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jan 6, 2016
1 parent 10726ed commit 3eaa085
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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])) {
Expand Down
28 changes: 27 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
composer,
lint,
cs,
tests
tests,
phpstan
"/>

<target name="composer">
Expand All @@ -16,6 +17,7 @@
checkreturn="true"
>
<arg value="install"/>
<arg value="--ignore-platform-reqs"/>
</exec>
</target>

Expand Down Expand Up @@ -81,4 +83,28 @@
</exec>
</target>

<target name="phpstan">
<php expression="PHP_VERSION_ID >= 70000 ?'true':'false'" returnProperty="isPHP7" level="verbose" />
<if>
<equals arg1="${isPHP7}" arg2="true" />
<then>
<exec
executable="vendor/bin/phpstan"
logoutput="true"
passthru="true"
checkreturn="true"
>
<arg value="analyse"/>
<arg value="-c"/>
<arg path="phpstan.neon"/>
<arg path="SlevomatCodingStandard"/>
<arg path="tests"/>
</exec>
</then>
<else>
<echo message="PHPStan requires PHP 7." />
</else>
</if>
</target>

</project>
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
3 changes: 3 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
parameters:
excludes_analyse:
- */tests/*/data/*

0 comments on commit 3eaa085

Please sign in to comment.