Refactor use of project root to project obj injection + test and fix some bugs

- Test/Fix indexation of method return types
- Get rid of some technical debt (use of project-root and global variables)
- Cleanup/refactor tests
master
Hugo Thunnissen 1 month ago
parent e04ab0c118
commit 58ef5e3599

@ -163,13 +163,6 @@ currently opened projects."
project)) project))
(defun phpinspect-get-or-create-cached-project-class (project-root class-fqn &optional no-enqueue)
(when project-root
(let ((project (phpinspect--cache-get-project-create
(phpinspect--get-or-create-global-cache)
project-root)))
(phpinspect-project-get-class-extra-or-create project class-fqn no-enqueue))))
(cl-defmethod phpinspect--cache-get-project-create (cl-defmethod phpinspect--cache-get-project-create
((cache phpinspect--cache) (project-root string)) ((cache phpinspect--cache) (project-root string))
"Get a project that is located in PROJECT-ROOT from CACHE. "Get a project that is located in PROJECT-ROOT from CACHE.
@ -196,6 +189,10 @@ then returned."
(phpinspect-project-enqueue-include-dirs project)))) (phpinspect-project-enqueue-include-dirs project))))
project)) project))
(defun phpinspect-current-project ()
(phpinspect--cache-get-project-create (phpinspect--get-or-create-global-cache)
(phpinspect-current-project-root)))
(defun phpinspect-project-enqueue-include-dirs (project) (defun phpinspect-project-enqueue-include-dirs (project)
(interactive (list (phpinspect--cache-get-project-create (interactive (list (phpinspect--cache-get-project-create
(phpinspect--get-or-create-global-cache) (phpinspect--get-or-create-global-cache)

@ -104,9 +104,16 @@ Conditionally executes BODY depending on
(cl-defmethod phpinspect--class-get-method ((class phpinspect--class) (method-name (head phpinspect-name))) (cl-defmethod phpinspect--class-get-method ((class phpinspect--class) (method-name (head phpinspect-name)))
(gethash method-name (phpinspect--class-methods class))) (gethash method-name (phpinspect--class-methods class)))
(cl-defmethod phpinspect--class-get-method ((class phpinspect--class) (method-name string))
(phpinspect--class-get-method class (phpinspect-intern-name method-name)))
(cl-defmethod phpinspect--class-get-static-method ((class phpinspect--class) (method-name (head phpinspect-name))) (cl-defmethod phpinspect--class-get-static-method ((class phpinspect--class) (method-name (head phpinspect-name)))
(gethash method-name (phpinspect--class-static-methods class))) (gethash method-name (phpinspect--class-static-methods class)))
(cl-defmethod phpinspect--class-get-static-method ((class phpinspect--class) (method-name string))
(phpinspect--class-get-static-method class (phpinspect-intern-name method-name)))
(cl-defmethod phpinspect--class-get-variable (cl-defmethod phpinspect--class-get-variable
((class phpinspect--class) (variable-name string)) ((class phpinspect--class) (variable-name string))
(catch 'found (catch 'found

@ -224,7 +224,8 @@ Returns list of `phpinspect--completion'."
(let* ((buffer (phpinspect-completion-query-buffer query)) (let* ((buffer (phpinspect-completion-query-buffer query))
(point (phpinspect-completion-query-point query)) (point (phpinspect-completion-query-point query))
(buffer-map (phpinspect-buffer-parse-map buffer)) (buffer-map (phpinspect-buffer-parse-map buffer))
(rctx (phpinspect-get-resolvecontext buffer-map point)) (rctx (phpinspect-get-resolvecontext
(phpinspect-buffer-project buffer) buffer-map point))
(completion-list (phpinspect--make-completion-list))) (completion-list (phpinspect--make-completion-list)))
(phpinspect-buffer-update-project-index buffer) (phpinspect-buffer-update-project-index buffer)

@ -128,20 +128,14 @@ be implemented for return values of `phpinspect-eld-strategy-execute'")
(phpinspect-list-p (phpinspect-list-p
(car (last (phpinspect--resolvecontext-subject rctx))))))) (car (last (phpinspect--resolvecontext-subject rctx)))))))
(cl-defmethod phpinspect-eld-strategy-execute (defun phpinspect--determine-function-call-statement (rctx eld-query enclosing-token)
((_strat phpinspect-eld-function-args) (q phpinspect-eldoc-query) (rctx phpinspect--resolvecontext)) (let (statement left-sibling)
(phpinspect--log "Executing `phpinspect-eld-function-args' strategy")
(let* ((enclosing-token (car (phpinspect--resolvecontext-enclosing-metadata
rctx)))
(left-sibling )
(statement )
match-result static arg-list arg-pos)
(cond (cond
;; Subject is a statement ;; Subject is a statement
((and (phpinspect-list-p (car (last (phpinspect--resolvecontext-subject rctx)))) ((and (phpinspect-list-p (car (last (phpinspect--resolvecontext-subject rctx))))
enclosing-token) enclosing-token)
(setq left-sibling (phpinspect-meta-find-child-before-recursively (setq left-sibling (phpinspect-meta-find-child-before-recursively
enclosing-token (phpinspect-eldoc-query-point q)))) enclosing-token (phpinspect-eldoc-query-point eld-query))))
;; Subject is inside an argument list ;; Subject is inside an argument list
((and enclosing-token ((and enclosing-token
(phpinspect-list-p (phpinspect-meta-token enclosing-token))) (phpinspect-list-p (phpinspect-meta-token enclosing-token)))
@ -160,6 +154,15 @@ be implemented for return values of `phpinspect-eld-strategy-execute'")
(phpinspect--log "Eldoc statement is: %s" (mapcar #'phpinspect-meta-token statement)) (phpinspect--log "Eldoc statement is: %s" (mapcar #'phpinspect-meta-token statement))
(phpinspect--log "Enclosing token was: %s" (phpinspect-meta-token enclosing-token)) (phpinspect--log "Enclosing token was: %s" (phpinspect-meta-token enclosing-token))
statement))
(cl-defmethod phpinspect-eld-strategy-execute
((_strat phpinspect-eld-function-args) (q phpinspect-eldoc-query) (rctx phpinspect--resolvecontext))
(phpinspect--log "Executing `phpinspect-eld-function-args' strategy")
(let* ((enclosing-token (car (phpinspect--resolvecontext-enclosing-metadata
rctx)))
(statement (phpinspect--determine-function-call-statement rctx q enclosing-token))
match-result static arg-list arg-pos)
(when enclosing-token (when enclosing-token
(cond (cond
@ -167,7 +170,6 @@ be implemented for return values of `phpinspect-eld-strategy-execute'")
((setq match-result (phpinspect--match-sequence (last statement 2) ((setq match-result (phpinspect--match-sequence (last statement 2)
:f (phpinspect-meta-wrap-token-pred #'phpinspect-attrib-p) :f (phpinspect-meta-wrap-token-pred #'phpinspect-attrib-p)
:f (phpinspect-meta-wrap-token-pred #'phpinspect-list-p))) :f (phpinspect-meta-wrap-token-pred #'phpinspect-list-p)))
(phpinspect--log "Eldoc context is a method call")
(setq arg-list (car (last match-result)) (setq arg-list (car (last match-result))
static (phpinspect-static-attrib-p (phpinspect-meta-token (car match-result))) static (phpinspect-static-attrib-p (phpinspect-meta-token (car match-result)))
@ -184,18 +186,14 @@ be implemented for return values of `phpinspect-eld-strategy-execute'")
(setf (phpinspect--resolvecontext-subject rctx) (setf (phpinspect--resolvecontext-subject rctx)
(mapcar #'phpinspect-meta-token (butlast statement 2))) (mapcar #'phpinspect-meta-token (butlast statement 2)))
(let* ((type-of-previous-statement
(when-let* ((type-of-previous-statement
(phpinspect-resolve-type-from-context rctx)) (phpinspect-resolve-type-from-context rctx))
(method-name-sym (phpinspect-intern-name (cadadr (phpinspect-meta-token (car match-result))))) (method-name (cadadr (phpinspect-meta-token (car match-result))))
(class (phpinspect-project-get-class-extra-or-create (class (phpinspect-rctx-get-or-create-cached-project-class
(phpinspect--resolvecontext-project rctx) rctx type-of-previous-statement 'no-enqueue))
type-of-previous-statement
'no-enqueue))
(method (if static (method (if static
(phpinspect--class-get-static-method class method-name-sym) (phpinspect--class-get-static-method class method-name)
(phpinspect--class-get-method class method-name-sym)))) (phpinspect--class-get-method class method-name))))
(when method (when method
(phpinspect-make-function-doc :fn method :arg-pos arg-pos)))) (phpinspect-make-function-doc :fn method :arg-pos arg-pos))))
@ -268,7 +266,7 @@ also `phpinspect-eldoc-query-execute'.")
(let* ((buffer (phpinspect-eldoc-query-buffer query)) (let* ((buffer (phpinspect-eldoc-query-buffer query))
(point (phpinspect-eldoc-query-point query)) (point (phpinspect-eldoc-query-point query))
(buffer-map (phpinspect-buffer-parse-map buffer)) (buffer-map (phpinspect-buffer-parse-map buffer))
(rctx (phpinspect-get-resolvecontext buffer-map point)) (rctx (phpinspect-get-resolvecontext (phpinspect-buffer-project buffer) buffer-map point))
responses) responses)
(phpinspect-buffer-update-project-index buffer) (phpinspect-buffer-update-project-index buffer)
(dolist (strategy phpinspect-eldoc-strategies) (dolist (strategy phpinspect-eldoc-strategies)
@ -276,6 +274,7 @@ also `phpinspect-eldoc-query-execute'.")
(when (phpinspect-eld-strategy-supports strategy query rctx) (when (phpinspect-eld-strategy-supports strategy query rctx)
(phpinspect--log "Found matching eldoc strategy. Executing...") (phpinspect--log "Found matching eldoc strategy. Executing...")
(push (phpinspect-eld-strategy-execute strategy query rctx) responses)))) (push (phpinspect-eld-strategy-execute strategy query rctx) responses))))
(remove nil responses))) (remove nil responses)))
(defun phpinspect-eldoc-function () (defun phpinspect-eldoc-function ()

@ -138,10 +138,11 @@ function (think \"new\" statements, return types etc.)."
;; @return annotation. When dealing with a collection, we want to store the ;; @return annotation. When dealing with a collection, we want to store the
;; type of its members. ;; type of its members.
(when type (when-let* ((return-annotation-type
(let* ((return-annotation-type
(cadadr (seq-find #'phpinspect-return-annotation-p comment-before)))) (cadadr (seq-find #'phpinspect-return-annotation-p comment-before))))
(phpinspect--apply-annotation-type return-annotation-type type type-resolver))) (if type
(phpinspect--apply-annotation-type return-annotation-type type type-resolver)
(setq type (funcall type-resolver (phpinspect--make-type :name return-annotation-type)))))
(when add-used-types (when add-used-types
(let ((used-types (phpinspect--find-used-types-in-tokens (let ((used-types (phpinspect--find-used-types-in-tokens

@ -141,57 +141,43 @@ Destructively removes tokens from the end of ASSIGNMENT-TOKENS."
(pop statement)) (pop statement))
statement) statement)
;; FIXME: the use of this function and similar ones should be replaced with code (defsubst phpinspect-get-cached-project-class (rctx class-fqn)
;; that uses locally injected project objects in stead of retrieving the project (phpinspect-project-get-class-or-extra (phpinspect--resolvecontext-project rctx) class-fqn))
;; object through global variables.
(defsubst phpinspect-get-cached-project-class (project-root class-fqn) (defun phpinspect-get-cached-project-class-methods (rctx class-fqn &optional static)
(when project-root (phpinspect--log "Getting cached project class methods for %s"
(phpinspect-project-get-class-or-extra class-fqn)
(phpinspect--cache-get-project-create (phpinspect--get-or-create-global-cache) (let ((class (phpinspect-rctx-get-or-create-cached-project-class rctx class-fqn)))
project-root)
class-fqn)))
(defun phpinspect-get-cached-project-class-methods (project-root class-fqn &optional static)
(phpinspect--log "Getting cached project class methods for %s (%s)"
project-root class-fqn)
(when project-root
(let ((class (phpinspect-get-or-create-cached-project-class
project-root
class-fqn)))
(when class (when class
(phpinspect--log "Retrieved class index, starting method collection %s (%s)" (phpinspect--log "Retrieved class index, starting method collection for %s"
project-root class-fqn) class-fqn)
(if static (if static
(phpinspect--class-get-static-method-list class) (phpinspect--class-get-static-method-list class)
(phpinspect--class-get-method-list class)))))) (phpinspect--class-get-method-list class)))))
(defsubst phpinspect-get-cached-project-class-method-type (defsubst phpinspect-get-cached-project-class-method-type (rctx class-fqn method-name)
(project-root class-fqn method-name) (let* ((class (phpinspect-rctx-get-or-create-cached-project-class rctx class-fqn))
(when project-root
(let* ((class (phpinspect-get-or-create-cached-project-class project-root class-fqn))
(method)) (method))
(when class (when class
(setq method (setq method
(phpinspect--class-get-method class (phpinspect-intern-name method-name))) (phpinspect--class-get-method class (phpinspect-intern-name method-name)))
(when method (when method
(phpinspect--function-return-type method)))))) (phpinspect--function-return-type method)))))
(defsubst phpinspect-get-cached-project-class-variable-type (defsubst phpinspect-get-cached-project-class-variable-type
(project-root class-fqn variable-name) (rctx class-fqn variable-name)
(phpinspect--log "Getting cached project class variable type for %s (%s::%s)" (phpinspect--log "Getting cached project class variable type %s::%s"
project-root class-fqn variable-name) class-fqn variable-name)
(when project-root
(let ((found-variable (let ((found-variable
(phpinspect--class-get-variable (phpinspect--class-get-variable
(phpinspect-get-or-create-cached-project-class project-root class-fqn) (phpinspect-rctx-get-or-create-cached-project-class rctx class-fqn)
variable-name))) variable-name)))
(when found-variable (when found-variable
(phpinspect--variable-type found-variable))))) (phpinspect--variable-type found-variable))))
(defsubst phpinspect-get-cached-project-class-static-method-type (defsubst phpinspect-get-cached-project-class-static-method-type
(project-root class-fqn method-name) (rctx class-fqn method-name)
(when project-root (let* ((class (phpinspect-rctx-get-or-create-cached-project-class rctx class-fqn))
(let* ((class (phpinspect-get-or-create-cached-project-class project-root class-fqn))
(method)) (method))
(when class (when class
(setq method (setq method
@ -199,7 +185,7 @@ Destructively removes tokens from the end of ASSIGNMENT-TOKENS."
class class
(phpinspect-intern-name method-name))) (phpinspect-intern-name method-name)))
(when method (when method
(phpinspect--function-return-type method)))))) (phpinspect--function-return-type method)))))
(defun phpinspect-get-derived-statement-type-in-block (defun phpinspect-get-derived-statement-type-in-block
(resolvecontext statement php-block type-resolver &optional function-arg-list assignments) (resolvecontext statement php-block type-resolver &optional function-arg-list assignments)
@ -265,16 +251,14 @@ $variable = $variable->method();"
(setq previous-attribute-type (setq previous-attribute-type
(or (or
(phpinspect-get-cached-project-class-method-type (phpinspect-get-cached-project-class-method-type
(phpinspect--resolvecontext-project-root resolvecontext
resolvecontext)
(funcall type-resolver previous-attribute-type) (funcall type-resolver previous-attribute-type)
(cadr attribute-word)) (cadr attribute-word))
previous-attribute-type))) previous-attribute-type)))
(setq previous-attribute-type (setq previous-attribute-type
(or (or
(phpinspect-get-cached-project-class-variable-type (phpinspect-get-cached-project-class-variable-type
(phpinspect--resolvecontext-project-root resolvecontext
resolvecontext)
(funcall type-resolver previous-attribute-type) (funcall type-resolver previous-attribute-type)
(cadr attribute-word)) (cadr attribute-word))
previous-attribute-type)))))) previous-attribute-type))))))
@ -290,8 +274,7 @@ $variable = $variable->method();"
(setq previous-attribute-type (setq previous-attribute-type
(or (or
(phpinspect-get-cached-project-class-static-method-type (phpinspect-get-cached-project-class-static-method-type
(phpinspect--resolvecontext-project-root resolvecontext
resolvecontext)
(funcall type-resolver previous-attribute-type) (funcall type-resolver previous-attribute-type)
(cadr attribute-word)) (cadr attribute-word))
previous-attribute-type))))))) previous-attribute-type)))))))

@ -55,10 +55,10 @@
:type phpinspect--token :type phpinspect--token
:documentation :documentation
"The statement we're trying to resolve the type of.") "The statement we're trying to resolve the type of.")
(project-root nil (project nil
:type string :type phpinspect-project
:documentation :documentation
"The root directory of the project we're resolving types for.") "The project we're resolving types for.")
(enclosing-metadata nil (enclosing-metadata nil
:type list :type list
:documentation :documentation
@ -127,7 +127,7 @@ it would no longer be valid for the new enclosing tokens."
(reverse token)))) (reverse token))))
(cl-defmethod phpinspect-get-resolvecontext (cl-defmethod phpinspect-get-resolvecontext
((bmap phpinspect-bmap) (point integer)) ((project phpinspect-project) (bmap phpinspect-bmap) (point integer))
"Construct resolvecontext for BMAP, orienting around POINT." "Construct resolvecontext for BMAP, orienting around POINT."
(let* ((enclosing-tokens) (let* ((enclosing-tokens)
;; When there are no enclosing tokens, point is probably at the absolute ;; When there are no enclosing tokens, point is probably at the absolute
@ -184,14 +184,9 @@ it would no longer be valid for the new enclosing tokens."
:subject (phpinspect--get-last-statement-in-token subject-token) :subject (phpinspect--get-last-statement-in-token subject-token)
:enclosing-tokens (nreverse (mapcar #'phpinspect-meta-token enclosing-tokens)) :enclosing-tokens (nreverse (mapcar #'phpinspect-meta-token enclosing-tokens))
:enclosing-metadata (nreverse enclosing-tokens) :enclosing-metadata (nreverse enclosing-tokens)
:project-root (phpinspect-current-project-root)))) :project project)))
(defun phpinspect--resolvecontext-project (rctx) (defun phpinspect--get-resolvecontext (project token &optional resolvecontext)
(phpinspect--cache-get-project-create
(phpinspect--get-or-create-global-cache)
(phpinspect--resolvecontext-project-root rctx)))
(defun phpinspect--get-resolvecontext (token &optional resolvecontext)
"Find the deepest nested incomplete token in TOKEN. "Find the deepest nested incomplete token in TOKEN.
If RESOLVECONTEXT is nil, it is created. Returns RESOLVECONTEXT If RESOLVECONTEXT is nil, it is created. Returns RESOLVECONTEXT
of type `phpinspect--resolvecontext' containing the last of type `phpinspect--resolvecontext' containing the last
@ -199,7 +194,7 @@ statement of the innermost incomplete token as subject
accompanied by all of its enclosing tokens." accompanied by all of its enclosing tokens."
(unless resolvecontext (unless resolvecontext
(setq resolvecontext (phpinspect--make-resolvecontext (setq resolvecontext (phpinspect--make-resolvecontext
:project-root (phpinspect-current-project-root)))) :project project)))
(let ((last-token (car (last token))) (let ((last-token (car (last token)))
(last-encountered-token (car (last-encountered-token (car
@ -213,13 +208,18 @@ accompanied by all of its enclosing tokens."
(phpinspect--resolvecontext-push-enclosing-token resolvecontext token)) (phpinspect--resolvecontext-push-enclosing-token resolvecontext token))
(if (phpinspect-incomplete-token-p last-token) (if (phpinspect-incomplete-token-p last-token)
(phpinspect--get-resolvecontext last-token resolvecontext) (phpinspect--get-resolvecontext project last-token resolvecontext)
;; else ;; else
(setf (phpinspect--resolvecontext-subject resolvecontext) (setf (phpinspect--resolvecontext-subject resolvecontext)
(phpinspect--get-last-statement-in-token token)) (phpinspect--get-last-statement-in-token token))
resolvecontext))) resolvecontext)))
(defun phpinspect-rctx-get-or-create-cached-project-class (rctx class-fqn &optional no-enqueue)
(cl-assert (phpinspect--resolvecontext-p rctx))
(let ((project (phpinspect--resolvecontext-project rctx)))
(phpinspect-project-get-class-extra-or-create project class-fqn no-enqueue)))
(defun phpinspect--make-type-resolver-for-resolvecontext (defun phpinspect--make-type-resolver-for-resolvecontext
(resolvecontext) (resolvecontext)
(let ((namespace-or-root (let ((namespace-or-root

@ -75,34 +75,27 @@
variable-list))) variable-list)))
(defun phpinspect-get-cached-project-class-methods (project-root class-fqn &optional static) (defun phpinspect-get-cached-project-class-methods (rctx class-fqn &optional static)
(phpinspect--log "Getting cached project class methods for %s (%s)" (phpinspect--log "Getting cached project class methods for %s" class-fqn)
project-root class-fqn) (let ((class (phpinspect-rctx-get-or-create-cached-project-class rctx class-fqn 'no-enqueue)))
(when project-root
(let ((class (phpinspect-get-or-create-cached-project-class
project-root
class-fqn 'no-enqueue)))
(phpinspect--log (if class (phpinspect--log (if class
"Retrieved class index, starting method collection %s (%s)" "Retrieved class index, starting method collection %s"
"No class index found in %s for %s") "No class index found for %s")
project-root class-fqn) class-fqn)
(when class (when class
(if static (if static
(phpinspect--class-get-static-method-list class) (phpinspect--class-get-static-method-list class)
(phpinspect--class-get-method-list class)))))) (phpinspect--class-get-method-list class)))))
(defun phpinspect--get-methods-for-class (defun phpinspect--get-methods-for-class
(resolvecontext class &optional static) (resolvecontext class &optional static)
"Find all known cached methods for CLASS." "Find all known cached methods for CLASS."
(or (phpinspect-get-cached-project-class-methods (or (phpinspect-get-cached-project-class-methods resolvecontext class static)
(phpinspect--resolvecontext-project-root resolvecontext)
class static)
(progn (phpinspect--log "Failed to find methods for class %s :(" class) nil))) (progn (phpinspect--log "Failed to find methods for class %s :(" class) nil)))
(defun phpinspect--get-variables-for-class (class-name &optional static) (defun phpinspect--get-variables-for-class (rctx class-name &optional static)
(let ((class (phpinspect-get-or-create-cached-project-class (let ((class (phpinspect-rctx-get-or-create-cached-project-class
(phpinspect-current-project-root) rctx class-name 'no-enqueue)))
class-name 'no-enqueue)))
(when class (when class
(if static (if static
(append (phpinspect--class-get-static-variables class) (phpinspect--class-get-constants class)) (append (phpinspect--class-get-static-variables class) (phpinspect--class-get-constants class))
@ -149,8 +142,7 @@ static variables and static methods."
(let ((type (funcall type-resolver statement-type))) (let ((type (funcall type-resolver statement-type)))
(when-let ((result (when-let ((result
(append (phpinspect--get-variables-for-class (append (phpinspect--get-variables-for-class
type resolvecontext type static)
static)
(funcall method-lister type)))) (funcall method-lister type))))
(phpinspect--log "Returning attributes %s" result) (phpinspect--log "Returning attributes %s" result)
result)))))) result))))))

@ -57,13 +57,6 @@
(inline-quote (inline-quote
(funcall phpinspect-type-filepath-function ,fqn))) (funcall phpinspect-type-filepath-function ,fqn)))
(defsubst phpinspect-cache-project-class (project-root indexed-class)
(when project-root
(phpinspect-project-add-class
(phpinspect--cache-get-project-create (phpinspect--get-or-create-global-cache)
project-root)
indexed-class)))
(defun phpinspect-parse-string-to-bmap (string) (defun phpinspect-parse-string-to-bmap (string)
(with-temp-buffer (with-temp-buffer
(insert string) (insert string)

@ -10,6 +10,12 @@
(phpinspect-ensure-worker) (phpinspect-ensure-worker)
(phpinspect-purge-cache) (phpinspect-purge-cache)
(defun phpinspect--make-dummy-project ()
(phpinspect--make-project
:fs (phpinspect-make-virtual-fs)
:autoload (phpinspect-make-autoloader)
:worker 'nil-worker))
(defvar phpinspect-test-directory (defvar phpinspect-test-directory
(file-name-directory (macroexp-file-name)) (file-name-directory (macroexp-file-name))
"Directory that phpinspect tests reside in.") "Directory that phpinspect tests reside in.")

@ -34,8 +34,8 @@
(let* ((code "class Foo { function a(\\Thing $baz) { $foo = new \\DateTime(); $bar = $foo; Whatever comes after don't matter.") (let* ((code "class Foo { function a(\\Thing $baz) { $foo = new \\DateTime(); $bar = $foo; Whatever comes after don't matter.")
(bmap (phpinspect-parse-string-to-bmap code)) (bmap (phpinspect-parse-string-to-bmap code))
(tokens (phpinspect-parse-string "class Foo { function a(\\Thing $baz) { $foo = new \\DateTime(); $bar = $foo;")) (tokens (phpinspect-parse-string "class Foo { function a(\\Thing $baz) { $foo = new \\DateTime(); $bar = $foo;"))
(context (phpinspect--get-resolvecontext tokens)) (context (phpinspect--get-resolvecontext (phpinspect-current-project) tokens))
(bmap-context (phpinspect-get-resolvecontext bmap (- (length code) 36))) (bmap-context (phpinspect-get-resolvecontext (phpinspect--make-dummy-project) bmap (- (length code) 36)))
(project-root "could never be a real project root") (project-root "could never be a real project root")
(phpinspect-project-root-function (phpinspect-project-root-function
(lambda (&rest _ignored) project-root)) (lambda (&rest _ignored) project-root))
@ -65,7 +65,7 @@
(ert-deftest phpinspect-get-pattern-type-in-block () (ert-deftest phpinspect-get-pattern-type-in-block ()
(let* ((code "class Foo { function a(\\Thing $baz) { $foo = new \\DateTime(); $this->potato = $foo;") (let* ((code "class Foo { function a(\\Thing $baz) { $foo = new \\DateTime(); $this->potato = $foo;")
(bmap (phpinspect-parse-string-to-bmap "class Foo { function a(\\Thing $baz) { $foo = new \\DateTime(); $this->potato = $foo;")) (bmap (phpinspect-parse-string-to-bmap "class Foo { function a(\\Thing $baz) { $foo = new \\DateTime(); $this->potato = $foo;"))
(context (phpinspect-get-resolvecontext bmap (length code))) (context (phpinspect-get-resolvecontext (phpinspect--make-dummy-project) bmap (length code)))
(project-root "could never be a real project root") (project-root "could never be a real project root")
(phpinspect-project-root-function (phpinspect-project-root-function
(lambda (&rest _ignored) project-root)) (lambda (&rest _ignored) project-root))
@ -90,8 +90,8 @@
(code2 "class Foo { function a(\\Thing $baz) { $foo = []; $foo[] = $baz; $bar = $foo[0]; $bork = [$foo[0]]; $bark = $bork[0]; $borknest = [$bork]; $barknest = $borknest[0][0]") (code2 "class Foo { function a(\\Thing $baz) { $foo = []; $foo[] = $baz; $bar = $foo[0]; $bork = [$foo[0]]; $bark = $bork[0]; $borknest = [$bork]; $barknest = $borknest[0][0]")
(bmap (phpinspect-parse-string-to-bmap code1)) (bmap (phpinspect-parse-string-to-bmap code1))
(tokens (phpinspect-parse-string code2)) (tokens (phpinspect-parse-string code2))
(context1 (phpinspect-get-resolvecontext bmap (- (length code1) 4))) (context1 (phpinspect-get-resolvecontext (phpinspect--make-dummy-project) bmap (- (length code1) 4)))
(context2 (phpinspect--get-resolvecontext tokens))) (context2 (phpinspect--get-resolvecontext (phpinspect-current-project) tokens)))
(should (equal (phpinspect--resolvecontext-subject context1) (should (equal (phpinspect--resolvecontext-subject context1)
(phpinspect--resolvecontext-subject context2))) (phpinspect--resolvecontext-subject context2)))
@ -101,7 +101,7 @@
(ert-deftest phpinspect-get-variable-type-in-block-array-foreach () (ert-deftest phpinspect-get-variable-type-in-block-array-foreach ()
(let* ((code "class Foo { function a(\\Thing $baz) { $foo = []; $foo[] = $baz; foreach ($foo as $bar) {$bar->") (let* ((code "class Foo { function a(\\Thing $baz) { $foo = []; $foo[] = $baz; foreach ($foo as $bar) {$bar->")
(bmap (phpinspect-parse-string-to-bmap code)) (bmap (phpinspect-parse-string-to-bmap code))
(context (phpinspect-get-resolvecontext bmap (length code))) (context (phpinspect-get-resolvecontext (phpinspect--make-dummy-project) bmap (length code)))
(project-root "could never be a real project root") (project-root "could never be a real project root")
(phpinspect-project-root-function (phpinspect-project-root-function
(lambda (&rest _ignored) project-root)) (lambda (&rest _ignored) project-root))
@ -123,32 +123,6 @@
(should (phpinspect--type= (phpinspect--make-type :name "\\Thing") (should (phpinspect--type= (phpinspect--make-type :name "\\Thing")
result))))) result)))))
(ert-deftest phpinspect-get-variable-type-in-block-nested-array ()
(let* ((code "class Foo { function a(\\Thing $baz) { $foo = [[$baz]]; foreach ($foo[0] as $bar) {$bar->")
(bmap (phpinspect-parse-string-to-bmap code))
(context (phpinspect-get-resolvecontext bmap (length code)))
(project-root "could never be a real project root")
(phpinspect-project-root-function
(lambda (&rest _ignored) project-root))
(project (phpinspect--make-project
:fs (phpinspect-make-virtual-fs)
:root project-root
:worker (phpinspect-make-worker))))
(puthash project-root project (phpinspect--cache-projects phpinspect-cache))
(let* ((function-token (seq-find #'phpinspect-function-p
(phpinspect--resolvecontext-enclosing-tokens context)))
(result (phpinspect-get-variable-type-in-block
context "bar"
(phpinspect-function-block function-token)
(phpinspect--make-type-resolver-for-resolvecontext context)
(phpinspect-function-argument-list function-token))))
(should (phpinspect--type= (phpinspect--make-type :name "\\Thing")
result)))))
(ert-deftest phpinspect--find-assignment-ctxs-in-token () (ert-deftest phpinspect--find-assignment-ctxs-in-token ()
(let* ((tokens (cadr (let* ((tokens (cadr
(phpinspect-parse-string "{ $foo = ['nr 1']; $bar = $nr2; if (true === ($foo = $nr3)) { $foo = $nr4; $notfoo = $nr5; if ([] === ($foo = [ $nr6 ])){ $foo = [ $nr7 ];}}}"))) (phpinspect-parse-string "{ $foo = ['nr 1']; $bar = $nr2; if (true === ($foo = $nr3)) { $foo = $nr4; $notfoo = $nr5; if ([] === ($foo = [ $nr6 ])){ $foo = [ $nr7 ];}}}")))
@ -241,17 +215,12 @@ class FlufferUpper
$this->upFluff = $upFluff; $this->upFluff = $upFluff;
} }
}")) }"))
(phpinspect-project-root-function (lambda () "phpinspect-test")) (project (phpinspect--make-dummy-project))
(context (phpinspect-get-resolvecontext bmap 310))) (context (phpinspect-get-resolvecontext project bmap 310)))
(setf (phpinspect--resolvecontext-project-root context)
"phpinspect-test")
(phpinspect-purge-cache) (phpinspect-purge-cache)
(dolist (tree (list token-tree fluffer vendor-fluff vendor-fluffer-upper)) (dolist (tree (list token-tree fluffer vendor-fluff vendor-fluffer-upper))
(phpinspect-cache-project-class (phpinspect-project-add-index project (phpinspect--index-tokens tree)))
"phpinspect-test"
(cdar (alist-get 'classes (cdr (phpinspect--index-tokens tree))))))
(should (phpinspect--type= (should (phpinspect--type=
(phpinspect--make-type :name "\\Vendor\\FluffLib\\DoubleFluffer") (phpinspect--make-type :name "\\Vendor\\FluffLib\\DoubleFluffer")
@ -260,7 +229,7 @@ class FlufferUpper
(phpinspect--make-type-resolver-for-resolvecontext (phpinspect--make-type-resolver-for-resolvecontext
context)))) context))))
(setq context (phpinspect-get-resolvecontext bmap 405)) (setq context (phpinspect-get-resolvecontext project bmap 405))
(should (phpinspect--type= (should (phpinspect--type=
(phpinspect--make-type :name "\\Vendor\\FluffLib\\FlufferUpper") (phpinspect--make-type :name "\\Vendor\\FluffLib\\FlufferUpper")
(phpinspect-resolve-type-from-context (phpinspect-resolve-type-from-context
@ -268,7 +237,6 @@ class FlufferUpper
(phpinspect--make-type-resolver-for-resolvecontext (phpinspect--make-type-resolver-for-resolvecontext
context)))))) context))))))
(ert-deftest phpinspect-resolve-type-from-context-static-method () (ert-deftest phpinspect-resolve-type-from-context-static-method ()
(with-temp-buffer (with-temp-buffer
(insert " (insert "
@ -289,11 +257,11 @@ class Thing
(index (phpinspect--index-tokens tokens)) (index (phpinspect--index-tokens tokens))
(phpinspect-project-root-function (lambda () "phpinspect-test")) (phpinspect-project-root-function (lambda () "phpinspect-test"))
(phpinspect-eldoc-word-width 100) (phpinspect-eldoc-word-width 100)
(context (phpinspect-get-resolvecontext bmap (point)))) (project (phpinspect--make-dummy-project))
(context (phpinspect-get-resolvecontext project bmap (point))))
(phpinspect-purge-cache) (phpinspect-purge-cache)
(phpinspect-cache-project-class (phpinspect-project-add-index project index)
(phpinspect-current-project-root)
(cdar (alist-get 'classes (cdr index))))
(should (phpinspect--type= (phpinspect--make-type :name "\\Thing") (should (phpinspect--type= (phpinspect--make-type :name "\\Thing")
(phpinspect-resolve-type-from-context (phpinspect-resolve-type-from-context
@ -320,13 +288,11 @@ class Thing
:bmap bmap) :bmap bmap)
(phpinspect-parse-current-buffer))) (phpinspect-parse-current-buffer)))
(index (phpinspect--index-tokens tokens)) (index (phpinspect--index-tokens tokens))
(phpinspect-project-root-function (lambda () "phpinspect-test"))
(phpinspect-eldoc-word-width 100) (phpinspect-eldoc-word-width 100)
(context (phpinspect-get-resolvecontext bmap (point)))) (project (phpinspect--make-dummy-project))
(context (phpinspect-get-resolvecontext project bmap (point))))
(phpinspect-purge-cache) (phpinspect-purge-cache)
(phpinspect-cache-project-class (phpinspect-project-add-index project index)
(phpinspect-current-project-root)
(cdar (alist-get 'classes (cdr index))))
(should (phpinspect--type= (phpinspect--make-type :name "\\Thing") (should (phpinspect--type= (phpinspect--make-type :name "\\Thing")
(phpinspect-resolve-type-from-context (phpinspect-resolve-type-from-context

@ -28,6 +28,10 @@
(require 'phpinspect-fs) (require 'phpinspect-fs)
(require 'phpinspect-autoload) (require 'phpinspect-autoload)
(require 'phpinspect-resolvecontext) (require 'phpinspect-resolvecontext)
(require 'phpinspect-test-env
(expand-file-name "phpinspect-test-env.el"
(file-name-directory (macroexp-file-name))))
(ert-deftest phpinspect-filename-to-typename () (ert-deftest phpinspect-filename-to-typename ()
(should (eq (phpinspect-intern-name "\\Foo\\Bar") (phpinspect-filename-to-typename "src/" "src/Foo////////Bar.php"))) (should (eq (phpinspect-intern-name "\\Foo\\Bar") (phpinspect-filename-to-typename "src/" "src/Foo////////Bar.php")))

@ -2,13 +2,16 @@
(require 'phpinspect) (require 'phpinspect)
(require 'phpinspect-eldoc) (require 'phpinspect-eldoc)
(require 'phpinspect-test-env
(expand-file-name "phpinspect-test-env.el"
(file-name-directory (macroexp-file-name))))
(ert-deftest phpinspect-eld-method-call () (ert-deftest phpinspect-eld-method-call ()
(setq phpinspect-load-stubs nil)
(with-temp-buffer (with-temp-buffer
(phpinspect-ensure-worker)
(phpinspect-purge-cache) (phpinspect-purge-cache)
(let* ((php-code " (let* ((php-code "<?php
class Thing class Thing
{ {
@ -20,17 +23,14 @@ class Thing
function doStuff() function doStuff()
{ {
$this->getThis(new \\DateTime(), bla)") $this->getThis(new \\DateTime(), bla)")
(tokens (phpinspect-parse-string php-code))
(index (phpinspect--index-tokens tokens))
(phpinspect-project-root-function (lambda () "phpinspect-test")) (phpinspect-project-root-function (lambda () "phpinspect-test"))
(phpinspect-eldoc-word-width 100) (phpinspect-eldoc-word-width 100)
(buffer (phpinspect-make-buffer :buffer (current-buffer))) (project (phpinspect--make-project :autoload (phpinspect-make-autoloader) :worker 'nil-worker))
(buffer (phpinspect-make-buffer :buffer (current-buffer) :-project project))
second-arg-pos inside-nested-list-pos first-arg-pos) second-arg-pos inside-nested-list-pos first-arg-pos)
(phpinspect-cache-project-class (setq-local phpinspect-current-buffer buffer)
(phpinspect-current-project-root)
(cdar (alist-get 'classes (cdr index))))
(insert php-code) (insert php-code)
(backward-char) (backward-char)
(setq second-arg-pos (point)) (setq second-arg-pos (point))
(backward-char 6) (backward-char 6)
@ -38,22 +38,47 @@ class Thing
(backward-char 8) (backward-char 8)
(setq first-arg-pos (point)) (setq first-arg-pos (point))
(phpinspect-buffer-reindex buffer)
;; Strategy should not trigger inside constructor/function arguments
(let ((query (phpinspect-make-eldoc-query :point inside-nested-list-pos :buffer buffer))
(strat (phpinspect-make-eld-function-args))
(rctx (phpinspect-get-resolvecontext project (phpinspect-buffer-parse-map buffer) inside-nested-list-pos)))
(should-not (phpinspect-eld-strategy-execute strat query rctx)))
(dolist (expected (list (cons second-arg-pos 1) (cons first-arg-pos 0)))
;; Test strat separately to ensure it is not erroneous
(let ((query (phpinspect-make-eldoc-query :point (car expected) :buffer buffer))
(strat (phpinspect-make-eld-function-args))
(rctx (phpinspect-get-resolvecontext project (phpinspect-buffer-parse-map buffer) (car expected))))
;; Subject is correct
(should (phpinspect-word-p (car (phpinspect--resolvecontext-subject rctx))))
;; Enclosing token is correct
(should (phpinspect-list-p (car (phpinspect--resolvecontext-enclosing-tokens rctx))))
;; Statement is correctly determined
(should (equal (cdr (phpinspect-parse-string "$this->getThis(new \\DateTime(), bla)"))
(mapcar #'phpinspect-meta-token
(phpinspect--determine-function-call-statement
rctx query (car (phpinspect--resolvecontext-enclosing-metadata
rctx))))))
;; Strategy correctly signals support
(should (phpinspect-eld-strategy-supports strat query rctx))
;; Strategy correctly returns result
(should (phpinspect-eld-strategy-execute strat query rctx)))
;; Test query execution
(let ((result (seq-find #'phpinspect-function-doc-p (let ((result (seq-find #'phpinspect-function-doc-p
(phpinspect-eldoc-query-execute (phpinspect-eldoc-query-execute
(phpinspect-make-eldoc-query :point second-arg-pos :buffer buffer))))) (phpinspect-make-eldoc-query :point (car expected) :buffer buffer)))))
(should (phpinspect-function-doc-p result))
(should (= 1 (phpinspect-function-doc-arg-pos result)))
(should (string= "getThis" (phpinspect--function-name (phpinspect-function-doc-fn result))))
(setq result (phpinspect-eldoc-query-execute
(phpinspect-make-eldoc-query :point inside-nested-list-pos :buffer buffer)))
(should-not result)
(setq result (car (phpinspect-eldoc-query-execute
(phpinspect-make-eldoc-query :point first-arg-pos :buffer buffer))))
(should (phpinspect-function-doc-p result)) (should (phpinspect-function-doc-p result))
(should (= 0 (phpinspect-function-doc-arg-pos result))) (should (= (cdr expected) (phpinspect-function-doc-arg-pos result)))
(should (string= "getThis" (phpinspect--function-name (phpinspect-function-doc-fn result)))))))) (should (string= "getThis" (phpinspect--function-name (phpinspect-function-doc-fn result)))))))))
(ert-deftest phpinspect-eldoc-function-for-object-method () (ert-deftest phpinspect-eldoc-function-for-object-method ()
(phpinspect-purge-cache) (phpinspect-purge-cache)
@ -70,18 +95,16 @@ class Thing
$this->getThis(new \\DateTime(), bla)") $this->getThis(new \\DateTime(), bla)")
(tokens (phpinspect-parse-string php-code)) (tokens (phpinspect-parse-string php-code))
(index (phpinspect--index-tokens tokens)) (index (phpinspect--index-tokens tokens))
(phpinspect-project-root-function (lambda () "phpinspect-test")) (project (phpinspect--make-dummy-project))
(phpinspect-eldoc-word-width 100)) (phpinspect-eldoc-word-width 100))
(phpinspect-cache-project-class (phpinspect-project-add-index project index)
(phpinspect-current-project-root)
(cdar (alist-get 'classes (cdr index))))
(should (string= "getThis: ($moment DateTime, $thing Thing, $other): Thing" (should (string= "getThis: ($moment DateTime, $thing Thing, $other): Thing"
(with-temp-buffer (with-temp-buffer
(insert php-code) (insert php-code)
(backward-char) (backward-char)
(setq-local phpinspect-current-buffer (setq-local phpinspect-current-buffer
(phpinspect-make-buffer :buffer (current-buffer))) (phpinspect-make-buffer :buffer (current-buffer) :-project project))
(phpinspect-buffer-parse phpinspect-current-buffer) (phpinspect-buffer-parse phpinspect-current-buffer)
(phpinspect-eldoc-function)))))) (phpinspect-eldoc-function))))))
@ -100,11 +123,9 @@ class Thing
self::doThing(") self::doThing(")
(tokens (phpinspect-parse-string php-code)) (tokens (phpinspect-parse-string php-code))
(index (phpinspect--index-tokens tokens)) (index (phpinspect--index-tokens tokens))
(phpinspect-project-root-function (lambda () "phpinspect-test")) (project (phpinspect--make-dummy-project))
(phpinspect-eldoc-word-width 100)) (phpinspect-eldoc-word-width 100))
(phpinspect-cache-project-class (phpinspect-project-add-index project index)
(phpinspect-current-project-root)
(cdar (alist-get 'classes (cdr index))))
(should (string= "doThing: ($moment DateTime, $thing Thing, $other): Thing" (should (string= "doThing: ($moment DateTime, $thing Thing, $other): Thing"
(with-temp-buffer (with-temp-buffer

@ -356,3 +356,31 @@ class AccountStatisticsController {
(should (phpinspect--type= relation-type (phpinspect--variable-type relation))) (should (phpinspect--type= relation-type (phpinspect--variable-type relation)))
(should (phpinspect--variable-type static-relation)) (should (phpinspect--variable-type static-relation))
(should (phpinspect--type= relation-type (phpinspect--variable-type static-relation))))))))) (should (phpinspect--type= relation-type (phpinspect--variable-type static-relation)))))))))
(ert-deftest phpinspect-index-return-type-annotation-for-method ()
(with-temp-buffer
(let ((project (phpinspect--make-project :autoload (phpinspect-make-autoloader))))
(insert "<?php
declare(strict_types=1);
namespace App\\Controller\\Api\\V1;
class AccountStatisticsController {
/**
* @return $this
*/
public function doStuff()
{
}
}")
(phpinspect-project-add-index project (phpinspect-index-current-buffer))
(let ((class (phpinspect-project-get-class
project
(phpinspect--make-type
:name "\\App\\Controller\\Api\\V1\\AccountStatisticsController"
:fully-qualified t))))
(should class)
(should (phpinspect--class-get-method class "doStuff"))))))

@ -6,20 +6,28 @@
(expand-file-name "phpinspect-test-env.el" (expand-file-name "phpinspect-test-env.el"
(file-name-directory (macroexp-file-name)))) (file-name-directory (macroexp-file-name))))
(ert-deftest phpinspect-get-variable-type-in-block-nested-array ()
(let* ((code "class Foo { function a(\\Thing $baz) { $foo = [[$baz]]; foreach ($foo[0] as $bar) {$bar->")
(bmap (phpinspect-parse-string-to-bmap code))
(project (phpinspect--make-dummy-project))
(context (phpinspect-get-resolvecontext project bmap (length code))))
(let* ((function-token (seq-find #'phpinspect-function-p
(phpinspect--resolvecontext-enclosing-tokens context)))
(result (phpinspect-get-variable-type-in-block
context "bar"
(phpinspect-function-block function-token)
(phpinspect--make-type-resolver-for-resolvecontext context)
(phpinspect-function-argument-list function-token))))
(should (phpinspect--type= (phpinspect--make-type :name "\\Thing")
result)))))
(ert-deftest phpinspect-get-variable-type-in-block-array-access () (ert-deftest phpinspect-get-variable-type-in-block-array-access ()
(let* ((code "class Foo { function a(\\Thing $baz) { $foo = []; $foo[] = $baz; $bar = $foo[0]; $bork = [$foo[0]]; $bark = $bork[0]; $borknest = [$bork]; $barknest = $borknest[0][0]; }}") (let* ((code "class Foo { function a(\\Thing $baz) { $foo = []; $foo[] = $baz; $bar = $foo[0]; $bork = [$foo[0]]; $bark = $bork[0]; $borknest = [$bork]; $barknest = $borknest[0][0]; }}")
(tokens (phpinspect-parse-string-to-bmap code)) (bmap (phpinspect-parse-string-to-bmap code))
(context (phpinspect-get-resolvecontext tokens (- (length code) 4))) (project (phpinspect--make-dummy-project))
(project-root "could never be a real project root") (context (phpinspect-get-resolvecontext project bmap (length code))))
(phpinspect-project-root-function
(lambda (&rest _ignored) project-root))
(project (phpinspect--make-project
:fs (phpinspect-make-virtual-fs)
:root project-root
:worker (phpinspect-make-worker))))
(puthash project-root project (phpinspect--cache-projects phpinspect-cache))
(let* ((function-token (car (phpinspect--resolvecontext-enclosing-tokens context))) (let* ((function-token (car (phpinspect--resolvecontext-enclosing-tokens context)))
(result1 (phpinspect-get-variable-type-in-block (result1 (phpinspect-get-variable-type-in-block
@ -41,16 +49,8 @@
(ert-deftest phpinspect-get-variable-type-in-block-array-foreach-self-referential () (ert-deftest phpinspect-get-variable-type-in-block-array-foreach-self-referential ()
(let* ((code "class Foo { function a(\\Thing $baz) { $foo = []; $foo[] = $baz; foreach ($foo as $bar) {$bar = $bar; $bar->") (let* ((code "class Foo { function a(\\Thing $baz) { $foo = []; $foo[] = $baz; foreach ($foo as $bar) {$bar = $bar; $bar->")
(bmap (phpinspect-parse-string-to-bmap code)) (bmap (phpinspect-parse-string-to-bmap code))
(context (phpinspect-get-resolvecontext bmap (length code))) (project (phpinspect--make-dummy-project))
(project-root "could never be a real project root") (context (phpinspect-get-resolvecontext project bmap (length code))))
(phpinspect-project-root-function
(lambda (&rest _ignored) project-root))
(project (phpinspect--make-project
:fs (phpinspect-make-virtual-fs)
:root project-root
:worker (phpinspect-make-worker))))
(puthash project-root project (phpinspect--cache-projects phpinspect-cache))
(let* ((function-token (seq-find #'phpinspect-function-p (let* ((function-token (seq-find #'phpinspect-function-p
(phpinspect--resolvecontext-enclosing-tokens context))) (phpinspect--resolvecontext-enclosing-tokens context)))

@ -28,7 +28,7 @@ class TestClass {
(phpinspect-parse-string code)) (phpinspect-parse-string code))
(setq bmap (phpinspect-pctx-bmap ctx)) (setq bmap (phpinspect-pctx-bmap ctx))
(let ((rctx (phpinspect-get-resolvecontext bmap 317))) (let ((rctx (phpinspect-get-resolvecontext (phpinspect--make-dummy-project) bmap 317)))
(should (phpinspect--resolvecontext-subject rctx)) (should (phpinspect--resolvecontext-subject rctx))
(should (phpinspect--resolvecontext-enclosing-tokens rctx))))) (should (phpinspect--resolvecontext-enclosing-tokens rctx)))))
@ -37,7 +37,7 @@ class TestClass {
(with-temp-buffer (with-temp-buffer
(insert-file-contents (expand-file-name "IncompleteClass.php" phpinspect-test-php-file-directory)) (insert-file-contents (expand-file-name "IncompleteClass.php" phpinspect-test-php-file-directory))
(let* ((bmap (phpinspect-parse-string-to-bmap (buffer-string))) (let* ((bmap (phpinspect-parse-string-to-bmap (buffer-string)))
(resolvecontext (phpinspect-get-resolvecontext bmap (point-max))) (resolvecontext (phpinspect-get-resolvecontext (phpinspect--make-dummy-project) bmap (point-max)))
(type-resolver (phpinspect--make-type-resolver-for-resolvecontext (type-resolver (phpinspect--make-type-resolver-for-resolvecontext
resolvecontext))) resolvecontext)))
@ -65,7 +65,7 @@ class TestClass {
(with-temp-buffer (with-temp-buffer
(insert-file-contents (concat phpinspect-test-php-file-directory "/IncompleteClassBlockedNamespace.php")) (insert-file-contents (concat phpinspect-test-php-file-directory "/IncompleteClassBlockedNamespace.php"))
(let* ((bmap (phpinspect-parse-string-to-bmap (buffer-string))) (let* ((bmap (phpinspect-parse-string-to-bmap (buffer-string)))
(resolvecontext (phpinspect-get-resolvecontext bmap (point-max))) (resolvecontext (phpinspect-get-resolvecontext (phpinspect--make-dummy-project) bmap (point-max)))
(type-resolver (phpinspect--make-type-resolver-for-resolvecontext (type-resolver (phpinspect--make-type-resolver-for-resolvecontext
resolvecontext))) resolvecontext)))
@ -87,6 +87,7 @@ class TestClass {
(ert-deftest phpinspect-type-resolver-for-resolvecontext-multiple-namespace-blocks () (ert-deftest phpinspect-type-resolver-for-resolvecontext-multiple-namespace-blocks ()
(let* ((resolvecontext (phpinspect--get-resolvecontext (let* ((resolvecontext (phpinspect--get-resolvecontext
(phpinspect-current-project)
(phpinspect-test-read-fixture-data (phpinspect-test-read-fixture-data
"IncompleteClassMultipleNamespaces"))) "IncompleteClassMultipleNamespaces")))
(type-resolver (phpinspect--make-type-resolver-for-resolvecontext (type-resolver (phpinspect--make-type-resolver-for-resolvecontext

Loading…
Cancel
Save