Skip to content

Commit

Permalink
enabled phpstan in travis-ci
Browse files Browse the repository at this point in the history
updated phpstan to 0.11
fixed phpstan issues
moved phpstan level into configuration file
  • Loading branch information
adaamz committed Feb 12, 2019
1 parent 855e6e1 commit 12126b2
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 50 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ php:

script:
- ./vendor/bin/phpunit --configuration phpunit.xml
# TODO enable this
# - composer phpstan
- composer phpstan
- composer phpcs

before_script:
Expand Down
2 changes: 1 addition & 1 deletion api/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
{
$userid = isset($_POST['userid']) ? (int)$_POST['userid'] : 0;
$token = isset($_POST['token']) ? $_POST['token'] : "";
$address = isset($_POST['address']) ? utf8_encode($_POST['address']) : null;
$address = isset($_POST['address']) ? (int)utf8_encode($_POST['address']) : null;
$port = isset($_POST['port']) ? (int)utf8_encode($_POST['port']) : null;
$private_port = isset($_POST['private_port']) ? (int)utf8_encode($_POST['private_port']) : null;
$server_name = isset($_POST['name']) ? $_POST['name'] : "";
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"phpunit/phpunit": "^7",
"phpmd/phpmd" : "@stable",
"maximebf/debugbar": "1.*",
"phpstan/phpstan": "^0.10.1",
"phpstan/phpstan-phpunit": "^0.10",
"phpstan/phpstan-strict-rules": "^0.10",
"phpstan/phpstan-webmozart-assert": "^0.10",
"phpstan/phpstan": "^0.11",
"phpstan/phpstan-phpunit": "^0.11",
"phpstan/phpstan-strict-rules": "^0.11",
"phpstan/phpstan-webmozart-assert": "^0.11",
"squizlabs/php_codesniffer": "~3.0"
},
"autoload": {
Expand All @@ -41,6 +41,6 @@
},
"scripts": {
"phpcs": "phpcs -s --standard=phpcs/ruleset.xml --ignore=vendor/ --extensions=php .",
"phpstan": "phpstan analyse --level=5 -c phpstan/config.phpstan.neon ."
"phpstan": "phpstan analyse -c phpstan/config.phpstan.neon ."
}
}
79 changes: 40 additions & 39 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion include/Template.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ private function getFilledTemplate()
// minify html
if (!DEBUG_MODE && $this->minify)
{
$this->smarty->registerFilter("output", "minify_html");
$this->smarty->registerFilter("output", function ($tpl_output, Smarty_Internal_Template $template) {
return minify_html($tpl_output, $template);
});
}

ob_start();
Expand Down
15 changes: 13 additions & 2 deletions phpstan/config.phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,19 @@ parameters:
- upload.php

ignoreErrors:
- '~^Parameter \#2 \$value of method XMLWriter::writeAttribute\(\) expects string, (bool|float|int|\(int\|false\)) given\.$~'
- '~^Parameter \#2 \$callback of method Smarty_Internal_TemplateBase::registerFilter\(\) expects callback, string given\.$~'
-
message: '~^If condition is always true\.$~'
path: 'include/ClientSession.class.php'
-
message: '~^If condition is always true\.$~'
path: 'include/Statistic.class.php'
-
message: '~^Offset int does not exist on array\(\)\|array\(int\)\.$~'
path: 'include/StkImage.class.php'
- '~^Parameter \#2 \$value of method XMLWriter::writeAttribute\(\) expects string, (?:int|float) given\.$~'
- '~^Parameter \#2 \$value of method XMLWriter::writeAttribute\(\) expects string, \(int\|false\) given\.$~'

level: 5

rules:
#- PHPStan\Rules\BooleansInConditions\BooleanInBooleanAndRule
Expand Down

0 comments on commit 12126b2

Please sign in to comment.