Skip to content

Commit 2f58118

Browse files
committed
coding style
1 parent 7cf035a commit 2f58118

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

src/Security/Identity.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ public function __construct($id, $roles = null, iterable $data = null)
4141
{
4242
$this->setId($id);
4343
$this->setRoles((array) $roles);
44-
$this->data = $data instanceof \Traversable ? iterator_to_array($data) : (array) $data;
44+
$this->data = $data instanceof \Traversable
45+
? iterator_to_array($data)
46+
: (array) $data;
4547
}
4648

4749

src/Security/Permission.php

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,12 @@ public function removeAllResources()
389389
* @param string|string[]|null $privileges
390390
* @return static
391391
*/
392-
public function allow($roles = self::ALL, $resources = self::ALL, $privileges = self::ALL, callable $assertion = null)
393-
{
392+
public function allow(
393+
$roles = self::ALL,
394+
$resources = self::ALL,
395+
$privileges = self::ALL,
396+
callable $assertion = null
397+
) {
394398
$this->setRule(true, self::ALLOW, $roles, $resources, $privileges, $assertion);
395399
return $this;
396400
}
@@ -405,8 +409,12 @@ public function allow($roles = self::ALL, $resources = self::ALL, $privileges =
405409
* @param string|string[]|null $privileges
406410
* @return static
407411
*/
408-
public function deny($roles = self::ALL, $resources = self::ALL, $privileges = self::ALL, callable $assertion = null)
409-
{
412+
public function deny(
413+
$roles = self::ALL,
414+
$resources = self::ALL,
415+
$privileges = self::ALL,
416+
callable $assertion = null
417+
) {
410418
$this->setRule(true, self::DENY, $roles, $resources, $privileges, $assertion);
411419
return $this;
412420
}
@@ -521,7 +529,7 @@ protected function setRule(bool $toAdd, bool $type, $roles, $resources, $privile
521529
'allPrivileges' => [
522530
'type' => self::DENY,
523531
'assert' => null,
524-
],
532+
],
525533
'byPrivilege' => [],
526534
];
527535
}
@@ -557,8 +565,8 @@ protected function setRule(bool $toAdd, bool $type, $roles, $resources, $privile
557565
* and its respective parents are checked similarly before the lower-priority parents of
558566
* the Role are checked.
559567
*
560-
* @param string|null|IRole $role
561-
* @param string|null|IResource $resource
568+
* @param string|IRole|null $role
569+
* @param string|IResource|null $resource
562570
* @param string|null $privilege
563571
* @throws Nette\InvalidStateException
564572
*/
@@ -582,7 +590,10 @@ public function isAllowed($role = self::ALL, $resource = self::ALL, $privilege =
582590

583591
do {
584592
// depth-first search on $role if it is not 'allRoles' pseudo-parent
585-
if ($role !== null && ($result = $this->searchRolePrivileges($privilege === self::ALL, $role, $resource, $privilege)) !== null) {
593+
if (
594+
$role !== null
595+
&& ($result = $this->searchRolePrivileges($privilege === self::ALL, $role, $resource, $privilege)) !== null
596+
) {
586597
break;
587598
}
588599

src/Security/User.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,18 @@ class User
5353
/** @var IAuthorizator|null */
5454
private $authorizator;
5555

56-
/** @var IIdentity|null|false false means undefined */
56+
/** @var IIdentity|false|null false means undefined */
5757
private $identity = false;
5858

5959
/** @var bool|null */
6060
private $authenticated;
6161

6262

63-
public function __construct(IUserStorage $storage, IAuthenticator $authenticator = null, IAuthorizator $authorizator = null)
64-
{
63+
public function __construct(
64+
IUserStorage $storage,
65+
IAuthenticator $authenticator = null,
66+
IAuthorizator $authorizator = null
67+
) {
6568
$this->storage = $storage;
6669
$this->authenticator = $authenticator;
6770
$this->authorizator = $authorizator;

0 commit comments

Comments
 (0)