Attention
TYPO3 v11 has reached end-of-life as of October 31th 2024 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.
Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v11 here: TYPO3 ELTS.
Enumerations & bitsets
- Use an enumeration, if you have a fixed list of values.
- Use a bitset, if you have a list of boolean flags.
Do not use PHP constants directly, if your code is meant to be extendable, as constants cannot be deprecated, but the values of an enumeration or methods of a bitset can.
Background and history
Before version 8.1, PHP had no enumeration concept as part of the language. Therefore the TYPO3 Core includes a custom enumeration implementation.
In TYPO3, enumerations are implemented by extending the abstract class
\TYPO3\
. It was originally implemented similar
to \Spl
which is unfortunately part of the unmaintained package
PECL spl_types.
With PHP version 8.1, an enumeration concept was implemented (see the Enumeration documentation for more details). This makes it possible to drop the custom enumeration concept from the Core in a future TYPO3 version.