#!/usr/bin/env php
<?php

/*
 * This file is part of ComLaude/php-formatter.
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

$phpCsFixerExecutable = __DIR__.'/../../friendsofphp/php-cs-fixer/php-cs-fixer';
$phpFormatterConfigFile = __DIR__.'/src/DefaultConfigWrapper.php';

// Take any parameters passed to this script
$args = array_slice($argv, 1);
$exitCode = 0;
$outputArray = [];

// Pass the params to php-cs-fixer, but default to package config file
$command = "php " . $phpCsFixerExecutable . " " . implode(" ", $args);
if ($args[0] == 'fix') {
    $command .= " --config=" . $phpFormatterConfigFile;
}

// Retain exit code of underlying script and exit with that
passthru($command, $exitCode);
exit($exitCode);
