Skip to content

Commit 695e45c

Browse files
JanTvrdikdg
authored andcommitted
travis: add PHPStan [Closes #157]
1 parent 08d7e42 commit 695e45c

File tree

5 files changed

+27
-2
lines changed

5 files changed

+27
-2
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ jobs:
2626
- travis_retry composer create-project nette/code-checker temp/code-checker ~2 --no-progress
2727
# Install Nette Coding Standard
2828
- travis_retry composer create-project nette/coding-standard temp/coding-standard --no-progress
29+
# Install PHPStan
30+
- travis_retry composer create-project phpstan/phpstan-shim temp/phpstan --no-progress
31+
- travis_retry composer install --no-progress --prefer-dist
2932

3033
script:
3134
- php temp/code-checker/src/code-checker.php --short-arrays --strict-types -i tests/Utils/fixtures.reflection
3235
- php temp/coding-standard/ecs check src tests --config tests/coding-standard.neon
36+
- php temp/phpstan/phpstan.phar analyse --autoload-file vendor/autoload.php --level 7 --configuration tests/phpstan.neon src
3337

3438

3539
- stage: Code Coverage

src/Utils/Html.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ final public function getHtml(): string
311311

312312
/**
313313
* Sets element's textual content.
314-
* @param IHtmlString|string $text
314+
* @param IHtmlString|string|int|float $text
315315
* @return static
316316
*/
317317
final public function setText($text)

tests/Utils/Html.basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ test(function () {
5858

5959

6060
test(function () {
61-
$el = Html::el('img')->src('image.gif')->alt('')->setText(null)->setText('any content');
61+
$el = Html::el('img')->src('image.gif')->alt('')->setText('any content');
6262
Assert::same('<img src="image.gif" alt="" />', (string) $el);
6363
Assert::same('<img src="image.gif" alt="" />', $el->startTag());
6464
Assert::same('', $el->endTag());

tests/phpstan-bootstrap.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
if (!function_exists('imagewebp')) {
6+
function imagewebp($image, $to = null, int $quality = 80): bool
7+
{
8+
}
9+
}

tests/phpstan.neon

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
parameters:
2+
bootstrap: tests/phpstan-bootstrap.php
3+
4+
ignoreErrors:
5+
# PHPStan does not support dynamic by reference return used by Nette\Utils\Strings::pcre()
6+
- '#Undefined variable: \$m#'
7+
8+
# PHPStan does not support RecursiveIteratorIterator proxying unknown method calls to inner iterator
9+
- '#RecursiveIteratorIterator::getSubPathName\(\)#'
10+
11+
# PHPStan does not support comparing null
12+
- '#Nette\\Utils\\Strings::substring\(\) expects int, int\|null given#'

0 commit comments

Comments
 (0)