Abstracts HTTP request input handling, providing an easy interface for data hydration and validation

Overview

Linio Input

Latest Stable Version License Build Status Scrutinizer Code Quality

Linio Input is yet another component of the Linio Framework. It aims to abstract HTTP request input handling, allowing a seamless integration with your domain model. The component is responsible for:

  • Parsing request body contents
  • Validating input data
  • Hydrating input data into objects

Install

The recommended way to install Linio Input is through composer.

{
    "require": {
        "linio/input": "dev-master"
    }
}

Tests

To run the test suite, you need install the dependencies via composer, then run PHPUnit.

$ composer install
$ phpunit

Usage

The library is very easy to use: first, you have to create your input handler class. The input handlers are responsible for specifying which data you're expecting to receive from requests. Let's create one:

<?php

namespace Linio\Api\Handler;

use Linio\Component\Input\InputHandler;

class RegistrationHandler extends InputHandler
{
    public function define()
    {
        $this->add('referrer', 'string');
        $this->add('registration_date', 'datetime');

        $user = $this->add('user', 'Linio\Model\User');
        $user->add('name', 'string');
        $user->add('email', 'string');
        $user->add('age', 'integer');
    }
}

Now, in your controller, you just need to bind data to the handler:

<?php

namespace Linio\Api\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class RegistrationController
{
    public function registerAction(Request $request): Response
    {
        $input = new RegistrationHandler();
        $input->bind($request->request->all());

        if (!$input->isValid()) {
            return new Response($input->getErrorsAsString());
        }

        $data = $input->getData();
        $data['referrer']; // string
        $data['registration_date']; // \DateTime
        $data['user']; // Linio\Model\User

        return new Response(['message' => 'Valid!']);
    }
}

Type Handler

When you are defining the fields for your input handler, there are a few types available: string, int, bool, datetime, etc. Those are predefined types provided by the library, but you can also create your own. This magic is handled by Linio\Component\Input\TypeHandler. The TypeHandler allows you to add new types, which are extensions of the BaseNode class.

<?php

class GuidNode extends BaseNode
{
    public function __construct()
    {
        $this->addConstraint(new Linio\Component\Input\Constraint\GuidValue());
    }
}

$typeHandler = new Linio\Component\Input\TypeHandler();
$typeHandler->addType('guid', GuidNode::class);

$input = new RegistrationHandler();
$input->setTypeHandler($typeHandler);

In this example, we have created a new guid type, which has a built-in constraint to validate contents. You can use custom types to do all sorts of things: add predefined constraint chains, transformers, instantiators and also customize how values are generated.

Constraints

Linio Input allows you to apply constraints to your fields. This can be done by providing a third argument for the add() method in your input handlers:

<?php

use Linio\Component\Input\Constraint\Pattern;

class RegistrationHandler extends InputHandler
{
    public function define()
    {
        $this->add('referrer', 'string', ['required' => true]);
        $this->add('registration_date', 'datetime');

        $user = $this->add('user', 'Linio\Model\User');
        $user->add('name', 'string');
        $user->add('email', 'string', ['constraints' => [new Pattern('/^\S+@\S+\.\S+$/')]]);
        $user->add('age', 'integer');
    }
}

The library includes several constraints by default:

  • Enum
  • GuidValue
  • NotNull
  • Pattern
  • StringSize

Transformers

Linio Input allows you to create data transformers, responsible for converting simple input data, like timestamps and unique IDs, into something meaningful, like a datetime object or the full entity (by performing a query).

<?php

namespace Linio\Api\Handler\Transformer;

use Doctrine\Common\Persistence\ObjectRepository;
use Linio\Component\Input\Transformer\TransformerInterface;

class IdTransformer implements TransformerInterface
{
    /**
     * @var ObjectRepository
     */
    protected $repository;

    public function transform($value)
    {
        try {
            $entity = $this->repository->find($value);
        } catch (\Exception $e) {
            return null;
        }

        return $entity;
    }

    public function setRepository(ObjectRepository $repository)
    {
        $this->repository = $repository;
    }
}

Data transformers can be added on a per-field basis during the definition of your input handler:

<?php

