diff --git a/phpinspect-autoload.el b/phpinspect-autoload.el index f22e504..f3e78ec 100644 --- a/phpinspect-autoload.el +++ b/phpinspect-autoload.el @@ -102,7 +102,7 @@ bareword typenames.")) (inline-quote (phpinspect-intern-name (replace-regexp-in-string - "[\\\\]+" + "\\\\[\\]+" "\\\\" (concat "\\" (or ,prefix "") diff --git a/phpinspect-buffer.el b/phpinspect-buffer.el index 972b523..33a35cd 100644 --- a/phpinspect-buffer.el +++ b/phpinspect-buffer.el @@ -430,10 +430,10 @@ linked with." ;; Take into account "atoms" (tokens without clear delimiters like words, ;; variables and object attributes. The meaning of these tokens will change as - ;; they grow or shrink, so their ful regions need to be marked for a reparse). + ;; they grow or shrink, so their full regions need to be marked for a reparse). (save-excursion (goto-char start) - (when (looking-back "\\($|->|::\\)?[^][)(}{[:blank:]\n;'\"]+" nil t) + (when (looking-back "\\(\\$\\|->\\|::\\)?[^][)(}{[:blank:]\n;'\"]+" nil t) (setq start (- start (length (match-string 0)))) (setq pre-change-length (+ pre-change-length (length (match-string 0)))))) diff --git a/phpinspect-imports.el b/phpinspect-imports.el index 848c548..77fb890 100644 --- a/phpinspect-imports.el +++ b/phpinspect-imports.el @@ -107,7 +107,7 @@ buffer position to insert the use statement at." (t (message "No import found for type %s" typename)))))) (defun phpinspect-namespace-part-of-typename (typename) - (string-trim-right typename "\\\\?[^\\\\]+")) + (string-trim-right typename "\\\\?[^\\]+")) (defalias 'phpinspect-fix-uses-interactive #'phpinspect-fix-imports "Alias for backwards compatibility") diff --git a/test/phpinspect-test.el b/test/phpinspect-test.el index 5501af2..74435e3 100644 --- a/test/phpinspect-test.el +++ b/test/phpinspect-test.el @@ -314,7 +314,7 @@ class Thing 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")) diff --git a/test/test-autoload.el b/test/test-autoload.el index a9b9bf4..7f51a22 100644 --- a/test/test-autoload.el +++ b/test/test-autoload.el @@ -28,6 +28,12 @@ (require 'phpinspect-fs) (require 'phpinspect-autoload) +(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/somewhere/else/" "src/somewhere/else/Foo/Bar.php")))) + + (ert-deftest phpinspect-find-composer-json-files () (let* ((fs (phpinspect-make-virtual-fs)) (autoloader (phpinspect-make-autoloader diff --git a/test/util/generate-test-data.el b/test/util/generate-test-data.el index 26d3593..2211fca 100644 --- a/test/util/generate-test-data.el +++ b/test/util/generate-test-data.el @@ -8,7 +8,7 @@ buffer-file-name))) (print-length 1000) (print-level 1000)) - (dolist (file (directory-files (concat here "/../fixtures" ) t "\\.php$")) + (dolist (file (directory-files (concat here "/../fixtures" ) t "\\.php\\'")) (with-temp-buffer (insert-file-contents-literally file) (let ((result (phpinspect-parse-current-buffer)))