branch: externals/phpinspect
commit 8cfc48348fac24f05be8ed82675b1f21f51dfbde
Author: Hugo Thunnissen <[email protected]>
Commit: Hugo Thunnissen <[email protected]>
Run relint and fix detected regexp issues
---
phpinspect-autoload.el | 2 +-
phpinspect-buffer.el | 4 ++--
phpinspect-imports.el | 2 +-
test/phpinspect-test.el | 2 +-
test/test-autoload.el | 6 ++++++
test/util/generate-test-data.el | 2 +-
6 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/phpinspect-autoload.el b/phpinspect-autoload.el
index f22e504a0e..f3e78eca3f 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 972b5236ef..33a35cde97 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 848c548c64..77fb890e51 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 5501af202f..74435e30d1 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 a9b9bf4046..7f51a22020 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 26d3593a8c..2211fcac97 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)))