PHP: Parse Error: syntax error, unexpected ‘:’, expecting ‘;’ or ‘{‘

The very cryptic error message

Parse Error: syntax error, unexpected ':', expecting ';' or '{'

It is in most cases a PHP7 incompatibility.

The code contains a language feature, What is only available at PHP7:

Return type definitions (Definition of the return value). Example:

function myFuntion($input): array
    return ['foo'];

This can strength enable, the function must return an array, otherwise an TypeErrror is thrown.

To make the code less PHP version running, muss man die Return Type Definition entfernen:

function myFuntion($input)
    return ['foo'];

Special case: composer

Happened with me, that it is not about code by me, but about dependencies, that I had installed with compser.
Typically they hired version the minimum in composer by PHP:

"php": ">=5.6",

It can make sense but also, the version of PHP to configure to avoid problems:

"config": {
    "platform": {
        "php": "5.6"