#!/bin/bash

if command -v docker-compose >/dev/null; then
	docker-compose exec comfino-woocommerce-php composer "$@"
else
	composer "$@"
fi

if [ -d ./vendor/phpspec/prophecy-phpunit ]; then
	if [ -f ./vendor/phpspec/prophecy-phpunit/ProphecyTestCase.php ]; then
		# Fix bug in Prophecy PhpUnit integration library (PHP 7.1 compatibility issue: conflict with old PHPUnit 5.7.x).
		sed -i 's~protected function onNotSuccessfulTest(\\Exception $e)~protected function onNotSuccessfulTest(/*\\Exception*/ $e)~g' ./vendor/phpspec/prophecy-phpunit/ProphecyTestCase.php
	fi
fi
