Problem/Motivation
When upgrading my drupal 9.5 project with "composer update", drupal/environment_indicator got updated from 4.0.14 to 4.0.21. Now I get a PHP error:
ParseError: syntax error, unexpected ')', expecting variable (T_VARIABLE)
in Composer\Autoload\{closure}()
(line 96 of modules/contrib/environment_indicator/src/ToolbarHandler.php).
This is because of commit 7de422f44e3234cacfdc9972b2282386e5a61156 for issue #3425788, which added a trailing comma in the constructor signature:
public function __construct(
ModuleHandlerInterface $module_handler,
ConfigFactoryInterface $config_factory,
AccountProxyInterface $account,
StateInterface $state,
Settings $settings,
EntityTypeManagerInterface $entity_type_manager,
) {
This is not supported by PHP 7.4, which itself is supported by Drupal 9.
Unfortunately, the composer.json does not specify a PHP version constraint.
Proposed resolution
Release a new 4.x version with PHP 7.4 support, or declare the PHP version constraint in all releases since 4.0.19.