Skip to content

Commit 3248a05

Browse files
committed
Add JSON support
1 parent 497ac27 commit 3248a05

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

phpstan.el

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
(require 'php-runtime)
5959

6060
(eval-when-compile
61-
(require 'php))
61+
(require 'php)
62+
(require 'json))
6263

6364
;; Variables:
6465
(defgroup phpstan nil
@@ -294,6 +295,17 @@ it returns the value of `SOURCE' as it is."
294295
"Return --memory-limit value."
295296
phpstan-memory-limit)
296297

298+
(defun phpstan--parse-json (buffer)
299+
"Read JSON string from BUFFER."
300+
(with-current-buffer buffer
301+
(goto-char (point-min))
302+
(if (eval-when-compile (and (fboundp 'json-serialize)
303+
(fboundp 'json-parse-buffer)))
304+
(with-no-warnings
305+
(json-parse-buffer :object-type 'plist :array-type 'list))
306+
(let ((json-object-type 'plist) (json-array-type 'list))
307+
(json-read-object)))))
308+
297309
;;;###autoload
298310
(defun phpstan-analyze-this-file ()
299311
"Analyze current buffer-file using PHPStan."

0 commit comments

Comments
 (0)