How to have different versions of PHP syntax coexist?

In my PHP file this line of code:

private const string NS_HTML = 'http://www.w3.org/1999/xhtml';

only works for PHP 8.3 or after.

If I want to make my library compatible to 8.2, is downgrading the syntax the only way to go? i.e.

private const NS_HTML = 'http://www.w3.org/1999/xhtml';

What I really want to achieve is some sort of magic like:

if (PHP_VERSION >= '8.3') {
  private const string NS_HTML = 'http://www.w3.org/1999/xhtml';
} else {
  private const NS_HTML = 'http://www.w3.org/1999/xhtml';
}

You may argue dropping the type constraint from a constant is not a big deal, but I am just giving out a simple example. Another 8.3 feature I use is the #[Override] attribute and I would love to keep them.

Update: based on answer from How can I code for multiple versions of PHP in the same file without error?:

This would work:

if (PHP_VERSION_ID >= 803000) {
    require_once __DIR__ . '/class-a-php8.3.php';
} else {
    require_once __DIR__ . '/class-a-php8.2.php';
}

While this won’t:

if (PHP_VERSION_ID >= 803000) :
    class A {
        private const string NS_HTML = 'http://www.w3.org/1999/xhtml';
        ...
    }
else:
    class A {
        private const NS_HTML = 'http://www.w3.org/1999/xhtml';
        ...
    }
endif;

i.e. different versions of syntax must sit in separate files.