Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
}
],
"require": {
"php": ">=7.0",
"php": ">=7.1",
"psr/cache": "~1.0",
"symfony/config": "~3.0|^4.0",
"symfony/yaml" : "~3.0|^4.0",
"symfony/yaml" : "~3.0|^4.0",
"friendsofphp/php-cs-fixer": "^2.12"
},
"support": {
Expand All @@ -30,6 +30,6 @@
}
},
"require-dev": {
"phpunit/phpunit": "^6.5"
"phpunit/phpunit": "^7.0"
}
}
19 changes: 10 additions & 9 deletions src/Manager/AttributeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

namespace PhpAbac\Manager;

use PhpAbac\Configuration\Configuration;

use PhpAbac\Model\{
AbstractAttribute,
Attribute,
EnvironmentAttribute
};
use InvalidArgumentException;
use PhpAbac\Configuration\ConfigurationInterface;
use PhpAbac\Model\AbstractAttribute;
use PhpAbac\Model\Attribute;
use PhpAbac\Model\EnvironmentAttribute;

class AttributeManager implements AttributeManagerInterface
{
Expand All @@ -24,8 +22,11 @@ class AttributeManager implements AttributeManagerInterface
* Options list :
* 'getter_prefix' => Prefix to add before getter name (default)'get'
* 'getter_name_transformation_function' => Function to apply on the getter name ( before adding prefix ) (default)'ucfirst'
*
* @param ConfigurationInterface $configuration
* @param array $options
*/
public function __construct(Configuration $configuration, array $options = [])
public function __construct(ConfigurationInterface $configuration, array $options = [])
{
$this->attributes = $configuration->getAttributes();

Expand Down Expand Up @@ -96,7 +97,7 @@ private function retrieveClassicAttribute(Attribute $attribute, $object, array $
$getter = $this->getter_prefix.call_user_func($this->getter_name_transformation_function, $property);
// Use is_callable, instead of method_exists, to deal with __call magic method
if (!is_callable([$propertyValue,$getter])) {
throw new \InvalidArgumentException('There is no getter for the "'.$attribute->getProperty().'" attribute for object "'.get_class($propertyValue).'" with getter "'.$getter.'"');
throw new InvalidArgumentException('There is no getter for the "'.$attribute->getProperty().'" attribute for object "'.get_class($propertyValue).'" with getter "'.$getter.'"');
}
if (($propertyValue = call_user_func_array([
$propertyValue,
Expand Down
14 changes: 6 additions & 8 deletions src/Manager/PolicyRuleManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

namespace PhpAbac\Manager;

use PhpAbac\Configuration\Configuration;

use PhpAbac\Model\{
PolicyRule,
PolicyRuleAttribute
};
use InvalidArgumentException;
use PhpAbac\Configuration\ConfigurationInterface;
use PhpAbac\Model\PolicyRule;
use PhpAbac\Model\PolicyRuleAttribute;

class PolicyRuleManager implements PolicyRuleManagerInterface
{
Expand All @@ -16,7 +14,7 @@ class PolicyRuleManager implements PolicyRuleManagerInterface
/** @var array **/
private $rules = [];

public function __construct(Configuration $configuration, AttributeManager $attributeManager)
public function __construct(ConfigurationInterface $configuration, AttributeManager $attributeManager)
{
$this->attributeManager = $attributeManager;
$this->rules = $configuration->getRules();
Expand All @@ -25,7 +23,7 @@ public function __construct(Configuration $configuration, AttributeManager $attr
public function getRule(string $ruleName, $user, $resource): array
{
if (!isset($this->rules[$ruleName])) {
throw new \InvalidArgumentException('The given rule "' . $ruleName . '" is not configured');
throw new InvalidArgumentException('The given rule "' . $ruleName . '" is not configured');
}

// TODO check if this is really useful
Expand Down
2 changes: 1 addition & 1 deletion tests/AbacTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AbacTest extends \PHPUnit\Framework\TestCase
/** @var array **/
protected $importSet;

public function setUp()
public function setUp(): void
{
$this->basicSet = [
AbacFactory::getAbac([__DIR__ . '/fixtures/policy_rules.yml']),
Expand Down
2 changes: 1 addition & 1 deletion tests/Cache/Item/MemoryCacheItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MemoryCacheItemTest extends \PHPUnit\Framework\TestCase
/** @var MemoryCacheItem **/
protected $item;

public function setUp()
public function setUp(): void
{
$this->item = new MemoryCacheItem('php_abac.test');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Cache/Item/TextCacheItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TextCacheItemTest extends \PHPUnit\Framework\TestCase
/** @var TextCacheItem **/
protected $item;

public function setUp()
public function setUp(): void
{
$this->item = new TextCacheItem('php_abac.test');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Cache/Pool/MemoryCacheItemPoolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MemoryCacheItemPoolTest extends \PHPUnit\Framework\TestCase
{
protected $pool;

public function setUp()
public function setUp(): void
{
$this->pool = new MemoryCacheItemPool();
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Cache/Pool/TextCacheItemPoolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ class TextCacheItemPoolTest extends \PHPUnit\Framework\TestCase
{
protected $pool;

public function setUp()
public function setUp(): void
{
$this->pool = new TextCacheItemPool([
'cache_folder' => __DIR__ . '/../../../data/cache/test'
]);
}

public function tearDown()
public function tearDown(): void
{
$this->pool->clear();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Comparison/ArrayComparisonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ArrayComparisonTest extends \PHPUnit\Framework\TestCase
/** @var ArrayComparison **/
protected $comparison;

public function setUp()
public function setUp(): void
{
$this->comparison = new ArrayComparison($this->getComparisonManagerMock());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Comparison/BooleanComparisonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BooleanComparisonTest extends \PHPUnit\Framework\TestCase
/** @var BooleanComparison **/
protected $comparison;

public function setUp()
public function setUp(): void
{
$this->comparison = new BooleanComparison($this->getComparisonManagerMock());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Comparison/DatetimeComparisonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DattimeeComparisonTest extends \PHPUnit\Framework\TestCase
/** @var DateComparison **/
protected $comparison;

public function setUp()
public function setUp(): void
{
$this->comparison = new DatetimeComparison($this->getComparisonManagerMock());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Comparison/NumericComparisonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class NumericComparisonTest extends \PHPUnit\Framework\TestCase
/** @var NumericComparison **/
protected $comparison;

public function setUp()
public function setUp(): void
{
$this->comparison = new NumericComparison($this->getComparisonManagerMock());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Comparison/ObjectComparisonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ObjectComparisonTest extends \PHPUnit\Framework\TestCase
/** @var ArrayComparison **/
protected $comparison;

public function setUp()
public function setUp(): void
{
$this->comparison = new ObjectComparison($this->getComparisonManagerMock());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Comparison/StringComparisonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class StringComparisonTest extends \PHPUnit\Framework\TestCase
/** @var StringComparison **/
protected $comparison;

public function setUp()
public function setUp(): void
{
$this->comparison = new StringComparison($this->getComparisonManagerMock());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Comparison/UserComparisonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class UserComparisonTest extends \PHPUnit\Framework\TestCase
/** @var ArrayComparison **/
protected $comparison;

public function setUp()
public function setUp(): void
{
$this->comparison = new UserComparison($this->getComparisonManagerMock());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Manager/AttributeManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AttributeManagerTest extends \PHPUnit\Framework\TestCase
/** @var AttributeManager **/
private $manager;

public function setUp()
public function setUp(): void
{
$this->manager = new AttributeManager($this->getConfigurationMock());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Manager/CacheManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CacheManagerTest extends \PHPUnit\Framework\TestCase
/** @var CacheManager **/
protected $cacheManager;

public function setUp()
public function setUp(): void
{
$this->cacheManager = new CacheManager();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Manager/ComparisonManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ComparisonManagerTest extends \PHPUnit\Framework\TestCase
/** @var ComparisonManager **/
protected $manager;

public function setUp()
public function setUp(): void
{
$this->manager = new ComparisonManager($this->getAttributeManagerMock());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Manager/PolicyRuleManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PolicyRuleManagerTest extends \PHPUnit\Framework\TestCase
/** @var PolicyRuleManager **/
private $manager;

public function setUp()
public function setUp(): void
{
$this->manager = new PolicyRuleManager(
$this->getConfigurationMock(),
Expand Down