go to bug id or search bugs for
Interpreter produces `PHP Fatal error: Constant expression contains invalid operations in…` because of explicit const value type cast.
But implicit is allowed and works as expected.
Yes, I undestand difference between `+` and `(int)` that `int` will cast to integer and drop past-float part. But question why that's now allowed is still present.
Casting plain value rather than array value doesn't work too. Even if you cast integer to integer.
const BARCODE_TYPES = [
All is OK and array value became int casted.
PHP Fatal error: Constant expression contains invalid operations in…
Add a Patch
Add a Pull Request
Constant expressions only support a limited set of operations. Casts are currently not part of this set. However, apart from the (object) cast, there is no *specific* reason to disallow them, so adding support for this shouldn't be a problem.
Some non-object casts can depend on run-time environment, such as casting double to string (depends on precision).