- Set a path to a file with custom error callback to
--syntax-error-callback
option. - Create a class implementing
PHP_Parallel_Lint\PhpParallelLint\Contracts\SyntaxErrorCallback
interface. File with the class must have the same name as the class inside. - Modify error before it is printed to the output.
File MyCustomErrorHandler.php
will be passed as an argument like ./parallel-lint --syntax-error-callback ./path/to/MyCustomErrorHandler.php .
.
The content should look like:
use PHP_Parallel_Lint\PhpParallelLint\Contracts\SyntaxErrorCallback;
use PHP_Parallel_Lint\PhpParallelLint\Errors\SyntaxError;
class MyCustomErrorHandler implements SyntaxErrorCallback {
/**
* @param SyntaxError $error
* @return SyntaxError
*/
public function errorFound(SyntaxError $error){
// Return new SyntaxError with custom modification to FilePath or Message
// Or return custom implementation of SyntaxError extending the original one...
return new SyntaxError(
$error->getFilePath(),
$error->getMessage()
);
}
}