php-advanced-json-rpc
php-advanced-json-rpc copied to clipboard
refactor: Switch to php documentor reflection
This draft pull request shows a rough implementation of how php-advanced-json-rpc could use PhpDocumentor Reflection. In order to resolve #9. I've added this PR to have a more constructive discussion about the pros and cons. I've based this on the latest stable mayor version of PHPDocumentor Reflection (^4.0). That version only support PHP 7.2 and up (Which is causing the build to fail). This already raises some concern as this lib is aiming to support PHP 7.0 but that is already two years EOL (See https://www.php.net/supported-versions.php). So perhaps some updates are needed for this lib as well?
This PR has the following changes:
- Extracts the current implementation, based on the native reflection classes of PHP, into an interface (strategy pattern)
- Implements a PhpDocumentor Reflection implementation of above interface
In order to complete this PR the following is needed:
- [ ] Add unit tests for the new implementation
- [ ] Decide if the current approach with the Reflection abstraction layer is something that is desired
- [ ] Resolve any @TODO added in this PR
- [ ] General cleanup of the PR.
- [ ] Ensure if we have the optimal way of caching implemented in order to resolve #2
Codecov Report
Merging #44 (e269399) into master (06f0b06) will decrease coverage by
15.11%. The diff coverage is62.96%.
@@ Coverage Diff @@
## master #44 +/- ##
=============================================
- Coverage 89.07% 73.95% -15.12%
- Complexity 58 96 +38
=============================================
Files 8 13 +5
Lines 119 192 +73
=============================================
+ Hits 106 142 +36
- Misses 13 50 +37
| Impacted Files | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| lib/Reflection/PhpDocumentorReflection.php | 0.00% <0.00%> (ø) |
16.00 <16.00> (?) |
|
| lib/Reflection/NativeReflection.php | 90.24% <90.24%> (ø) |
22.00 <22.00> (?) |
|
| lib/Dispatcher.php | 87.50% <90.90%> (-1.39%) |
18.00 <0.00> (-10.00) |
|
| lib/Reflection/Dto/Method.php | 100.00% <100.00%> (ø) |
4.00 <4.00> (?) |
|
| lib/Reflection/Dto/Parameter.php | 100.00% <100.00%> (ø) |
4.00 <4.00> (?) |
|
| lib/Reflection/Dto/Type.php | 100.00% <100.00%> (ø) |
2.00 <2.00> (?) |
|
| ... and 1 more |