Cannot declare const %s because
Description
This error is the constant counterpart of the use collision error raised for classes and functions: it fires when a top-level const declaration reuses a name that was already brought into the current file through a use const ... as ... import.
The full message reads: Cannot declare const %s because the name is already in use.
Example
<?php
use const App\FOO as BAR;
const BAR = 42;
?>
Literal Examples
- Cannot declare const BAR because the name is already in use
Alternatives
- Rename the
constdeclaration. - Change the alias used in the
use constimport.
Related error messages
Changed Behavior
This error may appear following an evolution in behavior, in previous versions. See