Skip to content

Commit d4dd5f2

Browse files
committed
uses nette/phpstan-rules
1 parent ca3a81f commit d4dd5f2

3 files changed

Lines changed: 56 additions & 1 deletion

File tree

composer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
"nette/http": "^3.2",
2424
"nette/tester": "^2.6",
2525
"tracy/tracy": "^2.9",
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
"mockery/mockery": "^1.6@stable"
2830
},
2931
"conflict": {
@@ -45,5 +47,10 @@
4547
"branch-alias": {
4648
"dev-master": "3.2-dev"
4749
}
50+
},
51+
"config": {
52+
"allow-plugins": {
53+
"phpstan/extension-installer": true
54+
}
4855
}
4956
}

tests/types/security-types.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php declare(strict_types=1);
2+
3+
/**
4+
* PHPStan type tests.
5+
*/
6+
7+
use Nette\Security\IIdentity;
8+
use Nette\Security\Permission;
9+
use Nette\Security\User;
10+
use function PHPStan\Testing\assertType;
11+
12+
13+
function testPermissionGetRoles(Permission $acl): void
14+
{
15+
assertType('list<string>', $acl->getRoles());
16+
}
17+
18+
19+
function testPermissionGetRoleParents(Permission $acl): void
20+
{
21+
$acl->addRole('admin');
22+
assertType('list<string>', $acl->getRoleParents('admin'));
23+
}
24+
25+
26+
function testPermissionGetResources(Permission $acl): void
27+
{
28+
assertType('list<string>', $acl->getResources());
29+
}
30+
31+
32+
function testIIdentityGetId(IIdentity $identity): void
33+
{
34+
assertType('int|string', $identity->getId());
35+
}
36+
37+
38+
function testUserGetId(User $user): void
39+
{
40+
assertType('int|string|null', $user->getId());
41+
}

tests/types/security-types.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__ . '/security-types.php');

0 commit comments

Comments
 (0)