reflection / validator
Define a specification of PHP entity and check whether the particular item matches it.
Installs: 162 592
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 0
Open Issues: 2
Requires
- php: >=7.0
- doctrine/annotations: 1.*
Requires (Dev)
- phpunit/phpunit: >=5
This package is auto-updated.
Last update: 2024-10-23 17:36:29 UTC
README
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: http://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) );