-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Initial release #1
Open
bakura10
wants to merge
13
commits into
master
Choose a base branch
from
release
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e81602f
Create branch
bakura10 05beae0
Add basic classes
bakura10 a240cfc
Streamline interfaces
bakura10 9905a2f
Reverse order
bakura10 d508fa0
Factory
bakura10 9d28bf2
Properly inject everything
bakura10 281e250
Refactor global filters/validators
bakura10 e68afab
Reintroduce validation group
bakura10 16877ba
ValidationGroup
bakura10 84d435e
Add tests for input
bakura10 8eb3dd5
Add tests for input result
bakura10 66fec1b
Fix validation group
bakura10 4d4b9df
More unit tests
bakura10 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
vendor/ | ||
composer.lock | ||
composer.phar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
language: php | ||
|
||
php: | ||
- 5.5 | ||
- 5.6 | ||
- hhvm | ||
- hhvm-nightly | ||
|
||
before_script: | ||
- composer self-update | ||
- composer update --prefer-source --dev | ||
|
||
script: | ||
- ./vendor/bin/phpunit --coverage-clover ./build/logs/clover.xml --group=Coverage | ||
- ./vendor/bin/phpcs --standard=PSR2 ./src/ ./tests | ||
|
||
after_script: | ||
- php vendor/bin/coveralls -v | ||
|
||
notifications: | ||
irc: "irc.freenode.org#zftalk.modules" | ||
email: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
input-filter | ||
============ | ||
# Input Filter | ||
|
||
ZF3 prototype for Input filter component | ||
This component is a prototype for ZF3 Input Filter. Its main advantages over original implementation are: | ||
|
||
* Much more efficient (benchmarks showed a x10 performance and a lot less consumed memory). | ||
* Completely stateless | ||
* Uses a concept of "InputFilterResult" | ||
* Renames to make it easier to understand (previous "InputFilter" has been renamed to "InputCollection") | ||
* Behaviour is now much more predictable | ||
* ... and a lot of things! | ||
|
||
## How to use it? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"name": "zfr/input-filter", | ||
"description": "Zend Framework 3 prototype for a better input filter component", | ||
"type": "library", | ||
"license": "MIT", | ||
"keywords": [ | ||
"zf3", | ||
"zend framework", | ||
"input filter" | ||
], | ||
"homepage": "https://github.com/zf-fr/input-filter", | ||
"authors": [ | ||
{ | ||
"name": "Michaël Gallego", | ||
"email": "[email protected]", | ||
"homepage": "http://www.michaelgallego.fr/" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.5", | ||
"zendframework/zend-servicemanager": "~2.2", | ||
"zendframework/zend-validator": "~2.2", | ||
"zendframework/zend-filter": "~2.2", | ||
"zendframework/zend-stdlib": "~2.2" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "~4.1", | ||
"squizlabs/php_codesniffer": "1.4.*", | ||
"satooshi/php-coveralls": "~0.6", | ||
"athletic/athletic": "0.1.7" | ||
}, | ||
"autoload": { | ||
"psr-0": { | ||
"InputFilter\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-0": { | ||
"InputFilterBenchmark\\": "benchmarks/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0"?> | ||
<phpunit | ||
bootstrap="./tests/Bootstrap.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
verbose="true" | ||
stopOnFailure="false" | ||
processIsolation="false" | ||
backupGlobals="false" | ||
syntaxCheck="true" | ||
> | ||
<testsuite name="InputFilter tests"> | ||
<directory>./tests</directory> | ||
</testsuite> | ||
<filter> | ||
<whitelist addUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">./src</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace InputFilter\Exception; | ||
|
||
interface ExceptionInterface | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace InputFilter\Exception; | ||
|
||
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace InputFilter\Exception; | ||
|
||
class RuntimeException extends \RuntimeException implements ExceptionInterface | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
/* | ||
* 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. | ||
*/ | ||
|
||
namespace InputFilter\Factory; | ||
|
||
use InputFilter\InputFactory; | ||
use InputFilter\InputFilterPluginManager; | ||
use Zend\ServiceManager\FactoryInterface; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
|
||
/** | ||
* @author Michaël Gallego <[email protected]> | ||
* @licence MIT | ||
*/ | ||
class InputFactoryFactory implements FactoryInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function createService(ServiceLocatorInterface $serviceLocator) | ||
{ | ||
/** @var InputFilterPluginManager $inputFilterManager */ | ||
$inputFilterManager = $serviceLocator->get(InputFilterPluginManager::class); | ||
|
||
/** @var \Zend\Validator\ValidatorPluginManager $validatorManager */ | ||
$validatorManager = $serviceLocator->get('ValidatorManager'); | ||
|
||
/** @var \Zend\Filter\FilterPluginManager $filterManager */ | ||
$filterManager = $serviceLocator->get('FilterManager'); | ||
|
||
return new InputFactory($inputFilterManager, $validatorManager, $filterManager); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/InputFilter/Factory/InputFilterPluginManagerFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/* | ||
* 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. | ||
*/ | ||
|
||
namespace InputFilter\Factory; | ||
|
||
use InputFilter\InputFilterPluginManager; | ||
use Zend\ServiceManager\Config; | ||
use Zend\ServiceManager\FactoryInterface; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
|
||
/** | ||
* @author Michaël Gallego <[email protected]> | ||
* @licence MIT | ||
* | ||
* @TODO: for ZF3, use "input_filters" instead of "zfr_input_filters" | ||
*/ | ||
class InputFilterPluginManagerFactory implements FactoryInterface | ||
{ | ||
/** | ||
* Create a hydrator plugin manager | ||
* | ||
* @param ServiceLocatorInterface $serviceLocator | ||
* @return InputFilterPluginManager | ||
*/ | ||
public function createService(ServiceLocatorInterface $serviceLocator) | ||
{ | ||
$config = $serviceLocator->get('Config'); | ||
$config = isset($config['zfr_input_filters']) ? $config['zfr_input_filters'] : []; | ||
|
||
$pluginManager = new InputFilterPluginManager(new Config($config)); | ||
$pluginManager->setServiceLocator($serviceLocator); | ||
|
||
return $pluginManager; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unaware of instantiation logic :D