Skip to content

Commit 4a2aab5

Browse files
committed
coding style
1 parent 8bc82eb commit 4a2aab5

File tree

7 files changed

+15
-19
lines changed

7 files changed

+15
-19
lines changed

src/Bridges/SecurityDI/SecurityExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public function getConfigSchema(): Nette\Schema\Schema
4040
'password' => Expect::string(),
4141
'roles' => Expect::anyOf(Expect::string(), Expect::listOf('string')),
4242
'data' => Expect::array(),
43-
])->castTo('array')
44-
)
43+
])->castTo('array'),
44+
),
4545
),
4646
'roles' => Expect::arrayOf('string|array|null'), // role => parent(s)
4747
'resources' => Expect::arrayOf('string|null'), // resource => parent

src/Bridges/SecurityHttp/CookieStorage.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,8 @@ public function saveAuthentication(IIdentity $identity): void
6464
$this->cookieName,
6565
$uid,
6666
$this->cookieExpiration,
67-
null,
68-
$this->cookieDomain,
69-
null,
70-
true,
71-
$this->cookieSameSite
67+
domain: $this->cookieDomain,
68+
sameSite: $this->cookieSameSite,
7269
);
7370
}
7471

@@ -78,8 +75,7 @@ public function clearAuthentication(bool $clearIdentity): void
7875
$this->uid = '';
7976
$this->response->deleteCookie(
8077
$this->cookieName,
81-
null,
82-
$this->cookieDomain
78+
domain: $this->cookieDomain,
8379
);
8480
}
8581

@@ -106,7 +102,7 @@ public function setExpiration(?string $expire, bool $clearIdentity): void
106102
public function setCookieParameters(
107103
?string $name = null,
108104
?string $domain = null,
109-
?string $sameSite = null
105+
?string $sameSite = null,
110106
) {
111107
$this->cookieName = $name ?? $this->cookieName;
112108
$this->cookieDomain = $domain ?? $this->cookieDomain;

src/Security/Permission.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ public function allow(
391391
$roles = self::ALL,
392392
$resources = self::ALL,
393393
$privileges = self::ALL,
394-
?callable $assertion = null
394+
?callable $assertion = null,
395395
) {
396396
$this->setRule(true, self::ALLOW, $roles, $resources, $privileges, $assertion);
397397
return $this;
@@ -411,7 +411,7 @@ public function deny(
411411
$roles = self::ALL,
412412
$resources = self::ALL,
413413
$privileges = self::ALL,
414-
?callable $assertion = null
414+
?callable $assertion = null,
415415
) {
416416
$this->setRule(true, self::DENY, $roles, $resources, $privileges, $assertion);
417417
return $this;

src/Security/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function __construct(
7373
?IUserStorage $legacyStorage = null,
7474
?IAuthenticator $authenticator = null,
7575
?Authorizator $authorizator = null,
76-
?UserStorage $storage = null
76+
?UserStorage $storage = null,
7777
) {
7878
$this->storage = $storage ?? $legacyStorage; // back compatibility
7979
if (!$this->storage) {

tests/Security.Http/CookieStorage.getState.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ $storage = new CookieStorage($request, $response);
1515
Assert::same([false, null, null], $storage->getState());
1616

1717
// short id
18-
$request = new Nette\Http\Request(new Nette\Http\UrlScript, [], [], ['userid' => 'short']);
18+
$request = new Nette\Http\Request(new Nette\Http\UrlScript, cookies: ['userid' => 'short']);
1919
$storage = new CookieStorage($request, $response);
2020
Assert::same([false, null, null], $storage->getState());
2121

2222
// correct id
2323
$id = '123456789123456';
24-
$request = new Nette\Http\Request(new Nette\Http\UrlScript, [], [], ['userid' => $id]);
24+
$request = new Nette\Http\Request(new Nette\Http\UrlScript, cookies: ['userid' => $id]);
2525
$storage = new CookieStorage($request, $response);
2626
Assert::equal([true, new SimpleIdentity($id), null], $storage->getState());
2727

2828
// custom cookie
29-
$request = new Nette\Http\Request(new Nette\Http\UrlScript, [], [], ['foo' => $id]);
29+
$request = new Nette\Http\Request(new Nette\Http\UrlScript, cookies: ['foo' => $id]);
3030
$storage = new CookieStorage($request, $response);
3131
$storage->setCookieParameters('foo');
3232
Assert::equal([true, new SimpleIdentity($id), null], $storage->getState());

tests/Security/Passwords.hash().phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ require __DIR__ . '/../bootstrap.php';
1414

1515

1616
Assert::truthy(
17-
preg_match('#^\$.{50,}\z#', (new Passwords)->hash('my-password'))
17+
preg_match('#^\$.{50,}\z#', (new Passwords)->hash('my-password')),
1818
);
1919

2020
Assert::truthy(
21-
preg_match('#^\$2y\$05\$.{53}\z#', (new Passwords(PASSWORD_BCRYPT, ['cost' => 5]))->hash('dg'))
21+
preg_match('#^\$2y\$05\$.{53}\z#', (new Passwords(PASSWORD_BCRYPT, ['cost' => 5]))->hash('dg')),
2222
);
2323

2424
$hash = (new Passwords(PASSWORD_BCRYPT))->hash('dg');

tests/Security/User.authorization.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Authorizator implements Nette\Security\Authorizator
4242
{
4343
public function isAllowed($role = self::ALL, $resource = self::ALL, $privilege = self::ALL): bool
4444
{
45-
return $role === 'admin' && strpos($resource, 'jany') === false;
45+
return $role === 'admin' && !str_contains($resource, 'jany');
4646
}
4747
}
4848

0 commit comments

Comments
 (0)