Active
Project:
Drupal core
Version:
main
Component:
base system
Priority:
Normal
Category:
Plan
Assigned:
Unassigned
Reporter:
Created:
19 Jan 2019 at 11:18 UTC
Updated:
21 Jan 2019 at 11:32 UTC
Jump to comment: Most recent
In #2920309: Add experimental module for Help Topics we tried to use final class to limit the API of the alpha experimental module. This was rejected by D8 release managers because @xjm noted
What we're saying is that right now, under current core policy, final should only be used for things that will never, ever be overridden, because that's what current core practice does. In general, I advise against tying this issue up in a policy discussion that hasn't been concluded (and is contentious).
https://www.drupal.org/project/drupal/issues/2920309?page=1 - comment #353
Allow experimental modules to use final as they see fit whilst in alpha and beta.
Further discussion.
Comments
Comment #2
alexpottNote that I can not find any mention of
finalnot being permitted or its valid as by core policy use-cases in https://www.drupal.org/docs/develop/standards/object-oriented-code or https://www.drupal.org/docs/develop/standards/coding-standards - but of course it's not easy to find things on d.o.Comment #3
cilefen commentedHave we mocked any final classes in phpunit? AFAIK it isn’t trivial. You can mock objects out of interfaces, so I guess that has not been an issue.
Comment #4
larowlanAside from mocking shortcomings, I am in favour of using final to enforce what is and isn't an extension point, along with private as well.
Language features will always be a stronger signal than documentation, convention and policies.
Comment #5
larowlanComment #6
wim leers@larowlan: you might want to state the same on #3019332: Use final to define classes that are NOT extension points.