A simple validator to check closure signatures.
PHP ~7.0
Through Composer as jobcloud/jobcloud-closure-validator.
use Jobcloud\ClosureValidator\Parameter;
use Jobcloud\ClosureValidator\Signature;
use Jobcloud\ClosureValidator\Validator;
$closure = function($param1, $param2) {};
$validator = new Validator;
$givenSignature = $validator->getSignatureFromClosure($closure);
$wishedSignature = new Signature(
[
new Parameter('param1'),
new Parameter('param2')
]
);
$diff = $validator->compare($givenSignature, $wishedSignature);
if (!$diff->isIdentical()) {
throw new \Exception('Invalid closure signature');
}
$validator->validOrException($givenSignature, $wishedSignature);