meilisearch / meilisearch-php

PHP wrapper for the Meilisearch API

Home Page:https://meilisearch.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DX - Make SDK classes `final` when possible

stloyd opened this issue · comments

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/

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)

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.

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