Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
leeqvip authored and StyleCIBot committed Nov 7, 2018
1 parent f8544c9 commit a0812f3
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/demo.php
Expand Up @@ -13,7 +13,7 @@
$obj = 'data1'; // 将被访问的资源。buildRoleLinks
$act = 'read'; // 用户对资源执行的操作。

if ($e->enforce($sub, $obj, $act) === true) {
if (true === $e->enforce($sub, $obj, $act)) {
// 允许 alice 读取 data1
echo '允许 alice 读取 data1';
} else {
Expand Down
6 changes: 4 additions & 2 deletions src/Config/Config.php
Expand Up @@ -71,24 +71,26 @@ private function parseBuffer($buf)
$buf = preg_replace('/[\r\n]+/', PHP_EOL, $buf);
$buf = explode(PHP_EOL, $buf);

for ($i = 0; $i <= \count($buf); $i++) {
for ($i = 0; $i <= \count($buf); ++$i) {
if ($canWrite) {
$this->write($section, $lineNum, $buffer);
$canWrite = false;
}

$lineNum++;
++$lineNum;
$line = isset($buf[$i]) ? $buf[$i] : '';
if ($i == \count($buf)) {
if (\strlen($buffer) > 0) {
$this->write($section, $lineNum, $buffer);
}

break;
}
$line = trim($line);

if ('' == $line || self::DEFAULT_COMMENT == substr($line, 0, 1) || self::DEFAULT_COMMENT_SEM == substr($line, 0, 1)) {
$canWrite = true;

continue;
} elseif ('[' == substr($line, 0, 1) && ']' == substr($line, -1)) {
if (\strlen($buffer) > 0) {
Expand Down
4 changes: 4 additions & 0 deletions src/Effect/DefaultEffector.php
Expand Up @@ -27,6 +27,7 @@ public function mergeEffects($expr, array $effects, array $results)
foreach ($effects as $eft) {
if (self::ALLOW == $eft) {
$result = true;

break;
}
}
Expand All @@ -35,6 +36,7 @@ public function mergeEffects($expr, array $effects, array $results)
foreach ($effects as $eft) {
if (self::DENY == $eft) {
$result = false;

break;
}
}
Expand All @@ -44,6 +46,7 @@ public function mergeEffects($expr, array $effects, array $results)
$result = true;
} elseif (self::DENY == $eft) {
$result = false;

break;
}
}
Expand All @@ -55,6 +58,7 @@ public function mergeEffects($expr, array $effects, array $results)
} else {
$result = false;
}

break;
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/Effect/Effector.php
Expand Up @@ -10,7 +10,9 @@
abstract class Effector
{
const ALLOW = 0;

const INDETERMINATE = 1;

const DENY = 2;

abstract public function mergeEffects($expr, array $effects, array $results);
Expand Down
2 changes: 2 additions & 0 deletions src/Enforcer.php
Expand Up @@ -408,11 +408,13 @@ public function enforce(...$rvals)
if (\is_bool($result)) {
if (!$result) {
$policyEffects[$i] = Effector::INDETERMINATE;

continue;
}
} elseif (\is_float($result)) {
if (0 == $result) {
$policyEffects[$i] = Effector::INDETERMINATE;

continue;
} else {
$matcherResults[$i] = $result;
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Model.php
Expand Up @@ -75,7 +75,7 @@ private function loadSection($cfg, $sec)
if (!$this->loadAssertion($cfg, $sec, $sec.$this->getKeySuffix($i))) {
break;
} else {
$i++;
++$i;
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/Model/Policy.php
Expand Up @@ -62,6 +62,7 @@ public function getFilteredPolicy($sec, $ptype, $fieldIndex, ...$fieldValues)
foreach ($fieldValues as $i => $fieldValue) {
if ('' != $fieldValue && $rule[$fieldIndex + $i] != $fieldValue) {
$matched = false;

break;
}
}
Expand Down Expand Up @@ -127,6 +128,7 @@ public function removeFilteredPolicy($sec, $ptype, $fieldIndex, ...$fieldValues)
foreach ($fieldValues as $i => $fieldValue) {
if ('' != $fieldValue && $rule[$fieldIndex + $i] != $fieldValue) {
$matched = false;

break;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Rbac/Role.php
Expand Up @@ -10,6 +10,7 @@
class Role
{
public $name = '';

private $roles = [];

public function __construct($name)
Expand Down
2 changes: 1 addition & 1 deletion src/Util/Util.php
Expand Up @@ -37,7 +37,7 @@ public static function arrayRemoveDuplicates(&$s)
if (!isset($found[$x])) {
$found[$x] = true;
$s[$j] = $s[$i];
$j++;
++$j;
}
}
$s = \array_slice($s, 0, $j);
Expand Down

0 comments on commit a0812f3

Please sign in to comment.