-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Options Handler, Interface and Parser #107
Conversation
Refactor Options_Parser to require all dependencies as constructor parameters. Inject dependencies in render.php. Add type hints for injected dependencies in Options_Parser. Add method to check whether every element of the injected array is implementing Options_Interface.
Add type hints for methods that need them. Refactor array declaration from array() to []. Rename one method to better show its function.
Add parameter and return types to all methods. Make void returns explicit in methods that call other methods. Change array declaration from array() to []. Make code style consistent.
Fix parameter types. Refactor handlerForOption method to always return an array. Use strict equality operator for strings. Cast option key passed to handlers to string. Add short options from package handlers to short option list.
Smoke test failures for PHP 7.1-7.4 are due to parameter and return types. Ie. the minimum PHP version needs a bump to 8.0+. This need is not introduced by this PR though as the codebase already makes use of PHP 8.0+ features (e.g.: |
Remove string casts. Change the package handlers array of the Parser constructor to a variadic Options_Interface and remove validation method.
Do you want to rebase the last commit into one of the prior commits for me to rebase, or just squash-merge the whole thing? |
I think a squash merge makes sense here. The only reason there are so many commits in this PR was for me to keep track of what I was doing (and possibly to make reviewing it easier). I'll squash commits like these in the future before I open a PR. |
You can keep the multiple commits when doing PRs as it makes reviewing easier :) |
Most of this PR adds dependencies of
Options_Parser
as constructor parameters (and injects them fromrender.php
) and adds parameter and return types toOptions_Handler
,Options_Interface
andOptions_Parser
.There are six smaller commits in this PR and it's probably easier to review it commit by commit.