File tree Expand file tree Collapse file tree 7 files changed +90
-7
lines changed
Expand file tree Collapse file tree 7 files changed +90
-7
lines changed Original file line number Diff line number Diff line change 9292 " PHP Mode face used to highlight constants."
9393 :group 'php-faces )
9494
95+ (defface php-magical-constant '((t (:inherit font-lock-builtin-face )))
96+ " PHP Mode face used to highlight magical constants."
97+ :group 'php-faces )
98+
9599(defface php-$this '((t (:inherit php-constant)))
96100 " PHP Mode face used to highlight $this variables."
97101 :group 'php-faces )
Original file line number Diff line number Diff line change @@ -701,13 +701,12 @@ style from Drupal."
701701 " __IS_CONSTANT__"
702702 " IS_CONSTANT99"
703703 " extraconstant"
704- " ClassName"
705- " class;" )))
704+ " ClassName" )))
706705 (dolist (variable variables)
707706 (search-forward variable)
708707 (goto-char (match-beginning 0 ))
709- (should (eq 'php-constant
710- ( get-text-property (point ) 'face ))))))
708+ (should (equal ( cons variable 'php-constant )
709+ ( cons variable ( get-text-property (point ) 'face ) ))))))
711710
712711 ; ; Set default
713712 (custom-set-variables '(php-extra-constants (quote ())))
@@ -989,6 +988,7 @@ Meant for `php-mode-test-issue-503'."
989988 (with-php-mode-test (" lang/types/cast.php" :faces t ))
990989 (with-php-mode-test (" lang/types/function.php" :faces t ))
991990 (with-php-mode-test (" lang/types/keywords.php" :faces t ))
992- (with-php-mode-test (" lang/errorcontrol.php" :faces t )))
991+ (with-php-mode-test (" lang/errorcontrol.php" :faces t ))
992+ (with-php-mode-test (" lang/magical-constants/echo.php" :faces t )))
993993
994994; ;; php-mode-test.el ends here
Original file line number Diff line number Diff line change @@ -1409,12 +1409,13 @@ a completion list."
14091409 ; ; - when used as cast, so that (int) and (array) look the same
14101410 (" (\\ (array\\ ))" 1 font-lock-type-face )
14111411
1412+ (,(regexp-opt php-magical-constants 'symbols ) (1 'php-magical-constant ))
14121413 ; ; namespaces
14131414 (" \\ (\\ ([a-zA-Z0-9_]+\\\\\\ )+[a-zA-Z0-9_]+\\ |\\ (\\\\ [a-zA-Z0-9_]+\\ )+\\ )[^:a-zA-Z0-9_\\\\ ]" 1 'font-lock-type-face )
14141415 (" \\ (\\ ([a-zA-Z0-9_]+\\\\\\ )+[a-zA-Z0-9_]+\\ |\\ (\\\\ [a-zA-Z0-9_]+\\ )+\\ )::" 1 'php-constant )
14151416
14161417 ; ; Support the ::class constant in PHP5.6
1417- (" \\ sw+\\ (::\\ )\\ (class\\ )\\ b" (1 'php-paamayim-nekudotayim ) (2 'php-constant ))
1418+ (" \\ sw+\\ (::\\ )\\ (class\\ )\\ b" (1 'php-paamayim-nekudotayim ) (2 'php-magical- constant ))
14181419
14191420 ; ; Highlight static method calls as such. This is necessary for method
14201421 ; ; names which are identical to keywords to be highlighted correctly.
Original file line number Diff line number Diff line change @@ -78,6 +78,14 @@ You can replace \"en\" with your ISO language code."
7878 :group 'php
7979 :type 'string )
8080
81+ ; ;; PHP Keywords
82+ (defconst php-magical-constants
83+ (list " __LINE__" " __FILE__" " __FUNCTION__" " __CLASS__" " __TRAIT__" " __METHOD__" " __NAMESPACE__" )
84+ " Magical keyword that is expanded at compile time.
85+
86+ These are different from \" constants\" in strict terms.
87+ see https://www.php.net/manual/language.constants.predefined.php" )
88+
8189; ;; Utillity for locate language construction
8290(defsubst php-in-string-p ()
8391 " Return non-nil if inside a string.
Original file line number Diff line number Diff line change 3939 (" Class name resolution is a special case\n " . font-lock-comment-face )
4040 (" stdClass" . php-constant)
4141 (" ::" . php-paamayim-nekudotayim)
42- (" class" . php-constant)
42+ (" class" . php-magical- constant)
4343 (" ;\n " )
4444 (" SomeClass" . php-constant)
4545 (" ::" . php-paamayim-nekudotayim)
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ echo __LINE__ , PHP_EOL ;
4+ echo __FILE__ , PHP_EOL ;
5+ echo __FILE__ , PHP_EOL ;
6+ echo __FUNCTION__ , PHP_EOL ;
7+ echo __CLASS__ , PHP_EOL ;
8+ echo __TRAIT__ , PHP_EOL ;
9+ echo __METHOD__ , PHP_EOL ;
10+ echo __NAMESPACE__ , PHP_EOL ;
11+ echo \Directory::class, PHP_EOL ;
Original file line number Diff line number Diff line change 1+ ; ; -*- mode : emacs-lisp -*-
2+ ((" <?php" . php-php-tag)
3+ (" \n\n " )
4+ (" echo" . php-keyword)
5+ (" " )
6+ (" __LINE__" . php-magical-constant)
7+ (" , " )
8+ (" PHP_EOL" . php-constant)
9+ (" ;\n " )
10+ (" echo" . php-keyword)
11+ (" " )
12+ (" __FILE__" . php-magical-constant)
13+ (" , " )
14+ (" PHP_EOL" . php-constant)
15+ (" ;\n " )
16+ (" echo" . php-keyword)
17+ (" " )
18+ (" __FILE__" . php-magical-constant)
19+ (" , " )
20+ (" PHP_EOL" . php-constant)
21+ (" ;\n " )
22+ (" echo" . php-keyword)
23+ (" " )
24+ (" __FUNCTION__" . php-magical-constant)
25+ (" , " )
26+ (" PHP_EOL" . php-constant)
27+ (" ;\n " )
28+ (" echo" . php-keyword)
29+ (" " )
30+ (" __CLASS__" . php-magical-constant)
31+ (" , " )
32+ (" PHP_EOL" . php-constant)
33+ (" ;\n " )
34+ (" echo" . php-keyword)
35+ (" " )
36+ (" __TRAIT__" . php-magical-constant)
37+ (" , " )
38+ (" PHP_EOL" . php-constant)
39+ (" ;\n " )
40+ (" echo" . php-keyword)
41+ (" " )
42+ (" __METHOD__" . php-magical-constant)
43+ (" , " )
44+ (" PHP_EOL" . php-constant)
45+ (" ;\n " )
46+ (" echo" . php-keyword)
47+ (" " )
48+ (" __NAMESPACE__" . php-magical-constant)
49+ (" , " )
50+ (" PHP_EOL" . php-constant)
51+ (" ;\n " )
52+ (" echo" . php-keyword)
53+ (" " )
54+ (" \\ Directory" . php-constant)
55+ (" ::" . php-paamayim-nekudotayim)
56+ (" class" . php-magical-constant)
57+ (" , " )
58+ (" PHP_EOL" . php-constant)
59+ (" ;\n " ))
You can’t perform that action at this time.
0 commit comments