Skip to content
This repository was archived by the owner on Jul 3, 2020. It is now read-only.

Multiple assertions develop #379

Merged
merged 65 commits into from
Feb 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
d1e0751
update dependencies
basz Apr 5, 2017
26d7d46
update test to work with phpunit 6
basz Apr 5, 2017
5ffbad2
patch test case without tests
basz Apr 5, 2017
f432acc
php7 return types
basz Apr 5, 2017
1e8a77f
copy zfr-rbac into repository
basz Apr 5, 2017
f9841b0
adding docheader to pipline
basz Apr 5, 2017
b2dd14f
switch notifications
basz Apr 5, 2017
868083b
adding return type to ZfcRbac/Rbac which results in removal of Except…
basz Apr 5, 2017
8b9d261
fix travis doccheck
basz Apr 5, 2017
40b3082
review feedback
basz Apr 5, 2017
bb74310
PermissionInterface is gone
basz Apr 5, 2017
918b1d6
adds a test
basz Apr 5, 2017
4902b38
remove php56 from travis matrix
basz Apr 5, 2017
ef3bb59
switch cs tooling updated travis conf
basz Apr 5, 2017
a27a554
apply code styling
basz Apr 5, 2017
881f839
ZfcRbac\Rbac\Role to ZfcRbac\Role
basz Apr 5, 2017
b4287d1
support only sm3 plugin managers
basz Apr 5, 2017
dfe3c85
v3 factories
basz Apr 5, 2017
43e1c95
tests for sm3 plugin managers
basz Apr 5, 2017
4f61a49
typo and env addition
basz Apr 5, 2017
5019c5e
remove :void (for now)
basz Apr 5, 2017
f8583c6
Revert "remove :void (for now)"
basz Feb 19, 2018
1b09787
require php71
basz Feb 19, 2018
6061d60
update travis to reflect requirement change
basz Feb 19, 2018
aa27bf2
remove as for v2 service manager
basz Feb 19, 2018
b456f17
not needed
basz Feb 19, 2018
069c058
remove aliases
basz Feb 19, 2018
ac95f43
add consistent final declaration
basz Feb 19, 2018
15b86cb
fix test: final classes can't be mocked
basz Feb 19, 2018
bd0f4c2
avoid confusion
basz Feb 19, 2018
925aa8c
incorrect reference
basz Feb 19, 2018
2c4ee74
aids IDE
basz Feb 19, 2018
36c0407
not needed as argument is type hinted
basz Feb 19, 2018
73c65dd
yield from ...
basz Feb 19, 2018
8aec2f5
phpstan level7
basz Feb 19, 2018
f0e1564
think notation was incorrect, this is more expressive (not sure)
basz Feb 19, 2018
607b1b6
hinting
basz Feb 19, 2018
e83c9ba
fixes tests
basz Feb 19, 2018
00295b7
move declare
basz Feb 19, 2018
544b8da
switch to psr-container
basz Feb 19, 2018
1b97382
whoops
basz Feb 19, 2018
0a67f02
fix minimum dependen
basz Feb 19, 2018
126e9e8
bring back stdlib
basz Feb 20, 2018
fe378ff
remove hhvm
basz Feb 20, 2018
242101d
by popular demand no more spaces
basz Feb 20, 2018
b6f3de5
optimize yielding
basz Feb 20, 2018
f69ed6d
params and doc block not needed
basz Feb 20, 2018
dd0fb93
unused property
basz Feb 20, 2018
f254ad5
more unneeded doc block removed
basz Feb 20, 2018
92d46d6
stdlib ^3.1
basz Feb 20, 2018
875090b
remove allow failure from travis
basz Feb 20, 2018
bf40881
revert unpack, does not work
basz Feb 20, 2018
523fd25
fix, must be of the type array, null given,
basz Feb 20, 2018
b1c1d1e
cs
basz Feb 20, 2018
2d10256
ternary assignment
basz Feb 20, 2018
9a4a615
import class
basz Feb 20, 2018
cc27436
ternary for real
basz Feb 20, 2018
66fedba
not needed as we switched to psr/container
basz Feb 20, 2018
2f89286
void return types on tests methods
basz Feb 20, 2018
869abfb
cache assertions
basz Feb 18, 2018
5c0290b
adds assertion set
basz Feb 18, 2018
10e6bcd
tests
basz Feb 18, 2018
02757b3
apply in AuthorizationService
basz Feb 18, 2018
81178b8
rebase conflict
basz Feb 20, 2018
175b48b
cs
basz Feb 20, 2018
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
16 changes: 16 additions & 0 deletions .docheader
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license.
*/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
vendor
composer.lock
.idea
.php_cs.cache
build
112 changes: 112 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?php

