Problem/Motivation
I am sure this is more about server-side configuration but it looks like commas before closing parenthesis in create() functions of classes somehow breaks composer autoload function.
The errors is:
ParseError: syntax error, unexpected ')' in Composer\Autoload\includeFile() (line 66 of modules/select_or_other/src/Plugin/Field/FieldWidget/ReferenceWidget.php).
When installing the module I needed to manually fix following files:
ReferenceWidget.php
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$plugin_id,
$plugin_definition,
$configuration['field_definition'],
$configuration['settings'],
$configuration['third_party_settings'],
$container->get('entity_type.manager'),
$container->get('entity_type.bundle.info'),
$container->get('current_user'), // Removing this comma
);
}
ListWidget.php
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$plugin_id,
$plugin_definition,
$configuration['field_definition'],
$configuration['settings'],
$configuration['third_party_settings'],
$container->get('current_user'),
$container->get('entity_type.manager'), // Removing this comma
);
}
After removing the commas autoload loads files well and everything works as intended.
Steps to reproduce
It might as well be related to older version of Drupal. On this project I run Drupal 8.9.13 and PHP 7.2.24
Proposed resolution
I am not sure how to write the patch but it seems to be a simple fix which will not break anything anywhere else.