phiamo / MopaBootstrapBundle

Easy integration of twitters bootstrap into symfony2
http://bootstrap.mohrenweiserpartner.de
711 stars 349 forks source link

Compatibility issue with PHP 7.4 due to return type hinting in FormActionsType #1285

Open N26N26 opened 2 months ago

N26N26 commented 2 months ago

Hi,

I encountered a syntax error while updating mopa/bootstrap-bundle from version 3.4.2 to 3.5.0 with PHP 7.4. The error is due to the use of union return type hinting in the FormActionsType class, which is not supported in PHP 7.4. According to the packagist documentation, this bundle should be compatible with PHP 7.4, so this appears to be either a documentation error or a code error.

### Error message:

ParseError: syntax error, unexpected '|', expecting ';' or '{'

### File and line number:

./vendor/mopa/bootstrap-bundle/Form/Type/FormActionsType.php:49

### Problematic code:

protected function createButton($builder, $name, $config): ButtonBuilder|FormBuilderInterface

For the moment, I have temporarily fixed the issue by requiring version 3.4.2 of mopa/bootstrap-bundle. However, I wanted to bring this to your attention as it is likely an issue that needs to be addressed.

### Suggested solution:

To resolve this issue, the documentation should either be updated to reflect that PHP 7.4 is not supported, or the code should be modified to be compatible with PHP 7.4. Here is one potential code modification:

Omit the return type hinting:

protected function createButton($builder, $name, $config)