Of course there is a small downside to this approach. Using this pattern requires two additional adapter classes and two PHP-file-specific interfaces to be written (when compared to the implementation with generics) and the delegation calls inside the adapters incur a very small runtime overhead. We consider these disadvantages negligible however when compared to the benefits of type safety and proper package dependencies.
You've expressed that the trade-off between the extra classes/overheads and type safety are worthwhile. Is the need to use extra classes to get type safety enough that you'd consider a different language (e.g. one with generics) given the option?
Software architect by profession but mathematician by education, with interests on the boundary between the two, where formal modelling and logical reasoning meet practical problems and pragmatism.
For us, switching to another language is currently not an option (in terms of existing codebase, libraries and infrastructure, developer knowledge and that PHP isn't that bad). However, in a completely new context I would probably choose another language over PHP.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You've expressed that the trade-off between the extra classes/overheads and type safety are worthwhile. Is the need to use extra classes to get type safety enough that you'd consider a different language (e.g. one with generics) given the option?
For us, switching to another language is currently not an option (in terms of existing codebase, libraries and infrastructure, developer knowledge and that PHP isn't that bad). However, in a completely new context I would probably choose another language over PHP.