You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Update phpcs config key and add validateConfigPath: Rename PHPCS_STANDARD to PHPCS_STANDARD_CONFIG for clarity; add a method to validate config file paths for all code analyzers.
- Rename checkAnalyzerInstallation to validateAnalyzerInstallation: Improve method name to better reflect its purpose.
- Improve error message formatting: Enhance readability of error messages in BaseCodeAnalyzerPreCommitHook.
$message .= sprintf("Your commit contains files that should pass %s but do not. Please fix the errors in the files above and try again.\n", $this->getName());
152
-
$message .= sprintf('You can check which %s errors happened in them by executing: <comment>%s {filePath}</comment>', $this->getName(), $this->analyzerCommand());
151
+
$message .= sprintf("Your commit contains files that should pass %s but do not. Please fix the errors in the files above and try again.\n",
152
+
$this->getName());
153
+
$message .= sprintf('You can check which %s errors happened in them by executing: <comment>%s {filePath}</comment>',
154
+
$this->getName(), $this->analyzerCommand());
153
155
154
156
$this->command->getOutput()->writeln($message);
155
157
@@ -163,7 +165,7 @@ protected function commitFailMessage()
163
165
*
164
166
* @throws HookFailException
165
167
*/
166
-
protectedfunctioncheckAnalyzerInstallation()
168
+
protectedfunctionvalidateAnalyzerInstallation()
167
169
{
168
170
if (file_exists($this->analyzerExecutable)) {
169
171
return$this;
@@ -179,6 +181,22 @@ protected function checkAnalyzerInstallation()
179
181
thrownewHookFailException();
180
182
}
181
183
184
+
protectedfunctionvalidateConfigPath($path)
185
+
{
186
+
if (file_exists($path)) {
187
+
return$this;
188
+
}
189
+
190
+
$this->command->newLine(2);
191
+
$this->command->getOutput()->writeln(
192
+
sprintf('<bg=red;fg=white> ERROR </> %s config file does not exist. Please check the path and try again.',
193
+
$this->getName())
194
+
);
195
+
$this->command->newLine();
196
+
197
+
thrownewHookFailException();
198
+
}
199
+
182
200
/**
183
201
* Suggests attempting to automatically fix the incorrectly formatted files or exit.
0 commit comments