Skip to content
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
wants to merge 13 commits into
base: master
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vendor/
composer.lock
composer.phar
22 changes: 22 additions & 0 deletions .travis.yml
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
14 changes: 11 additions & 3 deletions README.md
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!

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


## How to use it?
42 changes: 42 additions & 0 deletions composer.json
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/"
}
}
}
22 changes: 22 additions & 0 deletions phpunit.xml.dist
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>
14 changes: 14 additions & 0 deletions src/InputFilter/Exception/ExceptionInterface.php
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
{
}
14 changes: 14 additions & 0 deletions src/InputFilter/Exception/InvalidArgumentException.php
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
{
}
14 changes: 14 additions & 0 deletions src/InputFilter/Exception/RuntimeException.php
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
{
}
48 changes: 48 additions & 0 deletions src/InputFilter/Factory/InputFactoryFactory.php
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 src/InputFilter/Factory/InputFilterPluginManagerFactory.php
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;
}
}
Loading