aesonus/paladin

This package is abandoned and no longer maintained. No replacement package was suggested.

Validate method parameters based on their doc blocks

v3.0-beta 2020-09-01 18:43 UTC

README

This package allows for method arguments to be validated according to their docblocks

Installation

Simply install with composer:

composer require aesonus/paladin

Usage

Usage is simple. Just use the trait ValidatesParameters in your classes:

use Aesonus\Paladin\ValidatesParameters;

To validate parameters, just call the protected method validate with the method name and arguments:

/**
 *
 * @param int[] $param
*/
public function myMethod(array $param)
{
    $this->validate(__METHOD__, func_get_args());
}

The previous example will throw an exception if the passed argument is not an array of only int types.

You can use most psalm types as well. Refer to psalm documentation to see what types you can use.

Currently, templates and complex callables cannot be validated