php-gettext / Gettext

PHP library to collect and manipulate gettext (.po, .mo, .php, .json, etc)
MIT License
687 stars 134 forks source link

Support late static binding across all classes #232

Closed schlessera closed 4 years ago

schlessera commented 4 years ago

The classes have a mixture of practices right now which make them very tricky to extend.

All classes seem to communicate they can be extended (i.e. they are not marked as final), but as most of them don't properly support late static binding (they use self:: and private methods), extending them will lead to unexpected results and hard-to-diagnose bugs. self:: and private should only be used in final classes, or, in more rare cases, when an extension should specifically not have access to some part sof the base class.

The solution is to either mark all of them as final (provided there is an underlying interface), or make sure they properly support extension.

I've opted for the second option in this PR, for the following reasons:

Related issue: #231