Project

General

Profile

Actions

Task #101698

open

Remove "final" keyword

Added by Claus Due 9 months ago. Updated 3 months ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
Miscellaneous
Target version:
-
Start date:
2023-08-16
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

More and more classes are marked as "final" in TYPO3.

This should not be done unless in very specific circumstances:

  • For security reasons, e.g. when a class name can be selected from an exposed option like a form field, and only when such implementations share an interface and the entire application programs against the interface, not the implementation.
  • And that's basically it.

And it should never be done on a class that does not have an interface and where the rest of the framework programs against the specific implementation instead of the interface.

Using "final" as a way to signal that "you shouldn't replace this class" is an abuse of the language construct. Signals should be sent with interfaces or annotations - not by enforcing it as an unavoidable choice imposed on every developer.

The classes that currently declare "final" as well as those that are scheduled to become "final" simply do not fulfill this.

Additionally, "final" without a programmed-to interface is poison for testability in that it prevents the (efficient) creation of test doubles.

Therefore, the "final" keyword should be removed and avoided in the future.


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #101927: TYPO3 Fluid Core ViewHelpers should not be declared "final class"Rejected2023-09-15

Actions
Actions

Also available in: Atom PDF