Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove php-mode-extra-constants variable and functions #605

Merged
merged 1 commit into from
Dec 30, 2019
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
8 changes: 0 additions & 8 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,6 @@ PHPモードはデフォルトでは`php-enable-default-coding-style`関数で

このスタイルはSymfony2のコードベースで広く利用されていますが、慣習についての文書で明示的に言及されているものではありません。

### 定数の追加

フレームワークによって一般的な定数群が定義されるならば、変数`php-extra-constants`を値をカスタマイズすることができます。これはPHPモードが追加の定数として扱う定数名の文字列のリストです。これらの定数はPHP組み込みの定数と同じ強調表示を行います。

### Web Mode定数とキーワード

もしあなたが[Web Mode]を使用しているなら、Web Modeに設定された追加のPHP定数をとキーワードを追加しようとします。

### HTMLテンプレートのサポートを無効化する

多くの開発者はPHPモードで純粋なPHPスクリプト(HTMLテンプレートを含まないもの)を編集します。HTMLとの互換レイヤーはPHPモードの歴史的な機能ですが、完全には機能していません。速度の低下や強調表示を破壊するおそれがあるなどの副作用があります。変数`php-template-compatibility`を`nil`にセットすると、HTMLとの互換性を無効化することができます。HTMLやその他のマークアップ言語のテンプレートエンジンを含むPHPスクリプトを開発する際は[Web Mode][]は優れた選択肢です。
Expand Down
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,6 @@ With this style method call chains can be formatted with indented continuation a

This style is used widely throughout Symfony2 source code even if it is not explicitly mentioned in their conventions documents.

### Extra Constants

If you commonly use a framework or library that defines a set of constants then you may wish to customize the value of `php-extra-constants`. It is a list of strings that PHP Mode will treat as additional constants, i.e. providing them the same level syntax highlighting that PHP Mode uses for built-in constants.

### Web Mode Constants and Keywords

If you use [Web Mode][] then PHP Mode will attempt to use any additional PHP constants and keywords that Web Mode allows you to define.

### Avoid HTML Template Compatibility

Many developers use PHP Mode to edit pure PHP scripts (e.g. files with only PHP and no HTML). A basic compatibility layer with HTML has historically been part of PHP Mode but it does not work perfectly and can cause some bad side effects such as slowness and incorrect font locking. Configuring the `php-template-compatibility` property with a `nil` will cancel any attempt of HTML compatibility. [Web Mode](http://web-mode.org/) is a great alternative to PHP Mode if you need to work with PHP scripts that do contain HTML and other markup.
Expand Down
32 changes: 0 additions & 32 deletions php-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -160,30 +160,6 @@ Turning this on will open it whenever `php-mode' is loaded."
:tag "PHP Mode Template Compatibility"
:type 'boolean)

(defun php-mode-extra-constants-create-regexp (kwds)
"Create regexp for the list of extra constant keywords KWDS."
(concat "[^_$]?\\<\\("
(regexp-opt
(append kwds
(when (boundp 'web-mode-extra-php-constants) web-mode-extra-php-constants)))
"\\)\\>[^_]?"))

(defun php-mode-extra-constants-set (sym value)
"Apply the list of extra constant keywords `VALUE'.

This function is called when the custom variable php-extra-constants
is updated. The web-mode-extra-constants list is appended to the list
of constants when set."
;; remove old keywords
(when (boundp 'php-extra-constants)
(font-lock-remove-keywords
'php-mode `((,(php-mode-extra-constants-create-regexp php-extra-constants) 1 'php-constant))))
;; add new keywords
(when value
(font-lock-add-keywords
'php-mode `((,(php-mode-extra-constants-create-regexp value) 1 'php-constant))))
(set sym value))

(define-obsolete-variable-alias 'php-lineup-cascaded-calls 'php-mode-lineup-cascaded-calls "1.20.0")
(defcustom php-mode-lineup-cascaded-calls nil
"Indent chained method calls to the previous line."
Expand All @@ -201,14 +177,6 @@ of constants when set."
:tag "PHP Mode Page Delimiter"
:type 'regexp)

(define-obsolete-variable-alias 'php-extra-constants 'php-mode-extra-constants "1.20.0")
(defcustom php-mode-extra-constants '()
"A list of additional strings to treat as PHP constants."
:group 'php-mode
:tag "PHP Mode Extra Constants"
:type '(repeat string)
:set 'php-mode-extra-constants-set)

(define-obsolete-variable-alias 'php-do-not-use-semantic-imenu 'php-mode-do-not-use-semantic-imenu "1.20.0")
(defcustom php-mode-do-not-use-semantic-imenu t
"Customize `imenu-create-index-function' for `php-mode'.
Expand Down
3 changes: 0 additions & 3 deletions tests/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
no_constant;
no_CONSTANT;

// Test php-extra-constants
extraconstant;

// Everything called statically should be highlighted with the constant face
// (like c++-mode)
ClassName::$test;
Expand Down
3 changes: 0 additions & 3 deletions tests/constants.php.faces
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
("IS_CONSTANT99" . php-constant)
(";\nno_constant;\nno_CONSTANT;\n\n")
("// " . font-lock-comment-delimiter-face)
("Test php-extra-constants\n" . font-lock-comment-face)
("extraconstant;\n\n")
("// " . font-lock-comment-delimiter-face)
("Everything called statically should be highlighted with the constant face\n" . font-lock-comment-face)
("// " . font-lock-comment-delimiter-face)
("(like c++-mode)\n" . font-lock-comment-face)
Expand Down
19 changes: 0 additions & 19 deletions tests/php-mode-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -370,25 +370,6 @@ style from Drupal."

(ert-deftest php-mode-test-constants ()
"Proper highlighting for constants."
(custom-set-variables '(php-extra-constants (quote ("extraconstant"))))
(with-php-mode-test ("constants.php")
(let ((variables '(
"true" "TRUE"
"false" "FALSE"
"null" "NULL"
"IS_CONSTANT"
"__IS_CONSTANT__"
"IS_CONSTANT99"
"extraconstant"
"ClassName")))
(dolist (variable variables)
(search-forward variable)
(goto-char (match-beginning 0))
(should (equal (cons variable 'php-constant)
(cons variable (get-text-property (point) 'face)))))))

;; Set default
(custom-set-variables '(php-extra-constants (quote ())))
(with-php-mode-test ("constants.php" :faces t)))

(ert-deftest php-mode-test-identifiers()
Expand Down