use PhpCsFixer\Config as PhpCsFixerConfig;

class Config extends PhpCsFixerConfig
{
public function __construct()
{
parent::__construct();

$this->setRiskyAllowed(true);
}

public function getRules(): array
{
return [
'@PSR2' => true,
'@PHP71Migration' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'align_double_arrow' => true,
'align_equals' => false,
],
'blank_line_after_opening_tag' => true,
'blank_line_after_namespace' => true,
'blank_line_before_return' => true,
'braces' => true,
'cast_spaces' => true,
'class_definition' => true,
'combine_consecutive_unsets' => true,
'concat_space' => false,
'declare_strict_types' => true,
'elseif' => true,
'encoding' => true,
'full_opening_tag' => true,
'function_declaration' => true,
'function_typehint_space' => true,
'hash_to_slash_comment' => true,
'header_comment' => false,
'include' => true,
'indentation_type' => true,
'linebreak_after_opening_tag' => true,
'line_ending' => true,
'lowercase_constants' => true,
'lowercase_keywords' => true,
'method_argument_space' => true,
'method_separation' => true,
'modernize_types_casting' => true,
'native_function_casing' => true,
'new_with_braces' => 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_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'no_multiline_whitespace_before_semicolons' => true,
'no_short_bool_cast' => true,
'no_short_echo_tag' => 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_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_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,
'psr4' => true,
'return_type_declaration' => true,
'semicolon_after_instruction' => true,
'short_scalar_cast' => true,
'simplified_null_return' => false,
'single_blank_line_at_eof' => true,
'single_class_element_per_statement' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_quote' => true,
'standardize_not_equals' => true,
'strict_comparison' => true,
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline_array' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => true,
'whitespace_after_comma_in_array' => true,
];
}
}

$config = new Config();
$config->getFinder()->in(__DIR__)->exclude(['data', 'docs']);

$cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__;

$config->setCacheFile($cacheDir . '/.php_cs.cache');

return $config;
56 changes: 34 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
sudo: false

language: php

php:
- 5.6
- 7.0
- 7.1
- hhvm
cache:
directories:
- $HOME/.composer/cache
- $HOME/.php-cs-fixer

env:
matrix:
- PREFER_LOWEST="--prefer-lowest"
- PREFER_LOWEST=""
matrix:
include:
- php: 7.1
env:
- DEPENDENCIES=""
- EXECUTE_CS_CHECK=true
- TEST_COVERAGE=true
- php: 7.1
env:
- DEPENDENCIES="--prefer-lowest --prefer-stable"
- php: 7.2
env:
- DEPENDENCIES=""
- php: 7.2
env:
- DEPENDENCIES="--prefer-lowest --prefer-stable"

before_script:
- mkdir -p "$HOME/.php-cs-fixer"
- phpenv config-rm xdebug.ini
- composer self-update
- composer update --prefer-source $PREFER_LOWEST
- composer update $DEPENDENCIES

script:
- ./vendor/bin/phpunit --coverage-clover ./build/logs/clover.xml
- ./vendor/bin/phpcs --standard=PSR2 ./src/
- if [[ $TEST_COVERAGE == 'true' ]]; then php -dzend_extension=xdebug.so ./vendor/bin/phpunit --coverage-text --coverage-clover ./build/logs/clover.xml; else ./vendor/bin/phpunit; fi
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/php-cs-fixer fix -v --diff --dry-run; fi
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/docheader check src/ tests/; fi

