#!/bin/bash

pwd

echo "Running pre-commit hook..."

function header {
	echo "================================================================================"
	echo $1
	echo "================================================================================"
}

function stop {
	if [[ $? != 0 ]]; then
		echo "EXIT"
		exit 1
	fi
}

header "Syntax check with PHP-CS-Fixer"
vendor/bin/php-cs-fixer fix --diff --dry-run --verbose
stop

header "Syntax checking with PHP"
php -l src/*
stop
php -l tests/*
stop

header "Code analyses with PHPStan"
vendor/bin/phpstan analyse
stop

header "Testing with PHPUnit"
vendor/bin/phpunit
stop

echo
echo "OK. Commit status:"
