-
Notifications
You must be signed in to change notification settings - Fork 22
Simplify Server registration v2 #228
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
Simplify Server registration v2 #228
Conversation
lib/src/Router.php
Outdated
| /** | ||
| * @param ServerWithPathPrefix&RequestHandlerInterface $server | ||
| */ | ||
| public function registerServer(ServerWithPathPrefix $server): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have intersection types here, but they are supported since php8.1, and this will require to drop php7.4 & php8.0 support.
| public function registerServer(ServerWithPathPrefix $server): void | |
| public function registerServer(ServerWithPathPrefix&RequestHandlerInterface $server): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option that ServerWithPathPrefix should extend RequestHandlerInterface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given 8.0 has been EOL for almost two years now, I don't think dropping support would be a huge issue.
I'm not against extending the request handler interface either, just make sure it's implemented by the generated servers separately as well (to follow the concept we agreed to in the other PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sagikazarmark I suggest to move forward and drop old PHP versions support. It will help us to use all features of the language.
In a 4 days PHP8.5 will be released.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sagikazarmark and I propose to remove deprecated \Twirp\Server class, since it's deprecated for a 4 years already.
|
@sagikazarmark @SpencerMalone what do you think about proposed interface name? And do we add |
|
Idiomatic PHP I think is to have the suffix, even though I don't personally love it (but that's the golang dev in me talking). If it were me, I would probablyyyy leave the suffix off, but honestly don't feel strongly enough to push one way or another. |
SpencerMalone
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a maintainer but this LGTM
|
@sagikazarmark what's your opinion? I'd better go with Interface suffix |
|
I always thought that Interface suffix is an ugly code smell people invented because they fundamentally misunderstand interfaces. Normally I wouldn't fight it, because I know it's a standard in the PHP community, but the rest of the interfaces in the library don't use suffixes (looks like I wrote this lib during one of my rebel periods :) ), so for that reason alone (consistency), I'd say drop the suffix. Otherwise, LGTM |
|
@sagikazarmark renamed interface |
|
Thanks @antonkomarev Sorry it took some time for me to come around |
Overview
Replacement for the:
Simplify registration of server, because PATH_PREFIX constant declares:
What this PR does / why we need it
Instead of this:
Or this:
We can do:
Special notes for your reviewer
I tend to add an
*Interfacesuffix to the interface files, but didn't see that prefix in current local interfaces, so omitted it.Does this PR introduce a user-facing change?