Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lisp/php-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,11 @@ for \\[find-tag] (which see)."
("\\_<\\(?:implements\\|extends\\)\\_>" . 'php-class-declaration-spec)
;; Namespace declaration
("\\_<namespace\\_>" . 'php-namespace-declaration)
;; import constant statement
(,(rx symbol-start (group "use" (+ (syntax whitespace)) "const")
(+ (syntax whitespace)))
(1 'php-import-declaration)
(,(rx (group (+ (or (syntax word) (syntax symbol) "\\" "{" "}")))) nil nil (1 'php-constant-assign)))
;; import statement
("\\_<use\\_>" . 'php-import-declaration)
;; Class modifiers (abstract, final)
Expand Down Expand Up @@ -1478,6 +1483,11 @@ for \\[find-tag] (which see)."
;; is usually overkill.
`(
("\\<\\(@\\)" 1 'php-errorcontrol-op)
;; import function statement
(,(rx symbol-start (group "use" (+ (syntax whitespace)) "function")
(+ (syntax whitespace)))
(1 'php-import-declaration)
(,(rx (group (+ (or (syntax word) (syntax symbol) "\\" "{" "}")))) nil nil (1 'php-function-name t)))
;; Highlight function calls
("\\(\\_<\\(?:\\sw\\|\\s_\\)+?\\_>\\)\\s-*(" 1 'php-function-call)
;; Highlight all upper-cased symbols as constant
Expand Down
8 changes: 8 additions & 0 deletions tests/lang/import/import-constant.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
namespace Foo;

use const Foo\BAR;
use const Foo\{BUZ, BUZBUZ};
use const PHP_VERSION;

const FOO = 'bar';
31 changes: 31 additions & 0 deletions tests/lang/import/import-constant.php.faces
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
;; -*- mode: emacs-lisp -*-
(("<?php" . php-php-tag)
("\n")
("namespace" . php-namespace-declaration)
(" ")
("Foo" . font-lock-type-face)
(";\n\n")
("use const" . php-import-declaration)
(" ")
("Foo\\" . php-constant-assign)
("BAR" . font-lock-type-face)
(";\n")
("use const" . php-import-declaration)
(" ")
("Foo" . font-lock-type-face)
("\\{BUZ" . php-constant-assign)
(", ")
("BUZBUZ}" . php-constant-assign)
(";\n")
("use const" . php-import-declaration)
(" ")
("PHP_VERSION" . font-lock-type-face)
(";\n\n")
("const" . php-keyword)
(" ")
("FOO" . font-lock-type-face)
(" ")
("=" . php-assignment-op)
(" ")
("'bar'" . php-string)
(";\n"))
7 changes: 7 additions & 0 deletions tests/lang/import/import-function.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
namespace Foo;

use function var_dump;
use function is_array, is_string, is_dir;
use function Safe\json_encode;
use function Safe\{file_get_contents, json_decode};
37 changes: 37 additions & 0 deletions tests/lang/import/import-function.php.faces
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
;; -*- mode: emacs-lisp -*-
(("<?php" . php-php-tag)
("\n")
("namespace" . php-namespace-declaration)
(" ")
("Foo" . font-lock-type-face)
(";\n\n")
("use" . php-import-declaration)
(" ")
("function" . php-keyword)
(" ")
("var_dump" . php-function-name)
(";\n")
("use" . php-import-declaration)
(" ")
("function" . php-keyword)
(" ")
("is_array" . php-function-name)
(", ")
("is_string" . php-function-name)
(", ")
("is_dir" . php-function-name)
(";\n")
("use" . php-import-declaration)
(" ")
("function" . php-keyword)
(" ")
("Safe\\json_encode" . php-function-name)
(";\n")
("use" . php-import-declaration)
(" ")
("function" . php-keyword)
(" ")
("Safe\\{file_get_contents" . php-function-name)
(", ")
("json_decode}" . php-function-name)
(";\n"))
2 changes: 2 additions & 0 deletions tests/php-mode-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,8 @@ Meant for `php-mode-test-issue-503'."
(with-php-mode-test ("lang/doc-comment/return-type.php" :faces t))
(with-php-mode-test ("lang/function/calls.php" :faces t))
(with-php-mode-test ("lang/function/closure.php" :indent t :magic t :faces t))
(with-php-mode-test ("lang/import/import-constant.php" :faces t))
(with-php-mode-test ("lang/import/import-function.php" :faces t))
(with-php-mode-test ("lang/try-cactch/multiple.php" :faces t))
(with-php-mode-test ("lang/types/cast.php" :faces t))
(with-php-mode-test ("lang/types/function.php" :faces t))
Expand Down