Search code examples
phpbddbehat

Need help in overcoming the incompatibility of a certain behat dependencies set with a PHP 5.3


I was having a certain behat configuration with a specific dependencies set which worked well with PHP 5.5. But later I've had to transfer that configuration to a server with jenkins. The trouble is that server has PHP 5.3 installed with no possibility to be updated.

Despite dependencies refused to be installed via composer in a normal way, I've forced them to be installed anyway using the "--ignore-platform-reqs" parameter.

Having installed the dependencies, I've faced with another issue which I could not had overcome that easily. It simply displays an error while attempting to execute "bin/behat" command:

 PHP Parse error:  syntax error, unexpected '[' in .../workspace/automated-tests/vendor/guzzlehttp/psr7/src/functions.php on line 77
PHP Stack trace:
PHP   1. {main}() .../workspace/automated-tests/vendor/behat/behat/bin/behat:0
PHP   2. includeIfExists() .../workspace/automated-tests/vendor/behat/behat/bin/behat:21
PHP   3. include() .../automated-tests/vendor/behat/behat/bin/behat:17
PHP   4. ComposerAutoloaderInit617eef80953ba1e8b93feeaeccb52bc0::getLoader() .../workspace/automated-tests/vendor/autoload.php:7
PHP   5. composerRequire617eef80953ba1e8b93feeaeccb52bc0() .../workspace/automated-tests/vendor/composer/autoload_real.php:49
PHP   6. require() .../workspace/automated-tests/vendor/composer/autoload_real.php:59
Parse error: syntax error, unexpected '[' in .../workspace/automated-tests/vendor/guzzlehttp/psr7/src/functions.php on line 77 Call Stack: 0.0006 645368 1. {main}() .../workspace/automated-tests/vendor/behat/behat/bin/behat:0 0.0008 645976 2. includeIfExists() .../workspace/automated-tests/vendor/behat/behat/bin/behat:21 0.0016 649328 3. include('.../workspace/automated-tests/vendor/autoload.php') .../workspace/automated-tests/vendor/behat/behat/bin/behat:17 0.0021 680968 4. ComposerAutoloaderInit617eef80953ba1e8b93feeaeccb52bc0::getLoader() .../workspace/automated-tests/vendor/autoload.php:7 0.0082 1106296 5. composerRequire617eef80953ba1e8b93feeaeccb52bc0() .../workspace/automated-tests/vendor/composer/autoload_real.php:49 0.0089 1109928 6. require('.../workspace/automated-tests/vendor/guzzlehttp/psr7/src/functions_include.php') .../automated-tests/vendor/composer/autoload_real.php:59

Here's the list of dependencies in composer.json:

{
  "require": {
    "behat/gherkin": "~4.4",
    "drupal/drupal-extension": "~3.1",
    "emuse/behat-html-formatter": "dev-master"
  },
  "require-dev": {
    "bossa/phpspec2-expect": "~1.0",
    "ocramius/proxy-manager": "~0.5",
    "phpunit/phpunit": "~4.5",
    "jakoch/phantomjs-installer": "1.9.8"
  },
  "autoload": {
    "psr-0": {
      "Behat\\Behat":    "src/",
      "Behat\\Testwork": "src/"
    }
  },
  "config": {
    "bin-dir": "bin/"
  }
}

Solution

  • I've found a solution to the problem. I've changed the "require" block in composer.json to the following:

    {
      "require": {
        "drupal/drupal-extension": "*",
        "emuse/behat-html-formatter": "dev-master"
      },
    

    Notice that I've got rid of the ""behat/gherkin": "~4.4"" and changed drupal/extension version to "*". Thus it downloads the latest and most stable version along with all dependencies it requires (so behat 4 is included as well) according to the specs of my system (so its PHP 5.3 compatible).

    At least that's the way I see it. Please, correct me If I'm wrong.