use Linio\Api\Handler\Transformer\IdTransformer;

class RegistrationHandler extends InputHandler
{
    /**
     * @var IdTransformer
     */
    protected $idTransformer;

    public function define()
    {
        $this->add('store_id', 'string', ['transformer' => $this->idTransformer]);
    }

    public function setIdTransformer(IdTransformer $idTransformer)
    {
        $this->idTransformer = $idTransformer;
    }
}

Instantiators

Linio Input allows you to use different object instantiators on a per-field basis. This can be done by providing a third argument for the add() method in your input handlers:

<?php

use Linio\Component\Input\Instantiator\ConstructInstantiator;
use Linio\Component\Input\Instantiator\ReflectionInstantiator;

class RegistrationHandler extends InputHandler
{
    public function define()
    {
        $this->add('foobar', 'My\Foo\Class', ['instantiator' => new ConstructInstantiator()]);
        $this->add('barfoo', 'My\Bar\Class', ['instantiator' => new ReflectionInstantiator()]);
    }
}

The library includes several instantiators by default:

  • ConstructInstantiator
  • PropertyInstantiator
  • SetInstantiator
  • ReflectionInstantiator

By default, the SetInstantiator is used by Object and Collection nodes.

InputHandlers

Linio Input supports portable, reusable InputHandlers via nesting. This is accomplished by including the handler to the options parameter when adding fields.

Suppose your application deals with mailing addresses:

<?php

class OrderHandler extends InputHandler
{
    public function define()
    {
        $address = $this->add('shipping_address', Address::class);
        $address->add('street', 'string');
        $address->add('city', 'string');
        $address->add('state', 'string');
        $address->add('zip_code', 'integer');
    }
}

Rather than duplicating this everywhere you need to handle an address, you can extract the address into its own InputHandler and re-use it throughout your application.

<?php

class AddressHandler extends InputHandler
{
    public function define()
    {
        $address->add('street', 'string');
        $address->add('city', 'string');
        $address->add('state', 'string');
        $address->add('zip_code', 'integer');
    }
}

class OrderHandler extends InputHander
{
    public function define()
    {
        $this->add('shipping_address', Address::Class, ['handler' => new AddressHandler()]);
    }
}

