Skip to content

Define a specification of PHP entity and check whether the particular item matches it.

License

Notifications You must be signed in to change notification settings

BR0kEN-/reflection-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reflection Validator

Build Status Code coverage Quality Score Total Downloads Latest Stable Version License

When might it be useful?

Sometimes you may want to have an unlimited sequence of methods, which cannot be restricted/controlled by the interface. In this case on a "compilation" stage, you can restrict those methods to follow the standards you expect.

A real example from Drupal/Symfony world: https://cgit.drupalcode.org/form_alter_service/tree/src/FormAlterCompilerPass.php

Examples

Besides of fully-operable examples, you can check a quick use case:

(new MethodValidator(object<ReflectionMethod>, string<FQCN>))
    ->addArgument(
        (new ArgumentSpecification('form'))
            ->setType('array')
            ->setOptional(false)
            ->setPassedByReference(true)
    )
    ->addArgument(
        (new ArgumentSpecification('formState'))
            ->setType(Iterator::class)
            ->setOptional(false)
            ->setPassedByReference(false)
    );

About

Define a specification of PHP entity and check whether the particular item matches it.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages