Skip to content

Commit

Permalink
Merge pull request #47 from visto9259/fix-issue-42
Browse files Browse the repository at this point in the history
Fix issue 42
  • Loading branch information
visto9259 authored May 23, 2024
2 parents cff8aa6 + e2fff77 commit 542e893
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 35 deletions.
43 changes: 22 additions & 21 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,72 +22,69 @@ public function getRules(): array
],
'blank_line_after_opening_tag' => true,
'blank_line_after_namespace' => true,
// 'blank_line_before_return' => true,
'blank_line_before_statement' => ['statements' => ['return']],
'braces' => true,
// 'braces' => true,
'braces_position' => true,
'cast_spaces' => true,
'class_attributes_separation' => ['elements' => ['method' => 'one']],
'class_definition' => true,
'combine_consecutive_unsets' => true,
'concat_space' => false,
'constant_case' => ['case' => 'lower'],
'control_structure_braces' => true,
'control_structure_continuation_position' => true,
'declare_strict_types' => true,
'declare_parentheses' => true,
'echo_tag_syntax' => true,
'elseif' => true,
'encoding' => true,
'full_opening_tag' => true,
'function_declaration' => true,
'function_typehint_space' => true,
// 'hash_to_slash_comment' => true,
'single_line_comment_style' => ['comment_types' => ['hash']],
// 'function_typehint_space' => true,
'header_comment' => false,
'include' => true,
'indentation_type' => true,
'linebreak_after_opening_tag' => true,
'line_ending' => true,
// 'lowercase_constants' => true,
'constant_case' => ['case' => 'lower'],
'lowercase_keywords' => true,
'method_argument_space' => true,
// 'method_separation' => true,
'class_attributes_separation' => ['elements' => ['method' => 'one']],
'modernize_types_casting' => true,
'native_function_casing' => true,
'new_with_braces' => true,
// 'new_with_braces' => true,
'new_with_parentheses' => true,
'no_alias_functions' => true,
'no_blank_lines_after_class_opening' => true,
'no_closing_tag' => true,
'no_empty_statement' => true,
// 'no_extra_consecutive_blank_lines' => true,
'no_extra_blank_lines' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_multiline_whitespace_around_double_arrow' => true,
// 'no_multiline_whitespace_before_semicolons' => true,
'no_multiple_statements_per_line' => true,
'multiline_whitespace_before_semicolons' => true,
'no_short_bool_cast' => true,
// 'no_short_echo_tag' => true,
'echo_tag_syntax' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_around_offset' => true,
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
// 'no_trailing_comma_in_list_call' => true,
// 'no_trailing_comma_in_singleline_array' => true,
'no_trailing_comma_in_singleline' => true,
'no_trailing_whitespace_in_comment' => true,
'no_unneeded_control_parentheses' => true,
'no_unreachable_default_argument_value' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'no_spaces_inside_parenthesis' => true,
'no_trailing_whitespace_in_comment' => true,
// 'no_spaces_inside_parenthesis' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'normalize_index_brace' => true,
'not_operator_with_successor_space' => true,
'object_operator_without_whitespace' => true,
'ordered_imports' => true,
'phpdoc_indent' => true,
// 'phpdoc_inline_tag' => true,
'general_phpdoc_tag_rename' => true,
'phpdoc_inline_tag_normalizer' => true,
'phpdoc_tag_type' => true,
// 'psr4' => true,
'psr_autoloading' => true,
'return_type_declaration' => true,
'semicolon_after_instruction' => true,
Expand All @@ -97,15 +94,19 @@ public function getRules(): array
'single_class_element_per_statement' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_line_comment_style' => ['comment_types' => ['hash']],
'single_quote' => true,
'single_space_around_construct' => true,
'spaces_inside_parentheses' => true,
'standardize_not_equals' => true,
'statement_indentation' => true,
'strict_comparison' => true,
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
'ternary_operator_spaces' => true,
// 'trailing_comma_in_multiline_array' => true,
'trailing_comma_in_multiline' => true,
'trim_array_spaces' => true,
'type_declaration_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => true,
'whitespace_after_comma_in_array' => true,
Expand Down
2 changes: 1 addition & 1 deletion src/Assertion/AssertionContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class AssertionContainer extends AbstractPluginManager implements Assertio
protected $instanceOf = AssertionInterface::class;

/**
* {@inheritdoc}
* @inheritdoc
*/
public function get($name, array $options = null): AssertionInterface
{
Expand Down
4 changes: 2 additions & 2 deletions src/Assertion/AssertionSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ final class AssertionSet implements AssertionInterface
/**
* Condition constants
*/
const CONDITION_OR = 'condition_or';
const CONDITION_AND = 'condition_and';
public const CONDITION_OR = 'condition_or';
public const CONDITION_AND = 'condition_and';

/**
* @var AssertionContainerInterface
Expand Down
1 change: 0 additions & 1 deletion src/Container/RoleServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
use LmcRbac\Options\ModuleOptions;
use LmcRbac\Role\RoleProviderInterface;
use LmcRbac\Service\RoleService;
use Psr\Container\ContainerInterface;

Expand Down
2 changes: 1 addition & 1 deletion src/Role/InMemoryRoleProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct(array $rolesConfig)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getRoles(iterable $roleNames): iterable
{
Expand Down
8 changes: 5 additions & 3 deletions test/Assertion/AssertionSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ public function testWhenNoConditionIsGivenAndIsUsed()
$matcher = $this->exactly(2);
$assertionContainer->expects($matcher)
->method('get')
->willReturnCallback(fn (string $key) => match ($key) {
->willReturnCallback(function (string $key) use ($fooAssertion, $barAssertion) {
return match ($key) {
'fooFactory' => $fooAssertion,
'barFactory' => $barAssertion,
});
};
});

$this->assertFalse($assertionSet->assert('permission'));

Expand Down Expand Up @@ -244,7 +246,7 @@ private function assertionsCalled(array $assertions, array $assertionCalledCount
}
}

static public function dpMatrix(): array
public static function dpMatrix(): array
{
return [
// no assertions will fail
Expand Down
4 changes: 0 additions & 4 deletions test/Container/RoleServiceFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
namespace LmcRbacTest\Container;

use Laminas\ServiceManager\ServiceManager;
use LmcRbac\Container\InMemoryRoleProviderFactory;
use LmcRbac\Container\RoleServiceFactory;
use LmcRbac\Options\ModuleOptions;
use LmcRbac\Role\InMemoryRoleProvider;
use LmcRbac\Role\RoleProviderInterface;
use PHPUnit\Framework\TestCase;

/**
Expand All @@ -45,8 +43,6 @@ public function testCanCreateRoleService(): void
],
]);



$container = new ServiceManager(['services' => [
ModuleOptions::class => $options,
InMemoryRoleProvider::class => new InMemoryRoleProvider([]),
Expand Down
7 changes: 5 additions & 2 deletions test/Service/AuthorizationServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
*/
class AuthorizationServiceTest extends TestCase
{
static function grantedProvider(): array
public static function grantedProvider(): array
{
return [
// Simple is granted
Expand Down Expand Up @@ -302,7 +302,10 @@ public function testUsesAssertionsAsCallable(): void

$called = false;

$authorizationService = new AuthorizationService($rbac, $roleService, $assertionContainer,
$authorizationService = new AuthorizationService(
$rbac,
$roleService,
$assertionContainer,
[
'foo' => function ($permission, IdentityInterface $identity = null, $context = null) use (&$called) {
$called = true;
Expand Down

0 comments on commit 542e893

Please sign in to comment.