after_script:
- php vendor/bin/coveralls -v
after_success:
- if [[ $TEST_COVERAGE == 'true' ]]; then php vendor/bin/coveralls -v; fi

notifications:
irc: "irc.freenode.org#zftalk.modules"
email: true

matrix:
allow_failures:
- php: hhvm
webhooks:
urls:
- https://webhooks.gitter.im/e/90753b5c820315c57410
on_success: change # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always
on_start: never # options: [always|never|change] default: always
25 changes: 18 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
}
],
"require": {
"php": ">=5.5",
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3",
"zendframework/zend-stdlib": "^2.7 || ^3.0",
"zfr/rbac": "~2.0"
"php": "^7.1",
"zendframework/zend-servicemanager": "^3.3",
"zendframework/zend-stdlib": "^3.1"
},
"require-dev": {
"phpunit/phpunit": "~5.0",
"squizlabs/php_codesniffer": "^2.0",
"doctrine/common": "~2.4"
"malukenho/docheader": "^0.1",
"phpunit/phpunit": "^6.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use v7

"friendsofphp/php-cs-fixer": "^2.1",
"doctrine/common": "^2.4"
},
"autoload": {
"psr-4": {
Expand All @@ -52,5 +52,16 @@
"dev-master": "2.4-dev",
"dev-develop": "3.0-dev"
}
},
"scripts": {
"check": [
"@cs",
"@test",
"@header"
],
"cs": "php-cs-fixer fix -v --diff --dry-run",
"cs-fix": "php-cs-fixer fix -v --diff",
"test": "phpunit",
"header": "docheader check src test"
}
}
4 changes: 3 additions & 1 deletion config/config.global.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Expand Down Expand Up @@ -67,5 +69,5 @@
*/
'assertion_map' => [
],
]
],
];
8 changes: 5 additions & 3 deletions config/dependencies.global.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Expand Down Expand Up @@ -32,6 +34,6 @@
'role_provider_manager' => [],

// Assertion plugin manager
'assertion_manager' => []
]
];
'assertion_manager' => [],
],
];
15 changes: 5 additions & 10 deletions src/Assertion/AssertionInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Expand All @@ -16,6 +17,8 @@
* and is licensed under the MIT license.
*/

declare(strict_types=1);

namespace ZfcRbac\Assertion;

use ZfcRbac\Identity\IdentityInterface;
Expand All @@ -30,17 +33,9 @@
*/
interface AssertionInterface
{
/**
* Check if this assertion is true
*
* @param string $permission
* @param IdentityInterface $identity
* @param mixed $context
* @return bool
*/
public function assert(
$permission,
string $permission,
IdentityInterface $identity = null,
$context = null
);
): bool;
}
36 changes: 4 additions & 32 deletions src/Assertion/AssertionPluginManager.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Expand All @@ -16,10 +17,11 @@
* and is licensed under the MIT license.
*/

declare(strict_types=1);

namespace ZfcRbac\Assertion;

use Zend\ServiceManager\AbstractPluginManager;
use Zend\ServiceManager\Exception\InvalidServiceException;

/**
* Plugin manager to create assertions
Expand All @@ -31,35 +33,5 @@
*/
class AssertionPluginManager extends AbstractPluginManager
{
/**
* {@inheritDoc}
*/
public function validate($instance)
{
if ($instance instanceof AssertionInterface) {
return; // we're okay
}

throw new InvalidServiceException(sprintf(
'Assertion must implement "%s", but "%s" was given',
AssertionInterface::class,
is_object($instance) ? get_class($instance) : gettype($instance)
));
}

/**
* {@inheritDoc}
*/
public function validatePlugin($plugin)
{
$this->validate($plugin);
}

/**
* {@inheritDoc}
*/
protected function canonicalizeName($name)
{
return $name;
}
protected $instanceOf = AssertionInterface::class;
}
Loading