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

DX - Make SDK classes final when possible #518

Open
stloyd opened this issue May 31, 2023 · 3 comments
Open

DX - Make SDK classes final when possible #518

stloyd opened this issue May 31, 2023 · 3 comments
Labels
question Further information is requested

Comments

@stloyd
Copy link
Contributor

stloyd commented May 31, 2023

Description

I would even suggest locking all the classes with the final keyword, to prevent the BC breaks, and allow easier maintenance and a safer Developer Experience in the end.

In case we may think that it's worth introducing an interface covering SDK classes to allow either mocking/stubbing, but that could require additional work on standardizing the classes and responsibilities.

Refs: https://ocramius.github.io/blog/when-to-declare-classes-final/

@mmachatschek
Copy link
Collaborator

Concerning the final topic. I hear a lot of negatives about this (in the Laravel community) to not use this feature, even though it looks like a good idea. Users that need to extend classes marked as final will need to wait for upstream or have to fork libs themselves if they run into issues.
Also there are workarounds to extend classes even if they are marked as final so there is no 100% guarantee that the class marked as final will be in the final state.

#514 (comment)

@brunoocasali
Copy link
Member

The PHP code will probably not break, and the change is good. But since it could lead to unexpected results like the one pointed out by @mmachatschek I would prefer to do it in a v2 time.

@brunoocasali brunoocasali added the question Further information is requested label Jun 6, 2023
@norkunas
Copy link
Collaborator

norkunas commented Jun 7, 2023

@final phpdoc could be added to indicate that it will become final in v2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants