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
Requires
- php: ^7.4
- aesonus/parse-use-statements: ^1.1
Requires (Dev)
- aesonus/test-lib: ^4.01
This package is auto-updated.
Last update: 2024-10-29 05:40:28 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