Skip to content
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

Merged
merged 7 commits into from
Mar 7, 2024

Conversation

haszi
Copy link
Contributor

@haszi haszi commented Mar 1, 2024

Most of this PR adds dependencies of Options_Parser as constructor parameters (and injects them from render.php) and adds parameter and return types to Options_Handler, Options_Interface and Options_Parser.

There are six smaller commits in this PR and it's probably easier to review it commit by commit.

haszi added 6 commits March 1, 2024 15:12
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.
@haszi
Copy link
Contributor Author

haszi commented Mar 1, 2024

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.: match, str_contains(), etc.).

Remove string casts.
Change the package handlers array of the Parser constructor to a variadic Options_Interface and remove validation method.
@haszi haszi requested a review from Girgias March 3, 2024 20:13
@Girgias
Copy link
Member

Girgias commented Mar 5, 2024

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?

@haszi
Copy link
Contributor Author

haszi commented Mar 6, 2024

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.

@haszi haszi requested a review from Girgias March 7, 2024 14:06
@Girgias
Copy link
Member

Girgias commented Mar 7, 2024

You can keep the multiple commits when doing PRs as it makes reviewing easier :)

@Girgias Girgias merged commit efea045 into php:master Mar 7, 2024
8 checks passed
@haszi haszi deleted the Refactor-options-handlers branch March 7, 2024 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants