From f961f2488bcf8addaa6de50aa55dac357a17f916 Mon Sep 17 00:00:00 2001 From: fabacino Date: Thu, 24 Jan 2019 23:48:55 +0100 Subject: [PATCH] Fix highlighting of static method calls If a static method call has the same name as a keyword, it is highlighted as a keyword instead of a method call. Github-Issue: #498 --- php-mode-test.el | 5 ++++ php-mode.el | 6 ++++- tests/constants.php.faces | 3 ++- tests/identifiers.php.faces | 9 ++++--- tests/issue-201.php.faces | 9 ++++--- tests/static-method-calls.php | 13 ++++++++++ tests/static-method-calls.php.faces | 39 +++++++++++++++++++++++++++++ 7 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 tests/static-method-calls.php create mode 100644 tests/static-method-calls.php.faces diff --git a/php-mode-test.el b/php-mode-test.el index 5d37d8c5..57ebd89c 100644 --- a/php-mode-test.el +++ b/php-mode-test.el @@ -928,6 +928,11 @@ style from Drupal." "Test highlighting of type hints and return types." (with-php-mode-test ("type-hints.php" :faces t))) +(ert-deftest php-mode-test-static-method-calls () + "Test highlighting of static method calls which are named the same +as a keyword." + (with-php-mode-test ("static-method-calls.php" :faces t))) + (ert-deftest php-mode-debug-test () "Test running php-mode-debug and php-mode-debug--buffer." (with-temp-buffer diff --git a/php-mode.el b/php-mode.el index 8e72fe30..cdc668fb 100644 --- a/php-mode.el +++ b/php-mode.el @@ -16,7 +16,7 @@ (defconst php-mode-version-number "1.21.0" "PHP Mode version number.") -(defconst php-mode-modified "2019-02-28" +(defconst php-mode-modified "2019-03-04" "PHP Mode build date.") ;; This file is free software; you can redistribute it and/or @@ -1688,6 +1688,10 @@ a completion list." ;; Support the ::class constant in PHP5.6 ("\\sw+\\(::\\)\\(class\\)\\b" (1 'php-paamayim-nekudotayim) (2 'php-constant)) + ;; Highlight static method calls as such. This is necessary for method + ;; names which are identical to keywords to be highlighted correctly. + ("\\sw+::\\(\\sw+\\)(" 1 'php-static-method-call) + ;; While c-opt-cpp-* highlights the