class RegistrationHandler extends InputHander
{
    public function define()
    {
        $this->add('home_address', Address::Class, ['handler' => new AddressHandler()]);
    }
}
Comments
  • Way to work with an object that already exists

    Way to work with an object that already exists

    Is there a way to way to work with an object that already exists?

    or to do something like:

    $user = $repository->findOneById($id);
    
    $input = new UpdateUserHandler(); // link the $user here
    $input->bind($request->request->all());
    
    if (!$input->isValid()) {
        // error
    }
    
    // instead of do this:
    // $data = $input->getData('user');
    // do this:
    $service->update($user);
    
    opened by reisraff 5
  • Ability of default objects

    Ability of default objects

    This pull request covers a new feature that allows you have a default object reference.

    I will give the example that I added on tests:

    class DummyUser
    {
        protected $id;
        protected $name;
    
        /**
         * Getters and Setters
         */
    }
    
    class TestDefaultsInputHandler extends InputHandler
    {
        public function define()
        {
            $user = $this->add('user', DummyUser::class);
            $user->add('name', 'string');
        }
    }
    
    $input = [
        'user' => [
            'name' => 'Foo'
        ]
    ];
    
    $user = new DummyUser();
    $user->setId(1);
    $user->setName('Bar');
    
    $inputHandler = new TestDefaultsInputHandler();
    $inputHandler->bind($input, ['user' => $user]); // Here you pass your reference object
    
    $user->getId(); // outputs "1"
    $user->getName(); // outputs "Foo"
    
    stale 
    opened by reisraff 4
  • Constraints are overriding type in validation

    Constraints are overriding type in validation

    Creating an input with type and contraints defined It fails to assert that the type is correct.

    public function testOverride()
    {
        $input = [
            'price' => 'igor'
        ];
    
        $inputHandler = new TestConstraintOverrideType();
        $inputHandler->bind($input);
        $this->assertFalse($inputHandler->isValid());
    }
     
     class TestConstraintOverrideType extends InputHandler
     {
         public function define()
         {
             $this->add('price', 'int', [
                 'required' => true,
                 'constraints' => [new Range(0)]
             ]);
         }
     }
    
    opened by igordrnobrega 3
  • Update phpunit/phpunit requirement from ^6.0 || ^7.0 to ^6.0 || ^7.0 || ^8.0

    Update phpunit/phpunit requirement from ^6.0 || ^7.0 to ^6.0 || ^7.0 || ^8.0

    Updates the requirements on phpunit/phpunit to permit the latest version.

    Changelog

    Sourced from phpunit/phpunit's changelog.

    [8.0.1] - 2019-02-03

    Fixed

    • Fixed #3509: Process Isolation does not work with phpunit.phar

    [8.0.0] - 2019-02-01

    Changed

    • Implemented #3060: Cleanup PHPUnit\Framework\Constraint\Constraint
    • Implemented #3133: Enable dependency resolution by default
    • Implemented #3236: Define which parts of PHPUnit are covered by the backward compatibility promise
    • Implemented #3244: Enable result cache by default
    • Implemented #3288: The void_return fixer of php-cs-fixer is now in effect
    • Implemented #3439: Improve colorization of TestDox output
    • Implemented #3444: Consider data provider that provides data with duplicate keys to be invalid
    • Implemented #3467: Code location hints for [**requires**](https://github.com/requires) annotations as well as --SKIPIF--, --EXPECT--, --EXPECTF--, --EXPECTREGEX--, and --{SECTION}_EXTERNAL-- sections of PHPT tests
    • Implemented #3481: Improved --help output

    Deprecated

    • Implemented #3332: Deprecate annotation(s) for expecting exceptions
    • Implemented #3338: Deprecate assertions (and helper methods) that operate on (non-public) attributes
    • Implemented #3341: Deprecate optional parameters of assertEquals() and assertNotEquals()
    • Implemented #3369: Deprecate assertInternalType() and assertNotInternalType()
    • Implemented #3388: Deprecate the TestListener interface
    • Implemented #3425: Deprecate optional parameters of assertContains() and assertNotContains() as well as using these methods with string haystacks
    • Implemented #3494: Deprecate assertArraySubset()

    Removed

    • Implemented #2762: Drop support for PHP 7.1
    • Implemented #3123: Remove PHPUnit_Framework_MockObject_MockObject

    [8.0.1]: https://github.com/sebastianbergmann/phpunit/compare/8.0.0...8.0.1 [8.0.0]: https://github.com/sebastianbergmann/phpunit/compare/7.5...8.0.0

    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot ignore this [patch|minor|major] version will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language
    • @dependabot badge me will comment on this PR with code to add a "Dependabot enabled" badge to your readme

    Additionally, you can set the following in your Dependabot dashboard:

    • Update frequency (including time of day and day of week)
    • Automerge options (never/patch/minor, and dev/runtime dependencies)
    • Pull request limits (per update run and/or open at any time)
    • Out-of-range updates (receive only lockfile updates, if desired)
    • Security updates (receive only security updates, if desired)

    Finally, you can contact us by mentioning @dependabot.

    dependencies stale PR: unreviewed 
    opened by dependabot-preview[bot] 2
  • Update phpunit/phpunit requirement from ^6.0 to ^6.0 || ^7.0

    Update phpunit/phpunit requirement from ^6.0 to ^6.0 || ^7.0

    Updates the requirements on phpunit/phpunit to permit the latest version.

    Changelog

    Sourced from phpunit/phpunit's changelog.

    [7.4.4] - 2018-11-14

    Fixed

    • Fixed #3379: Dependent test of skipped test has status -1
    • Fixed #3394: Process Isolation does not work when PHPUnit is used as PHAR
    • Fixed #3398: Bug when replacing placeholders in [**testdox**](https://github.com/testdox) annotation using an associative array
    • Fixed #3401: Test re-ordering edge cases
    • Fixed #3402: Listening to the tests in reverse revealed evil hidden messages

    [7.4.3] - 2018-10-23

    Changed

    • Use ^3.1 of sebastian/environment again due to regression

    [7.4.2] - 2018-10-23

    Fixed

    • Fixed #3354: Regression when columns="max" is used

    [7.4.1] - 2018-10-18

    Fixed

    • Fixed #3321: Incorrect TestDox output for data provider with indexed array
    • Fixed #3353: Requesting less than 16 columns of output results in an error

    [7.4.0] - 2018-10-05

    Added

    • Implemented #3127: Emit error when mocked method is not really mocked
    • Implemented #3224: Ability to enforce a time limit for tests not annotated with [**small**](https://github.com/small), [**medium**](https://github.com/medium), or [**large**](https://github.com/large)
    • Implemented #3272: Ability to generate code coverage whitelist filter script for Xdebug
    • Implemented #3284: Ability to reorder tests based on execution time
    • Implemented #3290: Ability to load a PHP script before any code of PHPUnit itself is loaded

    [7.4.4]: https://github.com/sebastianbergmann/phpunit/compare/7.4.3...7.4.4 [7.4.3]: https://github.com/sebastianbergmann/phpunit/compare/7.4.2...7.4.3 [7.4.2]: https://github.com/sebastianbergmann/phpunit/compare/7.4.1...7.4.2 [7.4.1]: https://github.com/sebastianbergmann/phpunit/compare/7.4.0...7.4.1 [7.4.0]: https://github.com/sebastianbergmann/phpunit/compare/7.3...7.4.0

    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot ignore this [patch|minor|major] version will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language
    • @dependabot badge me will comment on this PR with code to add a "Dependabot enabled" badge to your readme

    Additionally, you can set the following in your Dependabot dashboard:

    • Update frequency (including time of day and day of week)
    • Automerge options (never/patch/minor, and dev/runtime dependencies)
    • Pull request limits (per update run and/or open at any time)
    • Out-of-range updates (receive only lockfile updates, if desired)
    • Security updates (receive only security updates, if desired)

    Finally, you can contact us by mentioning @dependabot.

    dependencies stale PR: unreviewed 
    opened by dependabot-preview[bot] 2
  • Update phpunit/phpunit requirement from ^6.0 to ^6.0 || ^7.0

    Update phpunit/phpunit requirement from ^6.0 to ^6.0 || ^7.0

    Updates the requirements on phpunit/phpunit to permit the latest version.

    Changelog

    Sourced from phpunit/phpunit's changelog.

    Changes in PHPUnit 6.5

    All notable changes of the PHPUnit 6.5 release series are documented in this file using the Keep a CHANGELOG principles.

    [6.5.13] - 2018-09-08

    • Fixed #3181: --filter should be case-insensitive
    • Fixed #3234: assertArraySubset() with $strict=true does not display differences properly
    • Fixed #3254: TextUI test runner cannot run a Test instance that is not a TestSuite

    [6.5.12] - 2018-08-22

    • Fixed #3248 and #3233: phpunit.xsd dictates element order where it should not
    • Fixed #3251: TeamCity result logger is missing test duration information

    [6.5.11] - 2018-08-07

    • Fixed #3219: getMockFromWsdl() generates invalid PHP code when WSDL filename contains special characters

    [6.5.10] - 2018-08-03

    Fixed

    • Fixed #3209: Test::run() and TestCase::run() interface contradiction
    • Fixed #3218: prefix attribute for directory node missing from phpunit.xml XSD
    • Fixed #3225: coverage-php missing from phpunit.xsd

    [6.5.9] - 2018-07-03

    Fixed

    • Fixed #3142: Method-level annotations ([**backupGlobals**](https://github.com/backupGlobals), [**backupStaticAttributes**](https://github.com/backupStaticAttributes), [**errorHandler**](https://github.com/errorHandler), [**preserveGlobalState**](https://github.com/preserveGlobalState)) do not override class-level annotations

    [6.5.8] - 2018-04-10

    Fixed

    • Fixed #2830: [**runClassInSeparateProcess**](https://github.com/runClassInSeparateProcess) does not work for tests that use [**dataProvider**](https://github.com/dataProvider)

    [6.5.7] - 2018-02-26

    Fixed

    • Fixed #2974: JUnit XML logfile contains invalid characters when test output contains binary data

    [6.5.6] - 2018-02-01

    Fixed

    • Fixed #2236: Exceptions in tearDown() do not affect getStatus()
    ... (truncated)
    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot ignore this [patch|minor|major] version will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language
    • @dependabot badge me will comment on this PR with code to add a "Dependabot enabled" badge to your readme

    Additionally, you can set the following in your Dependabot dashboard:

    • Update frequency (including time of day and day of week)
    • Automerge options (never/patch/minor, and dev/runtime dependencies)
    • Pull request limits (per update run and/or open at any time)
    • Out-of-range updates (receive only lockfile updates, if desired)
    • Security updates (receive only security updates, if desired)

    Finally, you can contact us by mentioning @dependabot.

    dependencies stale PR: unreviewed 
    opened by dependabot-preview[bot] 2
  • Update phpunit/phpunit requirement from ^6.0 to ^6.0|^7.0

    Update phpunit/phpunit requirement from ^6.0 to ^6.0|^7.0

    Updates the requirements on phpunit/phpunit to permit the latest version.

    Changelog

    Sourced from phpunit/phpunit's changelog.

    Changes in PHPUnit 6.5

    All notable changes of the PHPUnit 6.5 release series are documented in this file using the Keep a CHANGELOG principles.

    [6.5.12] - 2018-08-22

    • Fixed #3248 and #3233: phpunit.xsd dictates element order where it should not
    • Fixed #3251: TeamCity result logger is missing test duration information

    [6.5.11] - 2018-08-07

    • Fixed #3219: getMockFromWsdl() generates invalid PHP code when WSDL filename contains special characters

    [6.5.10] - 2018-08-03

    Fixed

    • Fixed #3209: Test::run() and TestCase::run() interface contradiction
    • Fixed #3218: prefix attribute for directory node missing from phpunit.xml XSD
    • Fixed #3225: coverage-php missing from phpunit.xsd

    [6.5.9] - 2018-07-03

    Fixed

    • Fixed #3142: Method-level annotations ([**backupGlobals**](https://github.com/backupGlobals), [**backupStaticAttributes**](https://github.com/backupStaticAttributes), [**errorHandler**](https://github.com/errorHandler), [**preserveGlobalState**](https://github.com/preserveGlobalState)) do not override class-level annotations

    [6.5.8] - 2018-04-10

    Fixed

    • Fixed #2830: [**runClassInSeparateProcess**](https://github.com/runClassInSeparateProcess) does not work for tests that use [**dataProvider**](https://github.com/dataProvider)

    [6.5.7] - 2018-02-26

    Fixed

    • Fixed #2974: JUnit XML logfile contains invalid characters when test output contains binary data

    [6.5.6] - 2018-02-01

    Fixed

    • Fixed #2236: Exceptions in tearDown() do not affect getStatus()
    • Fixed #2950: Class extending PHPUnit\Framework\TestSuite does not extend PHPUnit\FrameworkTestCase
    • Fixed #2972: PHPUnit crashes when test suite contains both .phpt files and unconventionally named tests

    [6.5.5] - 2017-12-17

    Fixed

    ... (truncated)
    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot ignore this [patch|minor|major] version will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language
    • @dependabot badge me will comment on this PR with code to add a "Dependabot enabled" badge to your readme

    Additionally, you can set the following in your Dependabot dashboard:

    • Update frequency (including time of day and day of week)
    • Automerge options (never/patch/minor, and dev/runtime dependencies)
    • Pull request limits (per update run and/or open at any time)
    • Out-of-range updates (receive only lockfile updates, if desired)
    • Security updates (receive only security updates, if desired)

    Finally, you can contact us by mentioning @dependabot.

    dependencies stale PR: unreviewed 
    opened by dependabot-preview[bot] 2
  • Update phpunit/phpunit requirement to ^6.0|^7.0

    Update phpunit/phpunit requirement to ^6.0|^7.0

    Updates the requirements on phpunit/phpunit to permit the latest version.

    Changelog

    Sourced from phpunit/phpunit's changelog.

    Changes in PHPUnit 6.5

    All notable changes of the PHPUnit 6.5 release series are documented in this file using the Keep a CHANGELOG principles.

    [6.5.9] - 2018-MM-DD

    Fixed

    • Fixed #3142: Method-level annotations ([**backupGlobals**](https://github.com/backupGlobals), [**backupStaticAttributes**](https://github.com/backupStaticAttributes), [**errorHandler**](https://github.com/errorHandler), [**preserveGlobalState**](https://github.com/preserveGlobalState)) do not override class-level annotations

    [6.5.8] - 2018-04-10

    Fixed

    • Fixed #2830: [**runClassInSeparateProcess**](https://github.com/runClassInSeparateProcess) does not work for tests that use [**dataProvider**](https://github.com/dataProvider)

    [6.5.7] - 2018-02-26

    Fixed

    • Fixed #2974: JUnit XML logfile contains invalid characters when test output contains binary data

    [6.5.6] - 2018-02-01

    Fixed

    • Fixed #2236: Exceptions in tearDown() do not affect getStatus()
    • Fixed #2950: Class extending PHPUnit\Framework\TestSuite does not extend PHPUnit\FrameworkTestCase
    • Fixed #2972: PHPUnit crashes when test suite contains both .phpt files and unconventionally named tests

    [6.5.5] - 2017-12-17

    Fixed

    • Fixed #2922: Test class is not discovered when there is a test class with [**group**](https://github.com/group) and provider throwing exception in it, tests are run with --exclude-group for that group, there is another class called later (after the class from above), and the name of that another class does not match its filename

    [6.5.4] - 2017-12-10

    Changed

    [6.5.3] - 2017-12-06

    Fixed

    • Fixed an issue with PHPT tests when forceCoversAnnotation="true" is configured

    [6.5.2] - 2017-12-02

    ... (truncated)
    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Note: This repo was added to Dependabot recently, so you'll receive a maximum of 5 PRs for your first few update runs. Once an update run creates fewer than 5 PRs we'll remove that limit.

    You can always request more updates by clicking Bump now in your Dependabot dashboard.

    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot ignore this [patch|minor|major] version will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language

    Additionally, you can set the following in your Dependabot dashboard:

    • Update frequency (including time of day and day of week)
    • Automerge options (never/patch/minor, and dev/runtime dependencies)
    • Pull request limits (per update run and/or open at any time)
    • Out-of-range updates (receive only lockfile updates, if desired)
    • Security updates (receive only security updates, if desired)

    Finally, you can contact us by mentioning @dependabot.

    dependencies 
    opened by dependabot-preview[bot] 2
  • Allow to set null as default value

    Allow to set null as default value

    When using ConstructInstantiator with nullable arguments for an optional input the only way to have the value injected is setting the handler with this definition:

    class SomeClassHandler extends InputHandler
    {
        public function define()
            $this->add('someField', 'int', [
                'allow_null' => true,
                'required' => false,
                'default' => null,
            ]);
        }
    }
    

    But the null default value is not set on the constructor data because hasDefault method on BaseNode tries to check for default values using (bool) $this->default. This, of course, is a problem even for empty strings or integers with value 0 set as default.

    stale 
    opened by onlab 2
  • chore: Update PHP to 8.1 and dependencies

    chore: Update PHP to 8.1 and dependencies

    Changes

    1. Upgrade PHP to version 8.1.
    2. Update dependencies to version with PHP 8.1 support.
    3. Minor changes made by php-cs-fixer.
    4. Add custom TestCase class for future customizations.
    opened by Felynx3 1
  • Error when walking null values

    Error when walking null values

    Hello, we're having a very specific issue using this library for validation of input inside LinioPay services.

    {
    		"headers": {
    			"Content-type": ["application/json; charset=UTF-8"]
    		},
    		"body": "{\"type\":\"server_error\",\"message\":\"Internal Server Error\",\"errors\":[],\"reference_id\":\"aoiscjizxcn19nczocnq\"}",
    		"parsed_body": {
    			"type": "server_error",
    			"message": "Internal Server Error",
    			"errors": [],
    			"reference_id": "aoiscjizxcn19nczocnq"
    		},
    		"exception_class": "TypeError",
    		"exception_message": "array_key_exists() expects parameter 2 to be array, null given",
    		"exception_code": 0,
    		"exception_file": "/path/to/project/vendor/linio/input/src/Node/BaseNode.php",
    		"exception_line": 235,
    		"tags": []
    	}
    

    So, to tackle this issue I added a validation to check whether the input is an array or not. If it is not an array, I just return the input itself.

    Let me know what you think. It's a minor issue for us, but we need to get the fix released as soon as possible.

    Thanks!

    PR: merged 
    opened by gabfr 1
  • Upgrade to GitHub-native Dependabot

    Upgrade to GitHub-native Dependabot

    Dependabot Preview will be shut down on August 3rd, 2021. In order to keep getting Dependabot updates, please merge this PR and migrate to GitHub-native Dependabot before then.

    Dependabot has been fully integrated into GitHub, so you no longer have to install and manage a separate app. This pull request migrates your configuration from Dependabot.com to a config file, using the new syntax. When merged, we'll swap out dependabot-preview (me) for a new dependabot app, and you'll be all set!

    With this change, you'll now use the Dependabot page in GitHub, rather than the Dependabot dashboard, to monitor your version updates, and you'll configure Dependabot through the new config file rather than a UI.

    Your account was configured to allow an unlimited number of open pull requests. This option is no longer supported in the new config file so it has been changed to 99.

    Your account is using config variables to access private registries. Relevant registries have been included in the new config file but additional steps may be necessary to complete the setup. Ensure that each secret below has been configured in the organization Dependabot secrets or the repository Dependabot secrets by an admin.

    • [ ] GIT_GITLAB_COM_PASSWORD

    If an included registry is not required by this repository you can remove it from the config file.

    If you've got any questions or feedback for us, please let us know by creating an issue in the dependabot/dependabot-core repository.

    Learn more about migrating to GitHub-native Dependabot

    Please note that regular @dependabot commands do not work on this pull request.

    dependencies 
    opened by dependabot-preview[bot] 1
  • The BaseNode::walk() method raises a type error if the input is supposed to have children, but a scalar is received.

    The BaseNode::walk() method raises a type error if the input is supposed to have children, but a scalar is received.

    For properties that are supposed to be objects, if the user passes a scalar, the array_key_exists method in BaseNode::walk() raises a type error instead of an invalid input exception.

    Sample code:

    class Handler extends InputHandler
    {
      public function define()
      {
        $this->add('endpoint', Endpoint::class, [
                'required' => true,
                'handler' => new EndPointHandler(),
                'instantiator' => new EndPointInstantiator(),
            ]);
      }
    }
    

    Sample input:

    {
      "endpoint": "https://local.liniopay.com",
    }
    

    Actual error raised:

    {
      "exception_class":"TypeError",
      "exception_message":"array_key_exists() expects parameter 2 to be array, string given",
      "exception_code":0,"exception_file":"/vagrant/vendor/linio/input/src/Node/BaseNode.php",
      "exception_line":214
    }
    
    stale 
    opened by aramonc 2
