Skip to content

Instantly share code, notes, and snippets.

@barryvdh
Last active May 16, 2023 12:37
Show Gist options
  • Star 34 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • 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);
@Muntrue
Copy link

Muntrue commented May 22, 2019

Barry hooks you up!

@eleftrik
Copy link

eleftrik commented Jun 5, 2019

Thank you!

@aliuwahab
Copy link

Love this....

@feel3D
Copy link

feel3D commented Mar 25, 2021

Great!

@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