Skip to content

Commit 33801ad

Browse files
authored
Update pre-commit
1 parent 28eda98 commit 33801ad

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

bin/pre-commit

+14-11
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,22 @@ function runPhpCsFixer()
107107
$returnCode = null;
108108

109109
exec(sprintf(
110-
'%s %s fix --config=.php_cs.php --no-interaction -v --path-mode=intersection -- %s',
110+
'%s %s fix --config=.php_cs.php --dry-run --no-interaction --path-mode=intersection -- %s',
111111
$phpBin,
112112
$phpCsFixerBin,
113113
implode(' ', getFilesToFix())
114114
), $output, $returnCode);
115115

116-
return $returnCode ? $output : false;
116+
if ($returnCode) {
117+
exec(sprintf(
118+
'%s %s fix --config=.php_cs.php --no-interaction -v --path-mode=intersection -- %s',
119+
$phpBin,
120+
$phpCsFixerBin,
121+
implode(' ', getFilesToFix())
122+
), $output);
123+
}
124+
125+
return $returnCode;
117126
}
118127

119128
function runPhpstan()
@@ -143,16 +152,10 @@ if ($phpSyntaxErrors) {
143152
exit(1);
144153
}
145154

146-
$phpCSFixerErrors = runPhpCsFixer();
147-
if ($phpCSFixerErrors) {
155+
$phpCSFixed = runPhpCsFixer();
156+
if ($phpCSFixed) {
148157
echo "Incorrect coding standards were detected and fixed." . PHP_EOL;
149158
echo "Please stash changes and run commit again." . PHP_EOL;
150-
echo "Output:" . PHP_EOL . PHP_EOL;
151-
152-
echo array_walk_recursive($phpStanErrors, function($item) {
153-
echo $item.PHP_EOL;
154-
}) . PHP_EOL;
155-
echo PHP_EOL;
156159

157160
exit(1);
158161
}
@@ -167,4 +170,4 @@ if ($phpStanErrors) {
167170
exit(1);
168171
}
169172

170-
exit(0);
173+
exit(0);

0 commit comments

Comments
 (0)