-
Notifications
You must be signed in to change notification settings - Fork 2k
refactor: remove unneeded abstract public methods #6713
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: remove unneeded abstract public methods #6713
Conversation
|
It feels a little weird to have Does anyone have examples of this somewhere else (even outside of CodeIgniter)? Where an abstract class implements the interface without the actual methods? |
|
If you are not using an IDE then I believe it is normal to feel the weirdness. PHP won't complain the absence of the interface's methods in the abstract class because it is abstract (i.e. incomplete). In that case, PHP will assume the concrete classes will complete fulfilling the interface. |
|
It's an interesting consideration that I haven't come across before. I did a little research and didn't find much but this rather mixed-quality, old conversation thread: https://thuvienphapluat.edu.vn/can-abstract-class-implement-interface-in-php If you two concur on this approach then I'm good with it. |
I use Intelephense but I don't know that it really matters for this case unless your IDE is somehow generating the initial class. When I'm fulfilling an abstraction I literally copy the definitions (either from the interface or the abstract methods from the abstract class) and work on filling them in. I was just noting that in this case one would have to know to go to the interface in this case, not the abstract class. |
|
This is an example from Symfony Console's InputInterface InputInterface defines a getFirstArgument method: but abstract class Input does not define it nor list it as abstract: because the child classes like ArgvInput will fulfill the contract: |
|
In my case using intelephense on VS Code if I'm writing a concrete class implementing an interface or extending an abstract class, intelephense will show a red notice that my concrete class needs to define this and that method. |
|
Awesome! Thanks for that research. Yes let's proceed with this. |
Description
These are already defined by
ConnectionInterface.Checklist: