Problem/Motivation
PHP has a language misfeature where a class can be marked as final
. There's no benefit as far as the language is considered, it is solely useful as a social construct to indicate this class is not covered by any BC policies and could change at any time and so it should not be extended. However, as #17 says
Looking back at amount of wasted time of community on issues like "make this place extensible" and sometimes unexpected future of new code I strongly against using final
Moreover making open source it looks a nonsense to spend time on closing/protecting it
Proposed resolution
The same social construct can be reached by using @final
instead. It is used by Guzzle, Symfony, Twig, behat, composer, phpstan etc. It is recognized by PhpStorm and possibly other IDEs which is no surprise since it was invented for phpDocumentor back in the PHP4 days. Drupal could also use it in all places which are exempted from BC already: plugin implementations, paramconverters, access checkers, event subscribers, hook implementation classes etc.
Further, @final
is just a comment and as such it can be applied to anything -- indeed, it is used in upstream on methods already which fixes another long standing problem of the same make: private
.
(Originally the issue was only about hook implementations but nothing here is specific to those.)