I'm working on a legacy PHP codebase that runs on PHP 5.4. I want to derive class-specific constants or properties based on a common constant. So for instance in PHP 5.6 or later I'd do:
config.php
define('CONFIG_DIR', 'PATH_TO_CONFIG_DIR');
MyClass.php
class MyClass {
const FILE_A = CONFIG_DIR . '/fileA';
const FILE_B = CONFIG_DIR . '/fileB';
}
But constant expressions are only allowed since PHP 5.6.
https://www.php.net/manual/en/migration56.new-features.php
So in PHP 5.4 what are the options that I could follow to derive sub-values based on a common constant within the class?