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

make classes final for 2.0 #321

Merged
merged 1 commit into from
Sep 5, 2024
Merged

make classes final for 2.0 #321

merged 1 commit into from
Sep 5, 2024

Conversation

dbu
Copy link
Collaborator

@dbu dbu commented Mar 5, 2019

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? yes
Related tickets fix #317
Documentation -
License MIT

What's in this PR?

Declaring final all classes that are marked as @final for the new major version

@xabbuh
Copy link
Member

xabbuh commented Mar 5, 2019

Have all the internal classes been internal since 1.0? Otherwise making them final would technically be a BC break too.

Collector/Collector.php Outdated Show resolved Hide resolved
@dbu
Copy link
Collaborator Author

dbu commented Mar 5, 2019

good point. the classes have been added in #128 and have been @internal since the beginning.

@dbu dbu force-pushed the mark-final branch 2 times, most recently from 1651c9a to b89618e Compare March 5, 2019 10:52
@dbu dbu mentioned this pull request Mar 13, 2019
@ostrolucky
Copy link
Collaborator

What's the advantage of this? In userspace I might want to extend these classes despite that they are not covered by semver.

@dbu
Copy link
Collaborator Author

dbu commented Nov 18, 2019

the problem with non-final classes is that people will start extending them, and then complain when things break because we change their signature. extending a class can break in so many ways when the base class does not consider BC (method name clashes, changing a method from protected to public in the base class, ...)

@ostrolucky
Copy link
Collaborator

You say that, but it doesn't really happen. Not for internal classes. And when it does, it's easy to quickly close such requests. It's much more likely you will receive requests to remove those finals. Look how many of such requests are in moneyphp repository.

@dbu
Copy link
Collaborator Author

dbu commented Nov 18, 2019

i do remember a few cases where people complained when we broke stuff, and i remember tons of cases where we had huge discussions about breaking BC with changes in such classes.

looking at what i want to make final, its really things about the layout in the debug toolbar. i don't expect people to need to customize that. if they want to provide visual tweaks (like you did in #355) that's awesome and should go into this repo rather than be project specific.

@dbu dbu force-pushed the mark-final branch 2 times, most recently from e05e986 to 022456a Compare November 27, 2019 08:55
@ostrolucky
Copy link
Collaborator

ostrolucky commented Nov 27, 2019

i do remember a few cases where people complained when we broke stuff

In classes marked @internal?

@dbu
Copy link
Collaborator Author

dbu commented Nov 27, 2019

that i don't remember. but what is your goal? would you only soft-mark the classes as internal, and allow people to break the rules and when things break for them, we can tell them "told you so"?

@php-http/owners what is your take on making classes final? i prefer it, but don't have a very strong opinion...

@ostrolucky
Copy link
Collaborator

Yes, @internal, or @final. That is defacto symfony's approach, even though recently they started to break this symfony/symfony#25788

Yes, I don't expect need of extending these classes ever, but software engineering runs into unforeseen change of requirements all the time.

@dbu dbu force-pushed the mark-final branch 2 times, most recently from 8a896e7 to 6a589e2 Compare May 12, 2023 09:29
@dbu dbu changed the base branch from 1.x to 2.x November 18, 2023 08:32
@dbu dbu changed the base branch from 2.x to 1.x November 18, 2023 08:33
@dbu dbu force-pushed the mark-final branch 2 times, most recently from f4d7483 to 3e38cc0 Compare November 18, 2023 17:50
@dbu
Copy link
Collaborator Author

dbu commented Sep 1, 2024

@xabbuh what is the current policy of symfony regarding final? i like the approach of making everything that is not meant to be extended final (which is almost everything in this bundle). there are interfaces that can be implemented if somebody needs to customize something. they can then just implement their own, or write decorators around the final classes.

i am adding the annotations in #467 for the 1.x branch, as we agree on doing that.

@xabbuh
Copy link
Member

xabbuh commented Sep 2, 2024

@dbu We don't have any strict rules but I guess nowadays new code often follows what Marco has written in https://ocramius.github.io/blog/when-to-declare-classes-final/.

@ostrolucky
Copy link
Collaborator

I also don't have anything against declaring classes final if they implement interface, like marco's post declares. This PR at the moment follows that

@dbu dbu changed the base branch from 1.x to 2.x September 4, 2024 20:09
@dbu dbu changed the title make internal classes final and mark other classes that will be final in 2.0 make classes final for 2.0 Sep 4, 2024
@dbu dbu added this to the 2.0.0 milestone Sep 4, 2024
@dbu dbu force-pushed the mark-final branch 4 times, most recently from 39184b7 to 3ce84bc Compare September 5, 2024 05:40
@dbu
Copy link
Collaborator Author

dbu commented Sep 5, 2024

i changed this MR to point to the 2.x branch and cleaned it up. does one of you want to review and merge?

@dbu dbu requested a review from xabbuh September 5, 2024 07:29
@ostrolucky ostrolucky merged commit ffeb988 into 2.x Sep 5, 2024
12 checks passed
@xabbuh xabbuh deleted the mark-final branch September 6, 2024 07:19
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.

4 participants