Releases(2.7.2)
Owner
Linio
Leading online store in Latin America
Linio
laminas-password-validator provides a validator for character-set based input validation.

laminas-password-validator laminas-password-validator provides a validator for character-set based input validation. Installation composer require pra

null 1 Mar 8, 2022
🔒 Laravel validation rule that checks if a password has been exposed in a data breach.

?? Laravel Password Exposed Validation Rule This package provides a Laravel validation rule that checks if a password has been exposed in a data breac

Jordan Hall 85 Apr 26, 2022
An extensible validation library for your data with sane defaults.

Hird Hirds, also known as housecarls, was a gathering of hirdmen, who functioned as the king's personal guards during the viking age and the early mid

Asko Nõmm 13 Apr 23, 2022
🔒 Laravel validation rule that checks if a password has been exposed in a data breach.

?? Laravel Password Exposed Validation Rule This package provides a Laravel validation rule that checks if a password has been exposed in a data breac

Jordan Hall 85 Apr 26, 2022
Library that offers Input Filtering based on Annotations for use with Objects. Check out 2.dev for 2.0 pre-release.

DMS Filter Component This library provides a service that can be used to filter object values based on annotations Install Use composer to add DMS\Fil

Rafael Dohms 89 Nov 28, 2022
Lightweight and feature-rich PHP validation and filtering library. Support scene grouping, pre-filtering, array checking, custom validators, custom messages. 轻量且功能丰富的PHP验证、过滤库。支持场景分组,前置过滤,数组检查,自定义验证器,自定义消息。

PHP Validate 一个简洁小巧且功能完善的php验证、过滤库。 简单方便,支持添加自定义验证器 支持前置验证检查, 自定义如何判断非空 支持将规则按场景进行分组设置。或者部分验证 支持在进行验证前对值使用过滤器进行净化过滤内置过滤器 支持在进行验证前置处理和后置处理独立验证处理 支持自定义每

Inhere 246 Jan 5, 2023
File uploads with validation and storage strategies

Upload This component simplifies file validation and uploading. Usage Assume a file is uploaded with this HTML form: <form method="POST" enctype="mult

Brandon Savage 1.7k Dec 27, 2022
Light and extendable schema validation library

Light PHP validation library For everyone who uses MongoDB or other NoSQL solution and cares about what client sends to his/her database and looking f

Alexander Serkin 43 Sep 28, 2022
Validation rules for Money and Currency

money-validation-laravel Validation rules for Money and Currency Installation composer require brokeyourbike/money-validation-laravel Usage Package us

Ivan Stasiuk 1 Oct 25, 2021
Valitron is a simple, elegant, stand-alone validation library with NO dependencies

Valitron: Easy Validation That Doesn't Suck Valitron is a simple, minimal and elegant stand-alone validation library with NO dependencies. Valitron us

Vance Lucas 1.5k Dec 30, 2022
[READ-ONLY] Validation library from CakePHP. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP Validation Library The validation library in CakePHP provides features to build validators that can validate arbitrary arrays of data with eas

