Skip to content

Commit 277f0b4

Browse files
committed
Use pcase
1 parent f266baa commit 277f0b4

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

flymake-phpstan.el

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
;;; Code:
3737
(require 'flymake)
3838
(require 'phpstan)
39+
(eval-when-compile
40+
(require 'pcase))
3941

4042
(defgroup flymake-phpstan nil
4143
"Flymake backend for PHP using PHPStan."
@@ -57,30 +59,30 @@
5759
:command command-args
5860
:sentinel
5961
(lambda (proc _event)
60-
(case (process-status proc))
61-
((exit)
62-
(unwind-protect
63-
(when (with-current-buffer source (eq proc flymake-phpstan--proc))
64-
(with-current-buffer (process-buffer proc)
65-
(goto-char (point-min))
66-
(cl-loop
67-
while (search-forward-regexp
68-
(eval-when-compile
69-
(rx line-start (1+ (not (any ":"))) ":"
70-
(group-n 1 (one-or-more digit)) ":"
71-
(group-n 2 (one-or-more not-newline)) line-end))
72-
nil t)
73-
for msg = (match-string 2)
74-
for (beg . end) = (flymake-diag-region
75-
source
76-
(string-to-number (match-string 1)))
77-
for type = :warning
78-
collect (flymake-make-diagnostic source beg end type msg)
79-
into diags
80-
finally (funcall report-fn diags)))
81-
(flymake-log :warning "Canceling obsolete check %s" proc))
82-
(kill-buffer (process-buffer proc))))
83-
(user-error "PHPStan error")))))
62+
(pcase (process-status proc)
63+
(`exit
64+
(unwind-protect
65+
(when (with-current-buffer source (eq proc flymake-phpstan--proc))
66+
(with-current-buffer (process-buffer proc)
67+
(goto-char (point-min))
68+
(cl-loop
69+
while (search-forward-regexp
70+
(eval-when-compile
71+
(rx line-start (1+ (not (any ":"))) ":"
72+
(group-n 1 (one-or-more digit)) ":"
73+
(group-n 2 (one-or-more not-newline)) line-end))
74+
nil t)
75+
for msg = (match-string 2)
76+
for (beg . end) = (flymake-diag-region
77+
source
78+
(string-to-number (match-string 1)))
79+
for type = :warning
80+
collect (flymake-make-diagnostic source beg end type msg)
81+
into diags
82+
finally (funcall report-fn diags)))
83+
(flymake-log :warning "Canceling obsolete check %s" proc))
84+
(kill-buffer (process-buffer proc))))
85+
(code (user-error "PHPStan error (exit status: %d)" code)))))))
8486

8587
(defun flymake-phpstan (report-fn &rest _ignored-args)
8688
"Flymake backend for PHPStan report using REPORT-FN."

0 commit comments

Comments
 (0)