-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Remove "final" from methods in Table schema class #6573
Comments
To be honest, I don't find this kind of issue very constructive. The fact that you don't know the reason behind a developer's decision, does not mean that there is "no valid reason" for that decision or that said decision "makes no sense". Just as you probably wouldn't be happy about being told that mocking a state representation of a 3rd party package such as the |
Sorry for my ignorance questioning that decision. What is the reason behind using final for those two methods only? |
We are trying to keep the external API surface to the necessary minimum to reduce the amount of effort required for maintenance. |
Regarding the "only" part, that's because they were added after the other methods, that were historically not final. Removing |
@morozov @greg0ire Thank you for your explanation! Nevertheless, adding According to https://ocramius.github.io/blog/when-to-declare-classes-final/, |
That's where you are wrong. For instance, this is a breaking change for extending types: -protected function();
+protected function(): int; add the -final protected function();
+final protected function(): int; Having the possibility to do such a change in the future could be handy in case generics are introduced, for instance.
Then don't use stubs? It's not like creating a |
Another problem with non-final methods is that, if we deprecate one, we need to have the framework use it until the next major release, because if it's overridden, then no longer calling it is a BC break. Eventually, all subclasses of |
You can't remove public methods (final or not) without a BC break. |
Where did you read anything about removing a method? |
Public class methods belong to the external API and can be used by consumers of the API, so any removal of a public class method is a BC break |
Yes, but nobody here said anything about removing them. |
Here |
No? This is about being able to stop calling the deprecated method… what makes you think it's about removing it? |
Feature Request
What
There are only two methods in the Table schema class which are marked as final, which seems to make no sense:
dbal/src/Schema/Table.php
Lines 274 to 283 in afcd624
Why
There seems to be no valid reason to make that methods final and using final methods, this makes it impossible to a) overwrite these methods and b) mock them in tests (our problem at the moment).
How
Just remove the "final" method modifier here:
dbal/src/Schema/Table.php
Lines 274 to 283 in afcd624
The text was updated successfully, but these errors were encountered: