From f9f12590e8c106dd804d96bee9926c4dd84b0051 Mon Sep 17 00:00:00 2001 From: Hugo Thunnissen Date: Mon, 14 Aug 2023 19:41:57 +0200 Subject: [PATCH] Handle cases where declarations do not contain a name --- phpinspect-project.el | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/phpinspect-project.el b/phpinspect-project.el index 0eb3ac8..6f8b228 100644 --- a/phpinspect-project.el +++ b/phpinspect-project.el @@ -189,20 +189,23 @@ indexed by the absolute paths of the files they're watching.")) (cl-defmethod phpinspect-project-add-class ((project phpinspect-project) (indexed-class (head phpinspect--indexed-class)) &optional index-imports) - (let* ((class-name (phpinspect--type-name-symbol - (alist-get 'class-name (cdr indexed-class)))) - (class (gethash class-name - (phpinspect-project-class-index project)))) - (unless class - (setq class (phpinspect--make-class-generated :project project))) - - (when index-imports - (phpinspect-project-enqueue-imports - project (alist-get 'imports (cdr indexed-class)))) - - (phpinspect--class-set-index class indexed-class) - (puthash class-name class (phpinspect-project-class-index project)) - (phpinspect-project-add-class-attribute-types-to-index-queue project class))) + (if (not (alist-get 'class-name (cdr indexed-class))) + (phpinspect--log "Error: Class with declaration %s does not have a name" (alist-get 'declaration indexed-class)) + ;; Else + (let* ((class-name (phpinspect--type-name-symbol + (alist-get 'class-name (cdr indexed-class)))) + (class (gethash class-name + (phpinspect-project-class-index project)))) + (unless class + (setq class (phpinspect--make-class-generated :project project))) + + (when index-imports + (phpinspect-project-enqueue-imports + project (alist-get 'imports (cdr indexed-class)))) + + (phpinspect--class-set-index class indexed-class) + (puthash class-name class (phpinspect-project-class-index project)) + (phpinspect-project-add-class-attribute-types-to-index-queue project class)))) (cl-defmethod phpinspect-project-set-class ((project phpinspect-project) (class-fqn phpinspect--type) (class phpinspect--class))