Request validation rules documentation based on static analysis instead of `eval`
WIP
fixes #226, fixes #169, fixes #235, fixes #634
This one is another very complex PR, but it ~would allow creating playgrounds for Scramble by making rules evaluation optional and relying on static analysis instead~ will reduce the amount of bugs due to evaluation issues.
To make this possible a bit more features to inference system must be added:
- [x] Static methods call analysis support
- [x] Late static binding analysis support (proper handing of
static::,self::,__CLASS__)- [x] Figure out general approach
- [x]
classconst fetching - [x] Consts fetching
- [x]
newcalls - [x] Method calls (static, non-static)
- [x] Props fetching
- [x] Consts fetch type inference support
- [x] Static method calls extensions support
- [x] Add
array_keysfunction support - [x] Inferring type from array value
- [ ] Inferring type from object value
And to Scramble docs generation:
- [x]
Rule::*methods inference support (via extensions for now) - [ ] Rules classes better support
- [ ]
Databaserules (exists,unique) and their methods - [ ]
new Enum|In|*rule creation
- [ ]
- [ ] New Rules API
- [ ] Documenting statically analyzed rules (rules type)
- [ ] Runtime objects -> Types conversion (for class-based rules)
@romalytvynenko I would enjoy this fix so much :tada:
I'm on same boat as https://github.com/dedoc/scramble/issues/226
I know this PR has been open a while, but is there anything that could be contributed from the community to bring this into a release?
@stefanzweifel the latest Scramble release has error tolerant validation rules evaluation which in most cases will be more efficient than the approach I was going to take with this PR. Have you tried the latest release? If it doesn't work for you, can you tell me more about your use case?
@romalytvynenko Nothing specific that results in an error in our current project. Saw the PR and really like the idea of using static analysis.
In our project we were struggling to get the api docs working, as we split our validation rules into instance-specific-request classes; but we could find a solution by using Request::createFrom() to make Scramble happy again.
@romalytvynenko thanks for your great work here. :fire:
Is there anything that could be contributed from the community to bring this into a release? I glad to help to complete this PR.
Closing this PR due to many ideas from it were implemented in 0.12.20+ releases.