-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Hi,
thank you for providing us that great gnupg port and I appriciate all work so far on it. To be honest for just calling it a "port", it might be enough.
But in order to help the project to gain more acceptance in the community, in order to pay the respect to your work and in order to not suprise you with a pull request fixing all that stuff in a "huge" one, the following are my recommendations and / or improvement ideas. You might want to spilt it up into separate tasks, if you feel comfortable with:
- reformat your php code according to the de-facto leading PSR-12 standard
- logging to php's stderr stream is old school, instead require the PSR LoggerInterface as dependency and inject it using dependency injection: This way, it basically can be logged through php stderr, but it scales a lot more to which stream(s) the message should be logged onto. I'd recommend to use it as an default constructor parameter and via a setter method in the class itself.
- require in the composer.json also the needed php (
ext-jsonwith version*) extension dependencies and the operating system dependencies as well. Since it that library you don't really distinguish between cli and web server usage, it's pretty common to provide all these libs as dependencies in the compser'srequiresection. This way, you can be sure that there is e. g. json present in the current php runtime, so no need for class-level-checks. - try to simplify your code complexity by avoiding much deep nested
if/whileetc. blocks for better maintainability. static code analyzers likephpstan/phpstanmight be a good tool for detecting such code smells and providing a helpful complexity score in order to figure out what should be fixed and what shouldn't - maybe enforce the coding style from contributers by using an
.editorconfigfile, which most code editors and IDEs nowadays provide support for: https://editorconfig.org/
This above list might not be complete, but should lead the project in the right direction. And I hope you will find these tips helpful. I'd like to read your feedback to my thoughts, Please note that these tips were brought to my head by a quick code review.
cheers,
alpham8