diff --git a/phpinspect-parser.el b/phpinspect-parser.el index a8cd508..31462a5 100644 --- a/phpinspect-parser.el +++ b/phpinspect-parser.el @@ -786,9 +786,10 @@ Returns the consumed text string without face properties." (char-equal (char-after) ?}))))) (declaration (phpinspect-parse-declaration (current-buffer) max-point continue-condition 'root))) - (if (or (phpinspect-end-of-token-p (car (last declaration))) - (not (looking-at (phpinspect-handler-regexp block)))) + (if (phpinspect-end-of-token-p (car (last declaration))) + ;; Abstract function? (list :function declaration) + ;; Parse body. `(:function ,declaration ,@(cdr (phpinspect--parse-function-body (current-buffer) max-point)))))) diff --git a/test/test-buffer.el b/test/test-buffer.el index 3c34f6d..8f8c45a 100644 --- a/test/test-buffer.el +++ b/test/test-buffer.el @@ -133,7 +133,10 @@ (should (phpinspect-function-p (phpinspect-meta-token (phpinspect-meta-parent (phpinspect-meta-parent bello1))))) (let ((function (phpinspect-meta-token (phpinspect-meta-parent (phpinspect-meta-parent bello1))))) - (should (= 2 (length function))) + ;; There's 5 nested tokens in the function. It is not a valid function + ;; token, a correct function would only contain a declaration and a + ;; block. But the incremental parser doesn't complain. + (should (= 5 (length function))) (should (phpinspect-declaration-p (cadr function))) (should (member '(:word "Bello") (cadr function))) (should (member '(:word "echo") (cadr function)))) @@ -286,6 +289,57 @@ class YYY { (should (equal parsed parsed-after)))) +(ert-deftest phpinspect-buffer-parse-incrementally-class-with-method () + (with-temp-buffer + (let* ((buffer (phpinspect-make-buffer + :buffer (current-buffer)))) + + + (setq-local phpinspect-current-buffer buffer) + (insert + "