Skip to content

Commit 9efaa14

Browse files
committed
uses nette/phpstan-rules
1 parent 4ec1558 commit 9efaa14

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

composer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
"nette/tester": "^2.6",
2424
"nette/security": "^3.0",
2525
"tracy/tracy": "^2.8",
26-
"phpstan/phpstan-nette": "^2.0@stable"
26+
"phpstan/phpstan": "^2.1@stable",
27+
"phpstan/extension-installer": "^1.4@stable",
28+
"nette/phpstan-rules": "^1.0"
2729
},
2830
"conflict": {
2931
"nette/di": "<3.0.3",
@@ -50,5 +52,10 @@
5052
"branch-alias": {
5153
"dev-master": "3.3-dev"
5254
}
55+
},
56+
"config": {
57+
"allow-plugins": {
58+
"phpstan/extension-installer": true
59+
}
5360
}
5461
}

tests/types/TypesTest.phpt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php declare(strict_types=1);
2+
3+
require __DIR__ . '/../bootstrap.php';
4+
5+
use Nette\PHPStan\Tester\TypeAssert;
6+
7+
TypeAssert::assertTypes(__DIR__ . '/http-types.php');

tests/types/http-types.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php declare(strict_types=1);
2+
3+
/**
4+
* PHPStan type tests for Http.
5+
* Run: vendor/bin/phpstan analyse tests/types
6+
*/
7+
8+
use Nette\Http\FileUpload;
9+
use Nette\Http\SessionSection;
10+
use function PHPStan\Testing\assertType;
11+
12+
13+
function testSessionSectionIterator(SessionSection $section): void
14+
{
15+
foreach ($section as $key => $value) {
16+
assertType('string', $key);
17+
assertType('mixed', $value);
18+
}
19+
}
20+
21+
22+
function testSessionSectionArrayAccess(SessionSection $section): void
23+
{
24+
$section->remove();
25+
$value = $section['key'];
26+
assertType('mixed', $value);
27+
}
28+
29+
30+
function testFileUploadGetImageSize(FileUpload $upload): void
31+
{
32+
$size = $upload->getImageSize();
33+
assertType('array{int, int}|null', $size);
34+
}

0 commit comments

Comments
 (0)