CakePHP 39 Oct 11, 2022
One Line Validation, For CodeIgniter 4

One Line Validation (OLV) is a package made for CodeIgniter 4 to provide a fast and single line validation experience ideal for CDN and/or API services consuming the Validation System from CodeIgniter 4.

AJ Meireles 2 Sep 21, 2021
高性能的验证器组件(Validation),适用于 Hyperf 或 Laravel 框架,可获得数百倍的性能提升

验证器 简介 兼容 Hyperf/Laravel Validation 规则 部分场景可获得约 500 倍性能提升 验证器可多次复用不同数据,无状态设计 规则可全局复用 智能合并验证规则 安装 环境要求 PHP >= 8.0 mbstring 扩展 ctype 扩展 安装命令 composer re

KK集团 80 Dec 9, 2022
Extension for the Laravel validation class

Intervention Validation Intervention Validation is an extension library for Laravel's own validation system. The package adds rules to validate data l

null 370 Dec 30, 2022
Extra validation rules for dealing with images in Laravel 5.

Image-Validator Extra validation rules for dealing with images in Laravel 5. NOTE: As of Laravel version 5.2, there are now built-in validation rules

Colin Viebrock 223 Jun 16, 2022
Laravel Validation Service

Laravel Validation Service Installation Add "prettus/laravel-repository": "1.1.*" to composer.json "prettus/laravel-validation": "1.1.*" Create a vali

Anderson Andrade 398 Nov 25, 2022
FyreValidation is a free, open-source validation library for PHP.

FyreValidation FyreValidation is a free, validation library for PHP. Table Of Contents Installation Validators Rules Error Messages Installation Using

Elusive 0 Jan 15, 2022
This package contains validatiors of data used in Poland (PESEL, NIP, REGON etc.)

This package contains validatiors of data used in Poland (PESEL, NIP, REGON etc.)

Pawel Lukas 2 Mar 18, 2022
Validate and sanitize arrays and objects.

Aura.Filter This package provides tools to validate and sanitize objects and arrays. Foreword Installation This library requires PHP 5.4 or later; we

Aura for PHP 153 Jan 2, 2023