Cannot apply attributes to multiple constants at once

Description

It is not possible to use attributes on global constants, when several constants are defined at the same time. That syntax is possible with class constants, but not with global constants.

Example

<?php

#[Foo]
const A = 1,
      B = 2;

?>

Solutions

  • Split the constant definitions, and apply the same attribute to each of them.

  • Convert the global constants to class constants.

Changed Behavior

This error may appear following an evolution in behavior, in previous versions. See ` <https://php-changed-behaviors.readthedocs.io/en/latest/behavior/.html>`_.