for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace JoaoRobertoPB\PhpGitHookSniffer\Pipelines;
use JoaoRobertoPB\PhpGitHookSniffer\Contracts\PipelineInterface;
class LintStage implements PipelineInterface
{
/**
* Process the payload.
*
* @param mixed $payload
*/
public function __invoke($payload)
echo "[ ] ----- Check Syntax Error -----\n";
foreach ($payload as $file) {
$fileName = trim($file);
$ext = pathinfo($fileName, PATHINFO_EXTENSION);
$return = 0;
if ('php' != $ext) {
continue;
}
$lintOutput = [];
exec('php -l '.escapeshellarg($fileName), $lintOutput, $return);
if ($return != 0) {
$return
foreach
18
echo implode("\n", $lintOutput), "\n";
$lintOutput
echo "[FAIL] ----- Check Syntax Error -----\n";
exit(1);
exit
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.
echo "[OK] ----- Check Syntax Error -----\n";
return $payload;