Skip to content

Instantly share code, notes, and snippets.

@barryvdh
Last active May 16, 2023 12:37
Show Gist options
  • Save barryvdh/3691cbad662ce26ffcad7d3807e89d69 to your computer and use it in GitHub Desktop.
Save barryvdh/3691cbad662ce26ffcad7d3807e89d69 to your computer and use it in GitHub Desktop.
phpunit pre-commit git hook
#!/usr/bin/env php
<?php
echo "Running tests.. ";
exec('vendor/bin/phpunit', $output, $returnCode);
if ($returnCode !== 0) {
// Show full output
echo PHP_EOL . implode($output, PHP_EOL) . PHP_EOL;
echo "Aborting commit.." . PHP_EOL;
exit(1);
}
// Show summary (last line)
echo array_pop($output) . PHP_EOL;
exit(0);
@slunak
Copy link

slunak commented Jan 15, 2023

For PHP ^8.0:

implode(string $separator, array $array): string

Legacy signature (deprecated as of PHP 7.4.0, removed as of PHP 8.0.0):
implode(array $array, string $separator): string

Source: https://www.php.net/manual/en/function.implode.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment