├── .dir-locals.el ├── .github ├── dependabot.yml └── workflows │ └── test.yml ├── .gitignore ├── .mailmap ├── AUTHORS.md ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Eask ├── LICENSE ├── Makefile ├── README.ja.md ├── README.md ├── docs └── php-align │ └── README.md ├── etc └── git │ ├── AUTHORS.md.in │ ├── AUTHORS2.md.in │ ├── commit-template.txt │ ├── former-contributors │ └── prepare-commit-msg ├── lisp ├── .editorconfig ├── php-align.el ├── php-complete.el ├── php-defs.el ├── php-face.el ├── php-flymake.el ├── php-format.el ├── php-ide-phpactor.el ├── php-ide.el ├── php-local-manual.el ├── php-mode-debug.el ├── php-mode.el ├── php-project.el └── php.el ├── script ├── README.md ├── data │ └── module_id_prefixes.php ├── extract_functions.php └── module_id_prefixes.php └── tests ├── .dir-locals.el ├── .editorconfig ├── 7.4 ├── arrow-function.php ├── arrow-function.php.faces ├── typed-property.php └── typed-property.php.faces ├── 8.0 └── attribute │ ├── class.php │ ├── class.php.faces │ ├── function.php │ ├── function.php.faces │ ├── function2.php │ └── function2.php.faces ├── 8.1 ├── enum.php ├── enum.php.faces ├── readonly.php └── readonly.php.faces ├── 8.4 ├── property-hooks.php └── property-hooks.php.faces ├── README.md ├── arrays.php ├── arrays.php.faces ├── constants.php ├── constants.php.faces ├── identifiers.php ├── identifiers.php.faces ├── indent ├── issue-227.php ├── issue-623.php ├── issue-702.php ├── issue-726.php ├── issue-774.php └── issue-793.php ├── issue-100.php ├── issue-102.php ├── issue-115.php ├── issue-124.php ├── issue-129.php ├── issue-130.php ├── issue-135.php ├── issue-136.php ├── issue-136.php.faces ├── issue-14.php ├── issue-144.php ├── issue-145.php ├── issue-16.php ├── issue-174.php ├── issue-175.php ├── issue-178.php ├── issue-18.php ├── issue-184.php ├── issue-186.php ├── issue-19.php ├── issue-197.php ├── issue-197.php.faces ├── issue-200.php ├── issue-201.php ├── issue-201.php.faces ├── issue-21.php ├── issue-211.php ├── issue-22.php ├── issue-237.php ├── issue-253.php ├── issue-259.php ├── issue-27.php ├── issue-28.php ├── issue-29.php ├── issue-305.php ├── issue-305.php.faces ├── issue-307.php ├── issue-310.php ├── issue-314.php ├── issue-333.php ├── issue-42.php ├── issue-439.php ├── issue-439.php.faces ├── issue-443.php ├── issue-443.php.27.faces ├── issue-443.php.faces ├── issue-503.php ├── issue-53.php ├── issue-66-bracket-namespace.php ├── issue-66-multi-namespace.php ├── issue-66-namespace.php ├── issue-66-use-namespace.php ├── issue-66.php ├── issue-68.php ├── issue-73.php ├── issue-83.php ├── issue-9.php ├── issue-99.php ├── lang ├── class │ ├── anonymous-class.php │ └── anonymous-class.php.faces ├── constants │ ├── const.php │ └── const.php.faces ├── doc-comment │ ├── annotation.php │ ├── annotation.php.faces │ ├── comments.php │ ├── comments.php.24.faces │ ├── comments.php.27.faces │ ├── comments.php.faces │ ├── inheritdoc.php │ ├── inheritdoc.php.faces │ ├── issue-8.php │ ├── issue-8.php.faces │ ├── return-type.php │ └── return-type.php.faces ├── errorcontrol.php ├── errorcontrol.php.faces ├── function │ ├── calls.php │ ├── calls.php.faces │ ├── closure.php │ └── closure.php.faces ├── import │ ├── import-constant.php │ ├── import-constant.php.faces │ ├── import-function.php │ └── import-function.php.faces ├── magical-constants │ ├── echo.php │ └── echo.php.faces ├── try-cactch │ ├── multiple.php │ └── multiple.php.faces └── types │ ├── cast.php │ ├── cast.php.faces │ ├── function.php │ ├── function.php.faces │ ├── keywords.php │ └── keywords.php.faces ├── language-constructs.php ├── namespace-block.php ├── php-mode-test.el ├── profiler └── large-string-interpolation.php ├── project └── 1 │ ├── .editorconfig │ ├── .hg │ ├── .projectile │ ├── .svn │ ├── composer.json │ └── src │ └── functions.php ├── static-method-calls.php ├── static-method-calls.php.faces ├── switch-statements.php ├── template.php ├── type-hints.php ├── type-hints.php.29.faces ├── type-hints.php.faces ├── variables.php └── variables.php.faces /.dir-locals.el: -------------------------------------------------------------------------------- 1 | ((emacs-lisp-mode (package-lint-main-file . "php-mode.el"))) 2 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: github-actions 4 | directory: / 5 | schedule: 6 | interval: daily 7 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | paths-ignore: 6 | - '**/*.md' 7 | - 'etc/*' 8 | workflow_dispatch: 9 | 10 | concurrency: 11 | group: ${{ github.workflow }}-${{ github.ref }} 12 | cancel-in-progress: true 13 | 14 | jobs: 15 | build: 16 | runs-on: ${{ matrix.os }} 17 | continue-on-error: ${{ matrix.experimental }} 18 | strategy: 19 | fail-fast: false 20 | matrix: 21 | os: [ubuntu-latest, macos-latest, windows-latest] 22 | emacs-version: 23 | - "27.2" 24 | - "28.2" 25 | - "29.4" 26 | - "30.1" 27 | experimental: [false] 28 | include: 29 | - os: ubuntu-latest 30 | emacs-version: snapshot 31 | experimental: true 32 | - os: macos-latest 33 | emacs-version: snapshot 34 | experimental: true 35 | - os: windows-latest 36 | emacs-version: snapshot 37 | experimental: true 38 | exclude: 39 | - os: macos-latest 40 | emacs-version: "27.2" 41 | steps: 42 | - uses: actions/setup-python@v5 43 | with: 44 | python-version: '3.11' 45 | architecture: 'x64' 46 | - uses: jcs090218/setup-emacs@master 47 | with: 48 | version: ${{ matrix.emacs-version }} 49 | - uses: emacs-eask/setup-eask@master 50 | with: 51 | version: 'snapshot' 52 | - uses: actions/checkout@v4 53 | - name: Run tests 54 | run: 'make .eask test' 55 | - name: Run tests (allow failure) 56 | run: 'make .eask test || true' 57 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.elc 2 | *~ 3 | .dir-locals-2.el 4 | /.cask/* 5 | /.eask/* 6 | /.keg/* 7 | /dist 8 | /.php-cs-fixer.cache 9 | php-mode-autoloads.el 10 | php_manual_en.json 11 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | Elis Axelsson Elis 2 | David Arroyo Menéndez David Arroyo7 3 | Jen-Chieh Shen JenChieh 4 | Joe Wreschnig Joe 5 | Jon Dufresne Jon Dufrense 6 | Syohei YOSHIDA Shohei YOSHIDA 7 | Syohei YOSHIDA Syohei Yoshida 8 | -------------------------------------------------------------------------------- /AUTHORS.md: -------------------------------------------------------------------------------- 1 | # Authors 2 | 3 | ## Author 4 | 5 | - [Turadg Aleahmad](https://github.com/turadg) (Original Author) 6 | - [Daniel Hackney](https://github.com/haxney) (Integrated with CC Mode) 7 | 8 | ## Maintainer 9 | 10 | - [USAMI Kenta (@zonuexe)](https://github.com/zonuexe) 11 | 12 | ## Retired Maintainers 13 | 14 | - [Aaron S. Hawley](https://users.ninthfloor.org/~ashawley/) 15 | - [Lennart Borgman](https://www.emacswiki.org/emacs/LennartBorgman) 16 | - [Eric James Michael Ritz](https://github.com/ejmr) 17 | - [Syohei Yoshida](https://syohex.org/) 18 | 19 | ## Contributors 20 | 21 | All contributors listed below improved PHP Mode as well. 22 | 23 | Names Sorted Alphabetically: 24 | 25 | - Aaron S. Hawley 26 | - Alan Pearce 27 | - Alex Figl-Brick 28 | - Andreas Röhler 29 | - Andrei Chițu 30 | - Antoine Brand 31 | - Bence Kalmar 32 | - Bill Lovett 33 | - Bob W. Hogg 34 | - Boris Folgmann 35 | - Carl Groner 36 | - Charlie McMackin 37 | - Chris Morris 38 | - Christian Albrecht 39 | - Christian Weiske 40 | - Craig Andrews 41 | - Daniel Hackney 42 | - David Arroyo Menéndez 43 | - David House 44 | - David Maus 45 | - Demis Balbach 46 | - Dias Badekas 47 | - Doug Marcey 48 | - Elis Axelsson 49 | - Emanuele Tomasi 50 | - Engelke Eschner 51 | - Eric James Michael Ritz 52 | - Eric Mc Sween 53 | - François-Xavier Bois 54 | - Fred Yankowski 55 | - Gerrit Riessen 56 | - Giacomo Tesio 57 | - Gregory Stark 58 | - Gu Weigang 59 | - Herbert Jones 60 | - Hernawan Fa'iz Abdillah 61 | - Ian Eure 62 | - Jacek Wysocki 63 | - Jakub Jankiewicz 64 | - James Laver 65 | - Jeff Beeman 66 | - Jen-Chieh Shen 67 | - Joe Wreschnig 68 | - John Keller 69 | - Jon Dufresne 70 | - Joris Steyn 71 | - Juanjo 72 | - Kevin Blake 73 | - Lennart Borgman 74 | - Marcin Antczak 75 | - Mark A. Hershberger 76 | - Mathias Meyer 77 | - Maël Nison 78 | - Michael Dwyer 79 | - Michael Stolovitzsky 80 | - Michele Bini 81 | - Nate Eagleson 82 | - Nicholas D Steeves 83 | - Nils Rennebarth 84 | - Norio Suzuki 85 | - Olaf The Viking 86 | - Peter Oliver 87 | - Phil Sainty 88 | - Philippe Ivaldi 89 | - Piotr Kwiecinski 90 | - Rex McMaster 91 | - Roland 92 | - Rosenfeld 93 | - Ryan 94 | - Sammartino 95 | - Sean Champ 96 | - Sebastian Wiesner 97 | - Serghei Iakovlev 98 | - Shohei YOSHIDA 99 | - Stefan Monnier 100 | - Stig Bakken 101 | - Syohei YOSHIDA 102 | - Tim Landscheidt 103 | - Tom Willemsen 104 | - Torsten Martinsen 105 | - U-CPT\deb 106 | - USAMI Kenta 107 | - Valentin Funk 108 | - Ville Skytta 109 | - Vinai Kopp 110 | - fabacino 111 | - fallchildren 112 | - flack 113 | - l3msh0 114 | - phil-s 115 | - ppercot 116 | - take 117 | - takeokunn 118 | - tangxinfa 119 | - tetsujin 120 | - tijsmallaerts 121 | - zapad 122 | - 顾伟刚 123 | 124 | A chronological list of pre-2019 contributors can be found at [wiki/Authors](https://github.com/emacs-php/php-mode/wiki/Authors). 125 | 126 | Contributors since 2011, where this project was hosted, can also be found at [graphs/contributors](https://github.com/emacs-php/php-mode/graphs/contributors), except for accounts that have been withdrawn from GitHub. 127 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | This project accepts contributions in various languages. Not only development but also documentation and translation are important contributions. 4 | 5 | * [English](#english) `[en]` 6 | * [简体中文](#simplified-chinese) `[zh-Hans]` 7 | * [繁体中文](#traditional-chinese) `[zh-Hant]` 8 | * [日本語](#japanese) `[ja]` 9 | 10 | ---------- 11 | 12 | ## English 13 | 14 | ### Setup (en) 15 | 16 | [Eask] is required to build the package. You need to install it using node.js and npm, or [download a prebuilt executable][eask-releases]. See [Eask Introduction][eask-introduction] and [Install Eask][eask-install] for more details. 17 | 18 | You can run the tests using the following command: 19 | 20 | ```sh 21 | make test 22 | ``` 23 | 24 | ### Guideline (en) 25 | 26 | All contributions to PHP Mode are welcome. But please try to do the following when submitting enhancements or bug fixes: 27 | 28 | 1. Open `php-mode-test.el` and run all the tests to make sure they pass as expected. You can also check this by running `make test` from the terminal. 29 | 2. Please commit with a concise and clear message that effectively achieves a simple purpose. 30 | 3. Submit a pull request here on GitHub. 31 | 32 | If you are fixing a bug related to a GitHub issue, then first of all, thank you for helping to improve PHP Mode. Second, there is a `tests/` directory that contains PHP scripts for issues (though not all). Please consider adding a test script to that directory that documents the expected behavior and provides code that allows others to see if that behavior works properly. Then create a unit test within `php-mode-test.el' using [ERT]. Try to follow the format of the existing tests. 33 | 34 | ### Regression test for Face (en) 35 | 36 | In this project, the regression test of [Font Lock] is realized by creating a `foo.php.face` file to be paired with the` foo.php` file. Add the `: faces t` option to the` with-php-mode-test` argument to activate this test. 37 | 38 | Please refer to [How to generate face file] for how to generate `.face` file required for this test. 39 | 40 | ---------- 41 | 42 | ## Simplified Chinese 43 | 44 | I am seeking a contribution on Chinese. We also lack a README written in Simplified Chinese. 45 | 46 | ### Guideline (zh-Hans) 47 | 48 | Please contribute. 49 | 50 | ---------- 51 | 52 | ## Traditional Chinese 53 | 54 | I am seeking a contribution on Chinese. We also lack a README written in Traditional Chinese. 55 | 56 | ### Guideline (zh-Hant) 57 | 58 | Please contribute. 59 | 60 | ---------- 61 | 62 | ## Japanese 63 | 64 | ### Setup (ja) 65 | 66 | パッケージをビルドするにはEaskが必要です。node.jsとnpmからインストールするか、ビルド済み実行ファイルをダウンロードする必要があります。Easkの詳細は[Eask Introduction][eask-introduction]と[Install Eask][eask-install]をお読みください。 67 | 68 | 以下のコマンドでテストを実行できます。 69 | 70 | ```sh 71 | make test 72 | ``` 73 | 74 | ### Guideline (ja) 75 | 76 | **Emacs PHP Mode**はどなたからの貢献も歓迎です。改善やバグ修正を行う前に以下の手順を行ってください。 77 | 78 | 1. `php-mode-test.el`を開いて[すべてのテストを実行][run all of the tests]し、期待通りにテストを通過することを確認します。端末から`make test`で確認することもできます。 79 | 2. 簡潔でシンプルな目的を達成するための、明示的なメッセージでコミットしてください。 80 | 3. GitHubからプルリクエストを送信してください。 81 | 82 | **GitHubのissueに関連するバグを修正する場合**: PHPモードの改善に協力いただきありがとうございます! `tests/`ディレクトリには(すべてではありませんが)issueに関連のあるPHPスクリプトが配置されています。そこに予期される挙動と他のひとが動作を適切に確認できるテストコードを追加することを検討してください。そして`php-mode-test.el`に既存のテストと同じように[ERT]を使ったテストコードを追加してください。 83 | 84 | ### Regression test for Face (ja) 85 | 86 | このプロジェクトでは `foo.php` ファイルに対応した `foo.php.face` ファイルを作成することで[Font Lock]の回帰テストを実現しています。このテストを有効化するには`with-php-mode-test`の引数に`:faces t`オプションを追加してください。 87 | 88 | このテストに必要な`.face`ファイルの生成方法は[How to generate face file]を参考にしてください。 89 | 90 | [run all of the tests]: http://www.gnu.org/software/emacs/manual/html_node/ert/Running-Tests-Interactively.html#Running-Tests-Interactively 91 | [Eask]: https://emacs-eask.github.io/ 92 | [eask-introduction]: https://emacs-eask.github.io/Getting-Started/Introduction/ 93 | [eask-install]: https://emacs-eask.github.io/Getting-Started/Install-Eask/ 94 | [eask-releases]: https://github.com/emacs-eask/cli/releases 95 | [ERT]: http://www.gnu.org/software/emacs/manual/html_node/ert/index.html 96 | [Font Lock]: https://www.gnu.org/software/emacs/manual/html_node/elisp/Font-Lock-Mode.html 97 | [How to generate face file]: https://github.com/emacs-php/php-mode/issues/509#issuecomment-491528968 98 | -------------------------------------------------------------------------------- /Eask: -------------------------------------------------------------------------------- 1 | ;; -*- mode: eask; lexical-binding: t -*- 2 | 3 | (package "php-mode" 4 | "1.26.1" 5 | "Major mode for editing PHP code") 6 | 7 | (website-url "https://github.com/emacs-php/php-mode") 8 | (keywords "languages" "php") 9 | 10 | (package-file "lisp/php-mode.el") 11 | (files 12 | "lisp/php.el" 13 | "lisp/php-complete.el" 14 | "lisp/php-defs.el" 15 | "lisp/php-face.el" 16 | "lisp/php-format.el" 17 | "lisp/php-project.el" 18 | "lisp/php-local-manual.el" 19 | "lisp/php-ide-phpactor.el" 20 | "lisp/php-ide.el" 21 | "lisp/php-mode-debug.el") 22 | 23 | (script "test" "echo \"Error: no test specified\" && exit 1") 24 | 25 | (source 'melpa) 26 | (source 'gnu) 27 | 28 | (depends-on "emacs" "26.1") 29 | 30 | (development 31 | (depends-on "phpactor") 32 | (depends-on "pkg-info") 33 | (depends-on "projectile") 34 | (depends-on "smart-jump") 35 | (depends-on "shut-up") 36 | ) 37 | 38 | (setq network-security-level 'low) ; see https://github.com/jcs090218/setup-emacs-windows/issues/156#issuecomment-932956432 39 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | EMACS ?= emacs 2 | CASK ?= cask 3 | EASK ?= eask 4 | 5 | compile: 6 | $(EASK) compile 7 | 8 | all: autoloads $(ELCS) authors 9 | 10 | authors: AUTHORS.md 11 | 12 | .PHONY: AUTHORS.md 13 | AUTHORS.md: etc/git/AUTHORS.md.in .mailmap 14 | @printf "Generating AUTHORS.md file..." 15 | @test -d .git \ 16 | && (cat $< > $@ \ 17 | && git log --pretty=format:'- %aN' \ 18 | | cat etc/git/former-contributors - \ 19 | | grep -v dependabot \ 20 | | LANG=C sort -u >> $@ \ 21 | && cat etc/git/AUTHORS2.md.in >> $@ \ 22 | && printf "FINISHED\n" ; ) \ 23 | || printf "FAILED (non-fatal)\n" 24 | 25 | autoloads: 26 | $(EASK) generate autoloads 27 | 28 | .eask: Eask 29 | $(EASK) install 30 | 31 | clean: 32 | $(EASK) clean all 33 | 34 | # Perform any operations that will be useful for developers 35 | # who contribute to PHP Mode. 36 | dev: 37 | cp etc/git/prepare-commit-msg .git/hooks/prepare-commit-msg 38 | chmod u+x .git/hooks/prepare-commit-msg 39 | 40 | # Runs all unit tests from php-mode-test.el and shows the results. The 41 | # script will exit with the status code zero if all tests pass. If any 42 | # test fails the script exits with a non-zero status and shows 43 | # diagnostics on standard output. 44 | # 45 | # You can use this script with git-bisect. See the documentation at 46 | # 47 | # http://git-scm.com/book/en/Git-Tools-Debugging-with-Git 48 | # 49 | # for an example of using a script like this with the 'git bisect run' 50 | # command. 51 | test: clean all 52 | $(EASK) test ert ./tests/php-mode-test.el 53 | 54 | .PHONY: all authors autoloads clean test 55 | -------------------------------------------------------------------------------- /README.ja.md: -------------------------------------------------------------------------------- 1 |
2 |

Emacs PHP Mode

3 | 4 | [![Emacs: 30.0](https://img.shields.io/badge/Emacs-30.0-blue.svg)](https://www.gnu.org/software/emacs/) 5 | [![lang: PHP 8.4](https://img.shields.io/badge/lang-PHP%208.4-brightgreen.svg)](https://www.php.net/releases/8.4/) 6 | [![Build Status](https://github.com/emacs-php/php-mode/workflows/CI/badge.svg)](https://github.com/emacs-php/php-mode/actions) 7 | [![GPL v3](https://img.shields.io/badge/license-GPL_v3-green.svg)][gpl-v3]
8 | [![NonGNU ELPA][nongnu-elpa-badge]][nongnu-elpa] 9 | [![melpa badge][melpa-badge]][melpa-link] 10 | 11 | A powerful and flexible Emacs major mode for editing PHP scripts 12 | 13 | [English](README.md)   |   日本語 14 | 15 |
16 | 17 | [GitHubプロジェクト][php-mode]にissueを作成してバグ報告や機能リクエストを送ってください。 18 | 19 | > [!NOTE] 20 | > [最新版][releases]のPHP ModeはEmacs 30をサポートしています。
アップグレードに伴うトラブルは[Discussions][discussions-emacs30]に気軽に書き込んでください。 21 | 22 | > [!WARNING] 23 | > Emacsをアップグレードした直後に初めてPHPファイルを開いたときに、CC Mode関連のエラーが発生する可能性があります。これは以前のバージョンのEmacsでバイトコンパイルされたPHP Modeがディスクにキャッシュされているために起こるので、PHP Modeの再インストールによって解決します。 24 | > 25 | > **`M-x php-mode-debug-reinstall`** または **`M-x package-reinstall php-mode`** コマンドをお試しください。 26 | 27 | [releases]: https://github.com/emacs-php/php-mode/releases 28 | [discussions-emacs30]: https://github.com/emacs-php/php-mode/discussions/798 29 | 30 | ## インストール 31 | 32 | **PHP ModeはEmacs 27.1以降で動作します**。対応バージョンの詳細は[Supported Version]をお読みください。Emacs 28以降では単に以下のコマンドを実行するだけでインストールできます。 33 | 34 | ``` 35 | M-x package-install php-mode 36 | ``` 37 | 38 | [`package-archives`にMELPAを追加][melpa-getting-started]することで、Web上の多くのパッケージでEmacsを強化できます。 39 | 40 | パッケージマネージャへの依存なしでインストールしたい場合は、Lispファイルを直接配置する伝統的な方法も可能です。詳しくは[Manual installation][wiki-manual-installation]をお読みください。 41 | 42 | ## 設定 43 | 44 | ### 個人設定 45 | 46 | .emacsファイル(`~/.emacs.d/init.el`)にPHPモードの設定を記述できます。 47 | 48 | ```lisp 49 | (defun my-php-mode-init () 50 | (subword-mode 1) 51 | (setq-local show-trailing-whitespace t) 52 | (setq-local ac-disable-faces '(font-lock-comment-face font-lock-string-face)) 53 | (add-hook 'hack-local-variables-hook 'php-ide-turn-on nil t)) 54 | 55 | (with-eval-after-load 'php-mode 56 | (add-hook 'php-mode-hook #'my-php-mode-init) 57 | (custom-set-variables 58 | '(php-mode-coding-style 'psr2) 59 | '(php-mode-template-compatibility nil) 60 | '(php-imenu-generic-expression 'php-imenu-generic-expression-simple)) 61 | 62 | ;; If you find phpcs to be bothersome, you can disable it. 63 | (when (require 'flycheck nil) 64 | (add-to-list 'flycheck-disabled-checkers 'php-phpmd) 65 | (add-to-list 'flycheck-disabled-checkers 'php-phpcs))) 66 | ``` 67 | 68 | ### プロジェクトローカル設定 69 | 70 | プロジェクトのトップディレクトリに`.dir-locals.el`または`.dir-locals-2.el`を記述すると、プロジェクト単位の設定を追加することができます。このファイルはユーザー自身のEmacsにインストールされたパッケージに依存するため、バージョン管理の対象に含めないことを推奨します。 71 | 72 | ```lisp 73 | ((nil 74 | (php-project-root . git) 75 | (php-project-coding-style . psr2))) 76 | ``` 77 | 78 | ## 不具合を報告する 79 | 80 | バグ報告の際には `M-x php-mode-debug` の出力を含めてください。この情報は問題の再現に役立ちます。 81 | 82 | 貢献するには 83 | ----------------- 84 | 85 | [CONTRIBUTING.md](CONTRIBUTING.md#japanese)をご覧ください。 86 | 87 | ## 著作権 88 | 89 | PHP Modeは[GNU General Public License Version 3][gpl-v3] (GPLv3) でライセンスされています。 90 | 91 | このプロジェクトは1999年に[Turadg Aleahmad][@turadg]が書いた`php-mode.el`に起源を持ちます。2013年に[Daniel Hackney][@haxney]がEmacs組み込みのCC Modeをもとに書き直し始めました。PHPモードの改善に協力した貢献者のリストは[Authors]と[Contributors]に掲載されています。 92 | 93 | このプロジェクトは2017年まで[Eric James Michael Ritz][@ejmr]によりメンテナンスされていました。現在は[Friends of Emacs-PHP Development][@emacs-php]コミュニティが引き継いで開発しています。 94 | 95 | > ``` 96 | > Copyright (C) 2023 Friends of Emacs-PHP development 97 | > Copyright (C) 1999, 2000, 2001, 2003, 2004 Turadg Aleahmad 98 | > 2008 Aaron S. Hawley 99 | > 2011, 2012, 2013, 2014, 2015, 2016, 2017 Eric James Michael Ritz 100 | > ``` 101 | > 102 | > This program is free software; you can redistribute it and/or modify 103 | > it under the terms of the GNU General Public License as published by 104 | > the Free Software Foundation, either version 3 of the License, or 105 | > (at your option) any later version. 106 | > 107 | > This program is distributed in the hope that it will be useful, 108 | > but WITHOUT ANY WARRANTY; without even the implied warranty of 109 | > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 110 | > GNU General Public License for more details. 111 | > 112 | > You should have received a copy of the GNU General Public License 113 | > along with this program. If not, see . 114 | 115 | [@ejmr]: https://github.com/ejmr 116 | [@emacs-php]: https://github.com/emacs-php 117 | [@haxney]: https://github.com/haxney 118 | [@turadg]: https://github.com/turadg 119 | [Authors]: https://github.com/emacs-php/php-mode/wiki/Authors 120 | [Contributors]: https://github.com/emacs-php/php-mode/graphs/contributors 121 | [Supported Version]: https://github.com/emacs-php/php-mode/wiki/Supported-Version 122 | [gpl-v3]: https://www.gnu.org/licenses/gpl-3.0 123 | [nongnu-elpa-badge]: https://elpa.nongnu.org/nongnu/php-mode.svg 124 | [nongnu-elpa]: https://elpa.nongnu.org/nongnu/php-mode.html 125 | [melpa-badge]: http://melpa.org/packages/php-mode-badge.svg 126 | [melpa-getting-started]: https://melpa.org/#/getting-started 127 | [melpa-link]: http://melpa.org/#/php-mode 128 | [php-mode]: https://github.com/emacs-php/php-mode 129 | [wiki]: https://github.com/emacs-php/php-mode/wiki 130 | [wiki-manual-installation]: https://github.com/emacs-php/php-mode/wiki/Manual-installation-ja 131 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |

Emacs PHP Mode

3 | 4 | [![Emacs: 30.0](https://img.shields.io/badge/Emacs-30.0-blue.svg)](https://www.gnu.org/software/emacs/) 5 | [![lang: PHP 8.4](https://img.shields.io/badge/lang-PHP%208.4-brightgreen.svg)](https://www.php.net/releases/8.4/) 6 | [![Build Status](https://github.com/emacs-php/php-mode/workflows/CI/badge.svg)](https://github.com/emacs-php/php-mode/actions) 7 | [![GPL v3](https://img.shields.io/badge/license-GPL_v3-green.svg)][gpl-v3]
8 | [![NonGNU ELPA][nongnu-elpa-badge]][nongnu-elpa] 9 | [![melpa badge][melpa-badge]][melpa-link] 10 | 11 | A powerful and flexible Emacs major mode for editing PHP scripts 12 | 13 | English   |   [日本語](README.ja.md) 14 | 15 |
16 | 17 | Please submit any bug reports or feature requests by creating issues on [the GitHub page for PHP Mode][php-mode]. 18 | 19 | > [!NOTE] 20 | > The [latest version][releases] of PHP Mode supports Emacs 30. 21 | > Please feel free to [open a discussion][discussions-emacs30] if you have any issues upgrading to Emacs 30. 22 | 23 | > [!WARNING] 24 | > After upgrading Emacs, when you open a PHP file for the first time, you may encounter errors related to CC Mode. These errors occur because a previously byte-compiled version of PHP Mode, cached on your disk, differs from the newly installed one. Reinstalling PHP Mode should resolve the issue. 25 | > 26 | > Try running **`M-x php-mode-debug-reinstall`** or **`M-x package-reinstall php-mode`**. 27 | 28 | [releases]: https://github.com/emacs-php/php-mode/releases 29 | [discussions-emacs30]: https://github.com/emacs-php/php-mode/discussions/798 30 | 31 | ## Installation 32 | 33 | **PHP Mode works with Emacs 27.1 or later.** For details on supported versions, see [Supported Version]. 34 | On Emacs 28 or later, you can install it simply by running: 35 | 36 | ``` 37 | M-x package-install php-mode 38 | ``` 39 | 40 | By [adding MELPA to `package-archives`][melpa-getting-started], you can extend Emacs with numerous packages from the web. 41 | 42 | If you prefer not to rely on a package manager, you can install the Lisp files directly in the traditional manner. See [Manual installation][wiki-manual-installation] for our recommended method. 43 | 44 | ## Configuration 45 | 46 | ### Personal Settings 47 | 48 | You can add configurations for PHP Mode in your `.emacs` file (`~/.emacs.d/init.el`): 49 | 50 | ```lisp 51 | (defun my-php-mode-init () 52 | (subword-mode 1) 53 | (setq-local show-trailing-whitespace t) 54 | (setq-local ac-disable-faces '(font-lock-comment-face font-lock-string-face)) 55 | (add-hook 'hack-local-variables-hook 'php-ide-turn-on nil t)) 56 | 57 | (with-eval-after-load 'php-mode 58 | (add-hook 'php-mode-hook #'my-php-mode-init) 59 | (custom-set-variables 60 | '(php-mode-coding-style 'psr2) 61 | '(php-mode-template-compatibility nil) 62 | '(php-imenu-generic-expression 'php-imenu-generic-expression-simple)) 63 | 64 | ;; If you find phpcs to be bothersome, you can disable it. 65 | (when (require 'flycheck nil) 66 | (add-to-list 'flycheck-disabled-checkers 'php-phpmd) 67 | (add-to-list 'flycheck-disabled-checkers 'php-phpcs))) 68 | ``` 69 | 70 | ### Project Setting 71 | 72 | You can add project-specific settings by creating a `.dir-locals.el` or `.dir-locals-2.el` file in the project's root directory. It is recommended not to put these files under version control, as they depend on the packages installed on each user's Emacs. 73 | 74 | ```lisp 75 | ((nil 76 | (php-project-root . git) 77 | (php-project-coding-style . psr2))) 78 | ``` 79 | 80 | ## Reporting Bugs 81 | 82 | When reporting a bug, please run `M-x php-mode-debug` and include its output in your bug report. This helps us reproduce any issues you may be experiencing. 83 | 84 | ## How to Contribute 85 | 86 | Please see [CONTRIBUTING.md](CONTRIBUTING.md#english). 87 | 88 | ## Copyright 89 | 90 | PHP Mode is licensed under [GNU General Public License Version 3][gpl-v3] (GPLv3). 91 | 92 | This project originated in `php-mode.el` written by [Turadg Aleahmad][@turadg] in 1999. In 2013 [Daniel Hackney][@haxney] began rewriting parts of PHP Mode in terms of Emacs' built-in CC Mode. Other contributors are listed in [Authors] and [Contributors]. 93 | 94 | This project was maintained by [Eric James Michael Ritz][@ejmr] until 2017. Currently, the [Friends of Emacs-PHP Development][@emacs-php] community inherits PHP Mode. 95 | 96 | > ``` 97 | > Copyright (C) 2022 Friends of Emacs-PHP development 98 | > Copyright (C) 1999, 2000, 2001, 2003, 2004 Turadg Aleahmad 99 | > 2008 Aaron S. Hawley 100 | > 2011, 2012, 2013, 2014, 2015, 2016, 2017 Eric James Michael Ritz 101 | > ``` 102 | > 103 | > This program is free software; you can redistribute it and/or modify 104 | > it under the terms of the GNU General Public License as published by 105 | > the Free Software Foundation, either version 3 of the License, or 106 | > (at your option) any later version. 107 | > 108 | > This program is distributed in the hope that it will be useful, 109 | > but WITHOUT ANY WARRANTY; without even the implied warranty of 110 | > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 111 | > GNU General Public License for more details. 112 | > 113 | > You should have received a copy of the GNU General Public License 114 | > along with this program. If not, see . 115 | 116 | [@ejmr]: https://github.com/ejmr 117 | [@emacs-php]: https://github.com/emacs-php 118 | [@haxney]: https://github.com/haxney 119 | [@turadg]: https://github.com/turadg 120 | [Authors]: https://github.com/emacs-php/php-mode/wiki/Authors 121 | [Contributors]: https://github.com/emacs-php/php-mode/graphs/contributors 122 | [Supported Version]: https://github.com/emacs-php/php-mode/wiki/Supported-Version 123 | [gpl-v3]: https://www.gnu.org/licenses/gpl-3.0 124 | [nongnu-elpa-badge]: https://elpa.nongnu.org/nongnu/php-mode.svg 125 | [nongnu-elpa]: https://elpa.nongnu.org/nongnu/php-mode.html 126 | [melpa-badge]: http://melpa.org/packages/php-mode-badge.svg 127 | [melpa-getting-started]: https://melpa.org/#/getting-started 128 | [melpa-link]: http://melpa.org/#/php-mode 129 | [php-mode]: https://github.com/emacs-php/php-mode 130 | [wiki]: https://github.com/emacs-php/php-mode/wiki 131 | [wiki-manual-installation]: https://github.com/emacs-php/php-mode/wiki/Manual-installation 132 | -------------------------------------------------------------------------------- /docs/php-align/README.md: -------------------------------------------------------------------------------- 1 | # php-align.el 2 | 3 | CAUTION!! this is still experimental. 4 | 5 | Support alignment (e.g. `align`, `align-current`) for PHP. 6 | 7 | Put this file into your load-path.and the following code into your ~/.emacs 8 | 9 | ```el 10 | (add-hook 'php-mode-hook #'php-align-setup) 11 | ``` 12 | 13 | ## Examples 14 | 15 | ### 1. 16 | 17 | #### before 18 | 19 | ```php 20 | $foo = "string"; // M-x align-current 21 | $looooooooong = 1; // 22 | ``` 23 | 24 | #### after 25 | 26 | ```php 27 | $foo = "string"; // M-x align-current 28 | $looooooooong = 1; // 29 | ``` 30 | 31 | ### 2. 32 | 33 | #### before 34 | 35 | ```php 36 | "$foo = 1"; 37 | $foo = "string"; // M-x align-current 38 | $looooooooong = 1; // 39 | 40 | $bar = 2; // 41 | ``` 42 | 43 | #### after 44 | 45 | ```php 46 | "$foo = 1"; 47 | $foo = "string"; // M-x align-current 48 | $looooooooong = 1; // 49 | 50 | $bar = 2; // 51 | ``` 52 | 53 | ### 3. 54 | 55 | #### before 56 | 57 | ```php 58 | $variable = 1; 59 | $vars = array(); // M-x align-current 60 | if ($variable == $vars) { 61 | 62 | } 63 | ``` 64 | 65 | #### after 66 | 67 | ```php 68 | $variable = 1; 69 | $vars = array(); // M-x align-current 70 | if ($variable == $vars) { 71 | 72 | } 73 | ``` 74 | 75 | ### 4. 76 | 77 | #### before 78 | 79 | ```php 80 | $vars = array( 81 | 1, 2, 3, 82 | 4, 5, 6, 83 | 7, 8, 9, 84 | 10, 11, 12, // C-u M-x align-current 85 | ); 86 | ``` 87 | 88 | #### after 89 | 90 | ```php 91 | $vars = array( 92 | 1, 2, 3, 93 | 4, 5, 6, 94 | 7, 8, 9, 95 | 10, 11, 12, // C-u M-x align-current 96 | ); 97 | ``` 98 | -------------------------------------------------------------------------------- /etc/git/AUTHORS.md.in: -------------------------------------------------------------------------------- 1 | # Authors 2 | 3 | ## Author 4 | 5 | - [Turadg Aleahmad](https://github.com/turadg) (Original Author) 6 | - [Daniel Hackney](https://github.com/haxney) (Integrated with CC Mode) 7 | 8 | ## Maintainer 9 | 10 | - [USAMI Kenta (@zonuexe)](https://github.com/zonuexe) 11 | 12 | ## Retired Maintainers 13 | 14 | - [Aaron S. Hawley](https://users.ninthfloor.org/~ashawley/) 15 | - [Lennart Borgman](https://www.emacswiki.org/emacs/LennartBorgman) 16 | - [Eric James Michael Ritz](https://github.com/ejmr) 17 | - [Syohei Yoshida](https://syohex.org/) 18 | 19 | ## Contributors 20 | 21 | All contributors listed below improved PHP Mode as well. 22 | 23 | Names Sorted Alphabetically: 24 | 25 | -------------------------------------------------------------------------------- /etc/git/AUTHORS2.md.in: -------------------------------------------------------------------------------- 1 | 2 | A chronological list of pre-2019 contributors can be found at [wiki/Authors](https://github.com/emacs-php/php-mode/wiki/Authors). 3 | 4 | Contributors since 2011, where this project was hosted, can also be found at [graphs/contributors](https://github.com/emacs-php/php-mode/graphs/contributors), except for accounts that have been withdrawn from GitHub. 5 | -------------------------------------------------------------------------------- /etc/git/commit-template.txt: -------------------------------------------------------------------------------- 1 | # SUBJECT, 50 Characters, No Period 2 | # "If applied, this commit will..." 3 | 4 | # BODY, 72 Characters 5 | # Answers the question, "Why?", not, "How?" 6 | 7 | # METADATA 8 | # GitHub-Issue: 9 | # Resolves: 10 | # See-also: 11 | # Reviewed-by: 12 | # Special-thanks: 13 | # HANGING INDENT 14 | -------------------------------------------------------------------------------- /etc/git/former-contributors: -------------------------------------------------------------------------------- 1 | - Aaron S. Hawley 2 | - Bill Lovett 3 | - Boris Folgmann 4 | - Chris Morris 5 | - Craig Andrews 6 | - David House 7 | - Dias Badekas 8 | - Doug Marcey 9 | - Eric Mc Sween 10 | - Fred Yankowski 11 | - Gerrit Riessen 12 | - Giacomo Tesio 13 | - Gregory Stark 14 | - Ian Eure 15 | - John Keller 16 | - Juanjo 17 | - Kevin Blake 18 | - Lennart Borgman 19 | - Mathias Meyer 20 | - Nils Rennebarth 21 | - Rex McMaster 22 | - Roland 23 | - Rosenfeld 24 | - Ryan 25 | - Sammartino 26 | - Sean Champ 27 | - Stefan Monnier 28 | - Stig Bakken 29 | - Torsten Martinsen 30 | - Valentin Funk 31 | - Ville Skytta 32 | - Vinai Kopp 33 | - ppercot 34 | -------------------------------------------------------------------------------- /etc/git/prepare-commit-msg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # prepare-commit-msg 4 | # ================== 5 | # 6 | # ## SYNOPSIS 7 | # 8 | # This hook fills the user's editor with a pre-written commit message 9 | # template, intended to help contributors adhere to good style and 10 | # practices when it comes to writing Git commit messages. 11 | # 12 | ######################################################################## 13 | 14 | # This hook will always recieve three arguments. We only care about the 15 | # first for our purposes, but still assign useful names to the others 16 | # in case we need them in the future. 17 | COMMIT_MESSAGE=$1 18 | COMMIT_SOURCE=$2 19 | COMMIT_SHA1=$3 20 | 21 | # If the commit message already contains content then the developer 22 | # is probably using his or her own template. In which case we do not 23 | # trample over it. We test for a pre-existing template by reading 24 | # the first line of the commit message this hook recieved, and check 25 | # so see if it is an empty string (apply our template) or not (leave 26 | # the message alone). 27 | TITLE_LINE=$(head -n1 $COMMIT_MESSAGE) 28 | 29 | if [ -z "$TITLE_LINE" ]; then 30 | project_dir=$(git rev-parse --show-toplevel) 31 | template="$project_dir/etc/git/commit-template.txt" 32 | echo "$(cat $template)\n$(cat $COMMIT_MESSAGE)" > $COMMIT_MESSAGE 33 | fi 34 | 35 | exit 0 36 | -------------------------------------------------------------------------------- /lisp/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | charset = utf-8 10 | 11 | [*.el] 12 | indent_style = space 13 | 14 | [Makefile] 15 | indent_style = tab 16 | -------------------------------------------------------------------------------- /lisp/php-align.el: -------------------------------------------------------------------------------- 1 | ;;; php-align.el --- Alignment configuration for PHP -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2011 tetsujin (Yusuke Segawa) 4 | ;; Copyright (C) 2023 Friends of Emacs-PHP development 5 | 6 | ;; Author: tetsujin (Yusuke Segawa) 7 | ;; Maintainer: USAMI Kenta 8 | ;; Keywords: php languages convenience align 9 | ;; Homepage: https://github.com/emacs-php/php-mode 10 | ;; Version: 1.26.1 11 | ;; License: GPL-3.0-or-later 12 | 13 | ;; This program is free software; you can redistribute it and/or modify 14 | ;; it under the terms of the GNU General Public License as published by 15 | ;; the Free Software Foundation, either version 3 of the License, or 16 | ;; (at your option) any later version. 17 | 18 | ;; This program is distributed in the hope that it will be useful, 19 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | ;; GNU General Public License for more details. 22 | 23 | ;; You should have received a copy of the GNU General Public License 24 | ;; along with this program. If not, see . 25 | 26 | ;;; Commentary: 27 | 28 | ;; This extension provides alignment for PHP. 29 | ;; Note that you must have Font Lock mode enabled. 30 | ;; 31 | ;; Put this file into your load-path.and the following code into your ~/.emacs 32 | ;; 33 | ;; (add-hook 'php-mode-hook #'php-align-setup) 34 | 35 | ;;; TODO: 36 | ;; - Add test codes using el-expectations. 37 | 38 | ;;; Code: 39 | (require 'align) 40 | (require 'regexp-opt) 41 | (require 'php-project) 42 | 43 | (defvar php-align-rules-list 44 | `((php-comma-delimiter 45 | (regexp . ",\\(\\s-*\\)[^/ \t\n]") 46 | (repeat . t) 47 | (modes . '(php-mode)) 48 | (run-if . ,(function (lambda () current-prefix-arg)))) 49 | (php-assignment 50 | (regexp . ,(concat "[^=!^&*-+<>/.| \t\n]\\(\\s-*[=!^&%*-+<>/.|]*\\)=>?" 51 | "\\(\\s-*\\)\\([^= \t\n]\\|$\\)")) 52 | (group . (1 2)) 53 | (modes . '(php-mode)) 54 | (justify . t) 55 | (tab-stop . nil)) 56 | (php-comment 57 | (regexp . "\\(\\s-*\\)\\(//.*\\|/\\*.*\\*/\\s-*\\)$") 58 | (modes . (php-mode)) 59 | (column . comment-column) 60 | (valid . ,(function 61 | (lambda () 62 | (save-excursion 63 | (goto-char (match-beginning 1)) 64 | (not (bolp))))))) 65 | (php-chain-logic 66 | (regexp . "\\(\\s-*\\)\\(&&\\|||\\|\\\\|\\\\)") 67 | (modes . (php-mode)) 68 | (valid . ,(function 69 | (lambda () 70 | (save-excursion 71 | (goto-char (match-end 2)) 72 | (looking-at "\\s-*\\(/[*/]\\|$\\)")))))))) 73 | 74 | (defvar php-align-region-separate 75 | (eval-when-compile 76 | (concat 77 | ;; blank line 78 | "\\(?:" "^\\s-*$" "\\)" 79 | "\\|" 80 | ;; comment start or end line 81 | "\\(?:" "^\\s-*\\(?:/[/*]\\|\\*/\\)" "\\)" 82 | "\\|" 83 | ;; end of line are '[', '(', '{', '}', '/*' 84 | "\\(?:" "\\(?:[[({}]\\|/\\*+\\)\\s-*$" "\\)" 85 | "\\|" 86 | ;; beginning of line are ')', '}', ']' and trailing character are ',', ';' 87 | "\\(?:" "^\\s-*[)}]][ \t,;]?\\s-*$" "\\)" 88 | "\\|" 89 | ;; beginning of line are some PHP keywrods 90 | "\\(?:" 91 | "^\\s-*" 92 | (regexp-opt 93 | '("for" "foreach" "while" "if" "else" "switch" "case" "break" "continue" 94 | "try" "catch" "declare" "do" "return" "namespace" "use")) 95 | "[ ;]" 96 | "\\)" 97 | "\\|" 98 | ;; function or method call 99 | "\\(?:" "^\\s-*" "\\(?:" "\\w\\|[->\\: \t]" "\\)+" "(" "\\)")) 100 | "Regexp of a section of PHP for alignment.") 101 | 102 | ;;;###autoload 103 | (defun php-align-setup () 104 | "Setup alignment configuration for PHP code." 105 | (when php-project-align-lines 106 | (php-align-mode 1))) 107 | 108 | (defvar php-align-mode-lighter " PHP-Align") 109 | 110 | ;;;###autoload 111 | (define-minor-mode php-align-mode 112 | "Alignment lines for PHP script." 113 | :lighter php-align-mode-lighter 114 | (add-to-list 'align-open-comment-modes 'php-mode) 115 | (add-to-list 'align-dq-string-modes 'php-mode) 116 | (add-to-list 'align-sq-string-modes 'php-mode) 117 | 118 | (if php-align-mode 119 | (progn 120 | (setq-local align-mode-rules-list php-align-rules-list) 121 | (setq-local align-region-separate php-align-region-separate)) 122 | (setq-local align-mode-rules-list nil) 123 | (setq-local align-region-separate nil))) 124 | 125 | (provide 'php-align) 126 | ;;; php-align.el ends here 127 | -------------------------------------------------------------------------------- /lisp/php-complete.el: -------------------------------------------------------------------------------- 1 | ;;; php-complete.el --- PHP auto-compiletion functions -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2023 Friends of Emacs-PHP development 4 | ;; Copyright (C) 2021, 2022 Free Software Foundation, Inc. 5 | 6 | ;; Author: USAMI Kenta 7 | 8 | ;; Created: 18 Sep 2022 9 | ;; Version: 1.26.1 10 | ;; Keywords: languages, php 11 | 12 | ;; This program is free software; you can redistribute it and/or modify 13 | ;; it under the terms of the GNU General Public License as published by 14 | ;; the Free Software Foundation, either version 3 of the License, or 15 | ;; (at your option) any later version. 16 | 17 | ;; This program is distributed in the hope that it will be useful, 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | ;; GNU General Public License for more details. 21 | 22 | ;; You should have received a copy of the GNU General Public License 23 | ;; along with this program. If not, see . 24 | 25 | ;;; Commentary: 26 | 27 | ;; Provide auto-compiletion functions. 28 | 29 | ;; These functions are copied function from GNU ELPA. 30 | ;; 31 | ;; - cape--table-with-properties (cape.el) 32 | ;; - cape--bounds (cape.el) 33 | ;; - cape--interactive (cape.el) 34 | 35 | ;;; Code: 36 | (eval-when-compile 37 | (require 'cl-lib)) 38 | (require 'php) 39 | (require 'php-defs) 40 | 41 | ;;;###autoload 42 | (defgroup php-complete nil 43 | "Auto completion for PHP edition." 44 | :tag "PHP Completion" 45 | :group 'php-mode) 46 | 47 | ;;;###autoload 48 | (defcustom php-complete-function-modules '(bcmath core gmp libxml intl mbstring pcntl posix sodium xml xmlwriter) 49 | "Module names for function names completion." 50 | :tag "PHP Complete Function Modules" 51 | :type (eval-when-compile `(set ,@(mapcar (lambda (elm) (list 'const (car elm))) 52 | php-defs-functions-alist))) 53 | :safe (lambda (value) (and (listp value) (cl-loop for v in values 54 | always (assq v php-defs-functions-alist)))) 55 | :group 'php-complete) 56 | 57 | ;;; Cape functions: 58 | 59 | ;; These functions are copied from cape.el package. https://github.com/minad/cape 60 | ;; Thanks to original author Daniel Mendler (@minad) 61 | 62 | (cl-defun php-complete--cape-table-with-properties (table &key category (sort t) &allow-other-keys) 63 | "Create completion TABLE with properties. 64 | CATEGORY is the optional completion category. 65 | SORT should be nil to disable sorting." 66 | (if (or (not table) (and (not category) sort)) 67 | table 68 | (let ((metadata `(metadata 69 | ,@(and category `((category . ,category))) 70 | ,@(and (not sort) '((display-sort-function . identity) 71 | (cycle-sort-function . identity)))))) 72 | (lambda (str pred action) 73 | (if (eq action 'metadata) 74 | metadata 75 | (complete-with-action action table str pred)))))) 76 | 77 | (defun php-complete--cape-bounds (thing) 78 | "Return bounds of THING." 79 | (or (bounds-of-thing-at-point thing) (cons (point) (point)))) 80 | 81 | (defun php-complete--cape-interactive (capf) 82 | "Complete with CAPF." 83 | (let ((completion-at-point-functions (list capf))) 84 | (or (completion-at-point) (user-error "%s: No completions" capf)))) 85 | 86 | ;;; Variables: 87 | (defvar php-complete--functions-cache (make-hash-table :test #'equal)) 88 | 89 | ;;; Data source functions: 90 | (defun php-complete--functions () 91 | "Return PHP function names." 92 | (let* ((modules (sort php-complete-function-modules #'string<)) 93 | (functions (gethash modules php-complete--functions-cache))) 94 | (unless functions 95 | (setq functions (sort (cl-loop for module in modules 96 | append (assq module php-defs-functions-alist)) 97 | #'string<)) 98 | (puthash modules functions php-complete--functions-cache)) 99 | functions)) 100 | 101 | ;;; Compiletion function: 102 | 103 | ;;;###autoload 104 | (defun php-complete-complete-function (&optional interactive) 105 | "Complete PHP keyword at point. 106 | 107 | If INTERACTIVE is nil the function acts like a capf." 108 | (interactive (list t)) 109 | (if interactive 110 | (php-complete--cape-interactive #'php-complete-complete-function) 111 | (let ((bounds (php-complete--cape-bounds 'symbol)) 112 | (tokens (nreverse (php-leading-tokens 2)))) 113 | `(,(car bounds) ,(cdr bounds) 114 | ,(php-complete--cape-table-with-properties 115 | (unless (or (member (nth 0 tokens) '("->" "::")) 116 | (string-prefix-p "$" (nth 1 tokens))) 117 | (php-complete--functions)) 118 | :category 'cape-keyword) 119 | :annotation-function (lambda (_) " PHP functions") 120 | :company-kind (lambda (_) 'keyword) 121 | :exclusive 'no)))) 122 | 123 | (provide 'php-complete) 124 | ;;; php-complete.el ends here 125 | -------------------------------------------------------------------------------- /lisp/php-flymake.el: -------------------------------------------------------------------------------- 1 | ;;; php-flymake.el --- Flymake backend for PHP -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2023 Friends of Emacs-PHP development 4 | 5 | ;; Author: USAMI Kenta 6 | ;; Created: 5 Mar 2022 7 | ;; Version: 1.26.1 8 | ;; Keywords: tools, languages, php 9 | 10 | ;; This program is free software; you can redistribute it and/or modify 11 | ;; it under the terms of the GNU General Public License as published by 12 | ;; the Free Software Foundation, either version 3 of the License, or 13 | ;; (at your option) any later version. 14 | 15 | ;; This program is distributed in the hope that it will be useful, 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | ;; GNU General Public License for more details. 19 | 20 | ;; You should have received a copy of the GNU General Public License 21 | ;; along with this program. If not, see . 22 | 23 | ;;; Commentary: 24 | 25 | ;; Flymake backend for PHP. 26 | 27 | ;;; Code: 28 | (require 'flymake) 29 | (require 'cl-lib) 30 | (eval-and-compile 31 | (require 'flymake-proc)) 32 | (eval-when-compile 33 | (require 'pcase) 34 | (require 'rx)) 35 | 36 | (defgroup php-flymake nil 37 | "Flymake backend for PHP." 38 | :tag "PHP Flymake" 39 | :group 'php) 40 | 41 | (defcustom php-flymake-executable-command-args nil 42 | "List of command and arguments for `php -l'." 43 | :group 'php-flymake 44 | :type '(repeat string) 45 | :safe (lambda (v) (and (listp v) (cl-every v #'stringp)))) 46 | 47 | (defconst php-flymake--diaggnostics-pattern 48 | (eval-when-compile 49 | (rx bol (? "PHP ") 50 | (group (or "Parse" "Fatal")) ;; 1: type, not used 51 | " error:" (+ (syntax whitespace)) 52 | (group (+? any)) ;; 2: msg 53 | " in " (group (+? any)) ;; 3: file, not used 54 | " on line " (group (+ num)) ;; 4: line 55 | eol))) 56 | 57 | (defvar-local php-flymake--proc nil) 58 | 59 | ;;;###autoload 60 | (defun php-flymake (report-fn &rest args) 61 | "Flymake backend for PHP syntax check. 62 | 63 | See `flymake-diagnostic-functions' about REPORT-FN and ARGS parameters." 64 | (setq-local flymake-proc-allowed-file-name-masks nil) 65 | (when (process-live-p php-flymake--proc) 66 | (if (plist-get args :interactive) 67 | (user-error "There's already a Flymake process running in this buffer") 68 | (kill-process php-flymake--proc))) 69 | (save-restriction 70 | (widen) 71 | (cl-multiple-value-bind (use-stdin skip) (php-flymake--buffer-status) 72 | (unless skip 73 | (setq php-flymake--proc (php-flymake--make-process report-fn buffer-file-name (current-buffer) use-stdin)) 74 | (when use-stdin 75 | (process-send-region php-flymake--proc (point-min) (point-max))) 76 | (process-send-eof php-flymake--proc))))) 77 | 78 | (defun php-flymake--buffer-status () 79 | "Return buffer status about \"use STDIN\" and \"Skip diagnostic\"." 80 | (let* ((use-stdin (or (null buffer-file-name) 81 | (buffer-modified-p (current-buffer)) 82 | (file-remote-p buffer-file-name))) 83 | (skip (and (not use-stdin) 84 | (save-excursion (goto-char (point-min)) (looking-at-p "#!"))))) 85 | (cl-values use-stdin skip))) 86 | 87 | (defun php-flymake--diagnostics (locus source) 88 | "Parse output of `php -l' command in SOURCE buffer. LOCUS means filename." 89 | (unless (eval-when-compile (and (fboundp 'flymake-make-diagnostic) 90 | (fboundp 'flymake-diag-region))) 91 | (error "`php-flymake' requires Emacs 26.1 or later")) 92 | (cl-loop 93 | while (search-forward-regexp php-flymake--diaggnostics-pattern nil t) 94 | for msg = (match-string 2) 95 | for line = (string-to-number (match-string 4)) 96 | for diag = (or (pcase-let ((`(,beg . ,end) 97 | (flymake-diag-region source line))) 98 | (flymake-make-diagnostic source beg end :error msg)) 99 | (flymake-make-diagnostic locus (cons line nil) nil :error msg)) 100 | return (list diag))) 101 | 102 | (defun php-flymake--build-command-line (file) 103 | "Return the command line for `php -l' FILE." 104 | (let* ((command-args (or php-flymake-executable-command-args 105 | (list (or (bound-and-true-p php-executable) "php")))) 106 | (cmd (car-safe command-args)) 107 | (default-directory (expand-file-name "~"))) 108 | (unless (or (file-executable-p cmd) 109 | (executable-find cmd)) 110 | (user-error "`%s' is not valid command" cmd)) 111 | (nconc command-args 112 | (list "-d" "display_errors=0") 113 | (when file (list "-f" file)) 114 | (list "-l")))) 115 | 116 | (defun php-flymake--make-process (report-fn locus source use-stdin) 117 | "Make PHP process for syntax check SOURCE buffer. 118 | 119 | See `flymake-diagnostic-functions' about REPORT-FN parameter. 120 | See `flymake-make-diagnostic' about LOCUS parameter." 121 | (make-process 122 | :name "php-flymake" 123 | :buffer (generate-new-buffer "*flymake-php-flymake*") 124 | :command (php-flymake--build-command-line (unless use-stdin locus)) 125 | :noquery t :connection-type 'pipe 126 | :sentinel 127 | (lambda (p _ev) 128 | (unwind-protect 129 | (when (and (eq 'exit (process-status p)) 130 | (with-current-buffer source (eq p php-flymake--proc))) 131 | (with-current-buffer (process-buffer p) 132 | (goto-char (point-min)) 133 | (funcall report-fn 134 | (if (zerop (process-exit-status p)) 135 | nil 136 | (php-flymake--diagnostics locus source))))) 137 | (unless (process-live-p p) 138 | ;; (display-buffer (process-buffer p)) ; uncomment to debug 139 | (kill-buffer (process-buffer p))))))) 140 | 141 | (provide 'php-flymake) 142 | ;;; php-flymake.el ends here 143 | -------------------------------------------------------------------------------- /lisp/php-ide-phpactor.el: -------------------------------------------------------------------------------- 1 | ;;; php-ide-phpactor.el --- PHP-IDE feature using Phpactor RPC -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2023 Friends of Emacs-PHP development 4 | 5 | ;; Author: USAMI Kenta 6 | ;; Keywords: tools, files 7 | ;; URL: https://github.com/emacs-php/php-mode 8 | ;; Version: 1.26.1 9 | ;; License: GPL-3.0-or-later 10 | 11 | ;; This program is free software; you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; This program is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with this program. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;; PHP-IDE implementation to integrate Phpactor (phpactor.el). 27 | ;; This feature depends on . 28 | 29 | ;;; Code: 30 | (require 'phpactor nil t) 31 | (require 'popup nil t) 32 | (require 'smart-jump nil t) 33 | (require 'cl-lib) 34 | 35 | (defvar-local php-ide-phpactor-buffer nil) 36 | (defvar-local php-ide-phpactor-hover-last-pos nil) 37 | (defvar-local php-ide-phpactor-hover-last-msg nil) 38 | 39 | (declare-function phpactor--command-argments "ext:phpactor" (&rest arg-keys)) 40 | (declare-function phpactor--parse-json "ext:phpactor" (buffer)) 41 | (declare-function phpactor--rpc-async "ext:phpactor" (action arguments callback)) 42 | (declare-function phpactor-goto-definition "ext:phpactor" ()) 43 | (declare-function popup-tip "ext:popup" (string)) 44 | (declare-function smart-jump-back "ext:smart-jump" ()) 45 | (declare-function smart-jump-go "ext:smart-jump" (&optional smart-list continue)) 46 | (declare-function smart-jump-references "ext:smart-jump" (&optional smart-list continue)) 47 | 48 | (defgroup php-ide-phpactor nil 49 | "UI support for PHP developing." 50 | :tag "PHP-IDE Phpactor" 51 | :prefix "php-ide-phpactor-" 52 | :group 'php-ide) 53 | 54 | (defcustom php-ide-phpactor-activate-features '(all) 55 | "A set of Phpactor features you want to enable." 56 | :tag "PHP-IDE Phpactor Activate Features" 57 | :type '(set (const :tag "All" all) 58 | (const hover) 59 | (const navigation)) 60 | :safe (lambda (xs) (and (listp xs) 61 | (cl-every (lambda (x) (memq x '(all hover navigation))) xs))) 62 | :group 'php-ide-phpactor) 63 | 64 | (defvar php-ide-phpactor-timer nil 65 | "Timer object for execute Phpactor and display hover message.") 66 | 67 | (defvar php-ide-phpactor-disable-hover-at-point-functions 68 | '(php-in-string-or-comment-p)) 69 | 70 | (defun php-ide-phpactor--disable-hover-at-point-p () 71 | "Return non-NIL if any function return non-NIL for disable to hover at point." 72 | (cl-loop for f in php-ide-phpactor-disable-hover-at-point-functions 73 | never (not (funcall f)))) 74 | 75 | (defun php-ide-phpactor-hover () 76 | "Show brief information about the symbol underneath the cursor." 77 | (interactive) 78 | (when (and php-ide-phpactor-buffer (not (php-ide-phpactor--disable-hover-at-point-p))) 79 | (if (eq (point) php-ide-phpactor-hover-last-pos) 80 | (when php-ide-phpactor-hover-last-msg 81 | (let ((msg php-ide-phpactor-hover-last-msg)) 82 | (setq php-ide-phpactor-hover-last-msg nil) 83 | (popup-tip msg))) 84 | (setq php-ide-phpactor-hover-last-pos (point)) 85 | (let ((main-buffer (current-buffer))) 86 | (phpactor--rpc-async "hover" (phpactor--command-argments :source :offset) 87 | (lambda (proc) 88 | (let* ((response (phpactor--parse-json (process-buffer proc))) 89 | (msg (plist-get (plist-get response :parameters) :message))) 90 | (with-current-buffer main-buffer 91 | (setq php-ide-phpactor-hover-last-msg msg))))))))) 92 | 93 | (defsubst php-ide-phpactor--feature-activated-p (feature) 94 | "Is FEATURE activated in `php-ide-phpactor-activate-features'." 95 | (or (memq 'all php-ide-phpactor-activate-features) 96 | (memq feature php-ide-phpactor-activate-features))) 97 | 98 | ;;;###autoload 99 | (defun php-ide-phpactor-activate () 100 | "Activate PHP-IDE using phpactor.el." 101 | (interactive) 102 | (when (php-ide-phpactor--feature-activated-p 'navigation) 103 | (if (not (bound-and-true-p phpactor-smart-jump-initialized)) 104 | (local-set-key [remap xref-find-definitions] #'phpactor-goto-definition) 105 | (local-set-key [remap xref-find-definitions] #'smart-jump-go) 106 | (local-set-key [remap xref-pop-marker-stack] #'smart-jump-back) 107 | (local-set-key [remap xref-find-references] #'smart-jump-references))) 108 | (when (php-ide-phpactor--feature-activated-p 'hover) 109 | (unless php-ide-phpactor-timer 110 | (setq php-ide-phpactor-timer (run-with-timer 0.8 0.8 #'php-ide-phpactor-hover)))) 111 | (setq php-ide-phpactor-buffer t)) 112 | 113 | ;;;###autoload 114 | (defun php-ide-phpactor-deactivate () 115 | "Dectivate PHP-IDE using phpactor.el." 116 | (interactive) 117 | (local-unset-key [remap xref-find-definitions]) 118 | (local-unset-key [remap xref-pop-marker-stack]) 119 | (local-unset-key [remap xref-find-references]) 120 | 121 | (when php-ide-phpactor-timer 122 | (cancel-timer php-ide-phpactor-timer) 123 | (setq php-ide-phpactor-timer nil)) 124 | (setq php-ide-phpactor-buffer nil)) 125 | 126 | (provide 'php-ide-phpactor) 127 | ;;; php-ide-phpactor.el ends here 128 | -------------------------------------------------------------------------------- /lisp/php-mode-debug.el: -------------------------------------------------------------------------------- 1 | ;;; php-mode-debug.el --- Debug functions for PHP Mode -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2023 Friends of Emacs-PHP development 4 | 5 | ;; Author: USAMI Kenta 6 | ;; URL: https://github.com/emacs-php/php-mode 7 | ;; Keywords: maint 8 | ;; Version: 1.26.1 9 | ;; License: GPL-3.0-or-later 10 | 11 | ;; This program is free software; you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; This program is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with this program. If not, see . 23 | 24 | ;;; Commentary: 25 | 26 | ;; Provides functions to debugging php-mode work. 27 | 28 | ;;; Code: 29 | (require 'cc-mode) 30 | (require 'cus-edit) 31 | (require 'php-mode) 32 | (require 'package) 33 | (require 'pkg-info nil t) 34 | (require 'el-get nil t) 35 | 36 | (declare-function pkg-info-version-info "ext:pkg-info" (library &optional package show)) 37 | 38 | (defun php-mode-debug-reinstall (force &optional called-interactive) 39 | "Reinstall PHP Mode to solve Cc Mode version mismatch. 40 | 41 | When FORCE, try to reinstall without interactively asking. 42 | When CALLED-INTERACTIVE then message the result." 43 | (interactive (list (yes-or-no-p (if (string= php-mode-cc-version c-version) 44 | "No need to recompile, but force PHP Mode to reinstall? " 45 | "Force reinstall PHP Mode? ")) 46 | t)) 47 | (let* ((cc-version-mismatched (string= php-mode-cc-version c-version)) 48 | (preface (if cc-version-mismatched 49 | "" 50 | "CC Mode has been updated. "))) 51 | (if (catch 'success 52 | (cond 53 | ((and (not called-interactive) 54 | (not force) 55 | cc-version-mismatched) 56 | nil) 57 | ((and (package-installed-p 'php-mode) 58 | (or force 59 | (yes-or-no-p (format "%sReinstall `php-mode' package? " preface)))) 60 | (package-reinstall 'php-mode) 61 | (throw 'success t)) 62 | ;; This clause is not included in the byte-compiled code when compiled without El-Get 63 | ((and (eval-when-compile (and (fboundp 'el-get-package-is-installed) 64 | (fboundp 'el-get-reinstall))) 65 | (el-get-package-is-installed 'php-mode) 66 | (or force 67 | (yes-or-no-p (format "%sReinstall `php-mode' package by El-Get? " preface)))) 68 | (el-get-reinstall 'php-mode) 69 | (throw 'success t)) 70 | ((not called-interactive) 71 | (user-error 72 | (if cc-version-mismatched 73 | "PHP Mode cannot be reinstalled automatically. Please try manually if necessary" 74 | "Please reinstall or byte recompile PHP Mode files manually"))))) 75 | (user-error "PHP Mode reinstalled successfully. Please restart Emacs") 76 | (prog1 t 77 | (when called-interactive 78 | (message "PHP Mode was not reinstalled")))))) 79 | 80 | (defun php-mode-debug--buffer (&optional command &rest args) 81 | "Return buffer for php-mode-debug, and execute `COMMAND' with `ARGS'." 82 | (with-current-buffer (get-buffer-create "*PHP Mode DEBUG*") 83 | (cl-case command 84 | (init (erase-buffer) 85 | (goto-address-mode)) 86 | (top (goto-char (point-min))) 87 | (insert (goto-char (point-max)) 88 | (apply #'insert args))) 89 | (current-buffer))) 90 | 91 | (defun php-mode-debug--message (format-string &rest args) 92 | "Write message `FORMAT-STRING' and `ARGS' to debug buffer, like `message'." 93 | (declare (indent 1)) 94 | (php-mode-debug--buffer 'insert (apply #'format format-string args) "\n")) 95 | 96 | (defun php-mode-debug () 97 | "Display informations useful for debugging PHP Mode." 98 | (interactive) 99 | (unless (eq major-mode 'php-mode) 100 | (user-error "Invoke this command only in php-mode buffer")) 101 | (php-mode-debug--buffer 'init) 102 | (php-mode-debug--message "Feel free to report on GitHub what you noticed!") 103 | (php-mode-debug--message "https://github.com/emacs-php/php-mode/issues/new") 104 | (php-mode-debug--message "") 105 | (php-mode-debug--message "Pasting the following information on the issue will help us to investigate the cause.") 106 | (php-mode-debug--message "```") 107 | (php-mode-debug--message "--- PHP-MODE DEBUG BEGIN ---") 108 | (php-mode-debug--message "versions: %s; %s; Cc Mode %s)" 109 | (emacs-version) 110 | (php-mode-version) 111 | (if (string= php-mode-cc-version c-version) 112 | c-version 113 | (format "%s (php-mode-cc-version: %s *mismatched*)" c-version php-mode-cc-version))) 114 | (php-mode-debug--message "package-version: %s" 115 | (if (fboundp 'pkg-info) 116 | (pkg-info-version-info 'php-mode) 117 | (let ((pkg (and (boundp 'package-alist) 118 | (cadr (assq 'php-mode package-alist))))) 119 | (when (and pkg (member (package-desc-status pkg) '("unsigned" "dependency"))) 120 | (package-version-join (package-desc-version pkg)))))) 121 | 122 | (php-mode-debug--message "major-mode: %s" major-mode) 123 | (php-mode-debug--message "minor-modes: %s" 124 | (cl-loop for s in minor-mode-list 125 | unless (string-match-p "global" (symbol-name s)) 126 | if (and (boundp s) (symbol-value s)) 127 | collect s)) 128 | (php-mode-debug--message "variables: %s" 129 | (cl-loop for v in '(indent-tabs-mode tab-width) 130 | collect (list v (symbol-value v)))) 131 | (php-mode-debug--message "custom variables: %s" 132 | (cl-loop for (v type) in (custom-group-members 'php nil) 133 | if (eq type 'custom-variable) 134 | collect (list v (symbol-value v)))) 135 | (php-mode-debug--message "c-indentation-style: %s" c-indentation-style) 136 | (php-mode-debug--message "c-style-variables: %s" 137 | (cl-loop for v in c-style-variables 138 | unless (memq v '(c-doc-comment-style c-offsets-alist)) 139 | collect (list v (symbol-value v)))) 140 | (php-mode-debug--message "c-doc-comment-style: %s" c-doc-comment-style) 141 | (php-mode-debug--message "c-offsets-alist: %s" c-offsets-alist) 142 | (php-mode-debug--message "buffer: %s" (list :length (save-excursion (goto-char (point-max)) (point)))) 143 | (php-mode-debug--message "--- PHP-MODE DEBUG END ---") 144 | (php-mode-debug--message "```\n") 145 | (php-mode-debug--message "Thank you!") 146 | (pop-to-buffer (php-mode-debug--buffer 'top))) 147 | 148 | (provide 'php-mode-debug) 149 | ;;; php-mode-debug.el ends here 150 | -------------------------------------------------------------------------------- /script/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Maintenance script for PHP Mode 3 | 4 | These scripts are provided for maintenance of PHP Mode. 5 | 6 | ## Extract PHP Functions 7 | 8 | This script extract PHP function names from . 9 | 10 | ### Usage 11 | 12 | ``` 13 | Usage: 14 | ./script/extract_functions.php count < php_manual_en.json 15 | ./script/extract_functions.php modules < php_manual_en.json 16 | ./script/extract_functions.php functions < php_manual_en.json > result.json 17 | ./script/extract_functions.php functions-sexp < php_manual_en.json > result.el 18 | ``` 19 | 20 | ### Data 21 | 22 | A pattern for grouping function modules by function-id is written in `data/module_id_prefixes.php`. 23 | 24 | * All entries are combined as prefix matching patterns 25 | * The meanings of `.` and `\.` (matches) in the regular expression are swapped 26 | * `\.` matches any one character 27 | * `.` matches only `"."` 28 | * An alphanumeric-terminated entry requires an exact match 29 | * Other entries require a [`\b`(word boundary)](https://www.php.net/manual/regexp.reference.escape.php) at the end 30 | 31 | ```php 32 | return [ 33 | 'apache' => [ 34 | 'function.apache-', // matches all "apache-" prefixed IDs 35 | 'function.virtual', // matches only "function.virtual" 36 | ], 37 | 'bcmath' => [ 38 | 'function.bc\.+', // matches "function.bcadd", "function.bccomp", ...etc 39 | ], 40 | ``` 41 | -------------------------------------------------------------------------------- /script/extract_functions.php: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | 9 | * @license FSFAP https://spdx.org/licenses/FSFAP.html 10 | */ 11 | 12 | // Copying and distribution of this file, with or without modification, 13 | // are permitted in any medium without royalty provided the copyright 14 | // notice and this notice are preserved. This file is offered as-is, 15 | // without any warranty. 16 | 17 | declare(strict_types=1); 18 | 19 | error_reporting(E_ALL); 20 | 21 | $functions = json_decode(stream_get_contents(STDIN), true); 22 | 23 | $command = $argv[0]; 24 | $subcommand = $argv[1] ?? null; 25 | 26 | $subcommands = [ 27 | 'count' => function (array $extracted) { 28 | echo json_encode(array_map(count(...), $extracted), JSON_PRETTY_PRINT), PHP_EOL; 29 | }, 30 | 'modules' => function (array $extracted) { 31 | echo implode(PHP_EOL, array_keys($extracted)), PHP_EOL; 32 | }, 33 | 'functions' => function (array $extracted) { 34 | echo json_encode(array_map(array_keys(...), $extracted), JSON_PRETTY_PRINT), PHP_EOL; 35 | }, 36 | 'functions-txt' => function (array $extracted) { 37 | foreach ($extracted as $functions) { 38 | foreach ($functions as $name => $_) { 39 | echo $name, PHP_EOL; 40 | } 41 | } 42 | }, 43 | 'functions-sexp' => function (array $extracted) { 44 | echo " '("; 45 | foreach ($extracted as $module => $functions) { 46 | echo "\n ({$module}"; 47 | // ksort($functions); 48 | foreach ($functions as $name => $function) { 49 | $escaped_name = strtr($name, ['\\' => '\\\\']); 50 | echo "\n \"{$escaped_name}\""; 51 | } 52 | echo ")"; 53 | } 54 | echo ")"; 55 | }, 56 | ]; 57 | 58 | if (!isset($subcommands[$subcommand])) { 59 | $json_url = 'http://doc.php.net/downloads/json/php_manual_en.json'; 60 | fwrite(STDERR, implode(PHP_EOL, [ 61 | "[Extract PHP Functions]\n", 62 | "This script extract PHP function names from <{$json_url}>.\n", 63 | "Usage:", 64 | "\t{$command} count < php_manual_en.json", 65 | "\t{$command} modules < php_manual_en.json", 66 | "\t{$command} functions < php_manual_en.json > result.json", 67 | "\t{$command} functions-sexp < php_manual_en.json > result.el", 68 | '', 69 | ])); 70 | exit(1); 71 | } 72 | 73 | $module_id_patterns = array_map( 74 | fn($allowlist) => '/\A(?:' . implode('|', array_map( 75 | fn($preg) => strtr($preg, ['\.' => '.', '.' => '\.']) . 76 | (preg_match('/[0-9a-z]\z/', $preg) ? '\z' : '\b'), 77 | $allowlist) 78 | ) . ')/', 79 | include __DIR__ . '/data/module_id_prefixes.php' 80 | ); 81 | 82 | $extracted = []; 83 | 84 | foreach ($functions as $name => $function) { 85 | if (str_contains($name, '::')) { 86 | continue; 87 | } 88 | 89 | $module = get_module($function, $module_id_patterns); 90 | 91 | if ($module === null) { 92 | fwrite(STDERR, "{$name}: {$function['id']}\n"); 93 | } else { 94 | $extracted[$module][$name] = $function; 95 | } 96 | } 97 | 98 | ksort($extracted); 99 | array_walk($extracted, function (&$functions) { 100 | ksort($functions); 101 | }); 102 | 103 | call_user_func($subcommands[$subcommand], $extracted); 104 | 105 | /** 106 | * @param array{id: non-empty-string} $function 107 | * @param array $function 108 | */ 109 | function get_module(array $function, array $patterns): ?string 110 | { 111 | foreach ($patterns as $module => $pattern) { 112 | if (preg_match($pattern, $function['id'])) { 113 | return $module; 114 | } 115 | } 116 | 117 | return null; 118 | } 119 | -------------------------------------------------------------------------------- /tests/.dir-locals.el: -------------------------------------------------------------------------------- 1 | ((emacs-lisp-mode (package-lint-main-file . "../php-mode.el"))) 2 | -------------------------------------------------------------------------------- /tests/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = false 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*.php] 8 | end_of_line = lf 9 | charset = utf-8 10 | trim_trailing_whitespace = false 11 | insert_final_newline = false 12 | -------------------------------------------------------------------------------- /tests/7.4/arrow-function.php: -------------------------------------------------------------------------------- 1 | $x + $y; 10 | 11 | $fn2 = [ 12 | fn($x) => $x + $y 13 | ]; 14 | 15 | $z = 1; 16 | $fn3 = fn($x) => fn($y) => $x * $y + $z; 17 | -------------------------------------------------------------------------------- /tests/7.4/arrow-function.php.faces: -------------------------------------------------------------------------------- 1 | ;; -*- mode: emacs-lisp -*- 2 | (("" . php-comparison-op) 20 | (" ") 21 | ("$" . php-variable-sigil) 22 | ("x" . php-variable-name) 23 | (" ") 24 | ("+" . php-arithmetic-op) 25 | (" ") 26 | ("$" . php-variable-sigil) 27 | ("y" . php-variable-name) 28 | (";\n\n") 29 | ("$" . php-variable-sigil) 30 | ("fn2" . php-variable-name) 31 | (" ") 32 | ("=" . php-assignment-op) 33 | (" [\n ") 34 | ("fn" . php-keyword) 35 | ("(") 36 | ("$" . php-variable-sigil) 37 | ("x" . php-variable-name) 38 | (") ") 39 | ("=" . php-assignment-op) 40 | (">" . php-comparison-op) 41 | (" ") 42 | ("$" . php-variable-sigil) 43 | ("x" . php-variable-name) 44 | (" ") 45 | ("+" . php-arithmetic-op) 46 | (" ") 47 | ("$" . php-variable-sigil) 48 | ("y" . php-variable-name) 49 | ("\n];\n\n") 50 | ("$" . php-variable-sigil) 51 | ("z" . php-variable-name) 52 | (" ") 53 | ("=" . php-assignment-op) 54 | (" 1;\n") 55 | ("$" . php-variable-sigil) 56 | ("fn3" . php-variable-name) 57 | (" ") 58 | ("=" . php-assignment-op) 59 | (" ") 60 | ("fn" . php-keyword) 61 | ("(") 62 | ("$" . php-variable-sigil) 63 | ("x" . php-variable-name) 64 | (") ") 65 | ("=" . php-assignment-op) 66 | (">" . php-comparison-op) 67 | (" ") 68 | ("fn" . php-keyword) 69 | ("(") 70 | ("$" . php-variable-sigil) 71 | ("y" . php-variable-name) 72 | (") ") 73 | ("=" . php-assignment-op) 74 | (">" . php-comparison-op) 75 | (" ") 76 | ("$" . php-variable-sigil) 77 | ("x" . php-variable-name) 78 | (" ") 79 | ("*" . php-arithmetic-op) 80 | (" ") 81 | ("$" . php-variable-sigil) 82 | ("y" . php-variable-name) 83 | (" ") 84 | ("+" . php-arithmetic-op) 85 | (" ") 86 | ("$" . php-variable-sigil) 87 | ("z" . php-variable-name) 88 | (";\n")) 89 | -------------------------------------------------------------------------------- /tests/7.4/typed-property.php: -------------------------------------------------------------------------------- 1 | string = $var; 12 | } 13 | 14 | public function print() 15 | { 16 | var_dump($this->string); 17 | } 18 | } 19 | 20 | (new Typed)->print(); 21 | -------------------------------------------------------------------------------- /tests/7.4/typed-property.php.faces: -------------------------------------------------------------------------------- 1 | ;; -*- mode: emacs-lisp -*- 2 | (("" . php-object-op) 38 | ("string" . php-property-name) 39 | (" ") 40 | ("=" . php-assignment-op) 41 | (" ") 42 | ("$" . php-variable-sigil) 43 | ("var" . php-variable-name) 44 | (";\n }\n\n ") 45 | ("public" . php-keyword) 46 | (" ") 47 | ("function" . php-keyword) 48 | (" ") 49 | ("print" . php-function-name) 50 | ("()\n {\n ") 51 | ("var_dump" . php-function-call-traditional) 52 | ("(") 53 | ("$" . php-this-sigil) 54 | ("this" . php-this) 55 | ("->" . php-object-op) 56 | ("string" . php-property-name) 57 | (");\n }\n}\n\n(") 58 | ("new" . php-keyword) 59 | (" ") 60 | ("Typed" . font-lock-type-face) 61 | (")") 62 | ("->" . php-object-op) 63 | ("print" . php-method-call-traditional) 64 | ("();\n")) 65 | -------------------------------------------------------------------------------- /tests/8.0/attribute/class.php: -------------------------------------------------------------------------------- 1 | static::Small, 13 | $cm < 100 => static::Medium, 14 | default => static::Large, 15 | }; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/8.1/enum.php.faces: -------------------------------------------------------------------------------- 1 | ;; -*- mode: emacs-lisp -*- 2 | (("" . php-comparison-op) 57 | (" ") 58 | ("static" . php-keyword) 59 | ("::" . php-paamayim-nekudotayim) 60 | ("Small, 61 | ") 62 | ("$" . php-variable-sigil) 63 | ("cm" . php-variable-name) 64 | (" ") 65 | ("<" . php-comparison-op) 66 | (" 100 ") 67 | ("=" . php-assignment-op) 68 | (">" . php-comparison-op) 69 | (" ") 70 | ("static" . php-keyword) 71 | ("::" . php-paamayim-nekudotayim) 72 | ("Medium, 73 | ") 74 | ("default" . php-keyword) 75 | (" ") 76 | ("=" . php-assignment-op) 77 | (">" . php-comparison-op) 78 | (" ") 79 | ("static" . php-keyword) 80 | ("::" . php-paamayim-nekudotayim) 81 | ("Large, 82 | }; 83 | } 84 | } 85 | ")) 86 | -------------------------------------------------------------------------------- /tests/8.1/readonly.php: -------------------------------------------------------------------------------- 1 | $this->firstName . ' ' . $this->lastName; 8 | } 9 | 10 | // All write operations go through this hook, and the result is what is written. 11 | // Read access happens normally. 12 | public string $firstName { 13 | set => ucfirst(strtolower($value)); 14 | } 15 | 16 | // All write operations go through this hook, which has to write to the backing value itself. 17 | // Read access happens normally. 18 | public string $lastName { 19 | set { 20 | if (strlen($value) < 2) { 21 | throw new \InvalidArgumentException('Too short'); 22 | } 23 | $this->lastName = $value; 24 | } 25 | } 26 | } 27 | 28 | $p = new Person(); 29 | 30 | $p->firstName = 'peter'; 31 | print $p->firstName; // Prints "Peter" 32 | $p->lastName = 'Peterson'; 33 | print $p->fullName; // Prints "Peter Peterson" 34 | -------------------------------------------------------------------------------- /tests/8.4/property-hooks.php.faces: -------------------------------------------------------------------------------- 1 | ;; -*- mode: emacs-lisp -*- 2 | (("" . php-comparison-op) 22 | (" ") 23 | ("$" . php-this-sigil) 24 | ("this" . php-this) 25 | ("->" . php-object-op) 26 | ("firstName" . php-property-name) 27 | (" . ") 28 | ("' '" . php-string) 29 | (" . ") 30 | ("$" . php-this-sigil) 31 | ("this" . php-this) 32 | ("->" . php-object-op) 33 | ("lastName" . php-property-name) 34 | (";\n }\n\n ") 35 | ("// " . font-lock-comment-delimiter-face) 36 | ("All write operations go through this hook, and the result is what is written.\n" . font-lock-comment-face) 37 | (" ") 38 | ("// " . font-lock-comment-delimiter-face) 39 | ("Read access happens normally.\n" . font-lock-comment-face) 40 | (" ") 41 | ("public" . php-keyword) 42 | (" ") 43 | ("string" . php-class) 44 | (" ") 45 | ("$" . php-variable-sigil) 46 | ("firstName" . php-variable-name) 47 | (" {\n ") 48 | ("set" . php-builtin) 49 | (" ") 50 | ("=" . php-assignment-op) 51 | (">" . php-comparison-op) 52 | (" ") 53 | ("ucfirst" . php-function-call-traditional) 54 | ("(") 55 | ("strtolower" . php-function-call-traditional) 56 | ("(") 57 | ("$" . php-variable-sigil) 58 | ("value" . php-variable-name) 59 | ("));\n }\n\n ") 60 | ("// " . font-lock-comment-delimiter-face) 61 | ("All write operations go through this hook, which has to write to the backing value itself.\n" . font-lock-comment-face) 62 | (" ") 63 | ("// " . font-lock-comment-delimiter-face) 64 | ("Read access happens normally.\n" . font-lock-comment-face) 65 | (" ") 66 | ("public" . php-keyword) 67 | (" ") 68 | ("string" . php-class) 69 | (" ") 70 | ("$" . php-variable-sigil) 71 | ("lastName" . php-variable-name) 72 | (" {\n ") 73 | ("set" . php-builtin) 74 | (" {\n ") 75 | ("if" . php-keyword) 76 | (" (") 77 | ("strlen" . php-function-call-traditional) 78 | ("(") 79 | ("$" . php-variable-sigil) 80 | ("value" . php-variable-name) 81 | (") ") 82 | ("<" . php-comparison-op) 83 | (" 2) {\n ") 84 | ("throw" . php-keyword) 85 | (" ") 86 | ("new" . php-keyword) 87 | (" ") 88 | ("\\InvalidArgumentException" . font-lock-type-face) 89 | ("(") 90 | ("'Too short'" . php-string) 91 | (");\n }\n ") 92 | ("$" . php-this-sigil) 93 | ("this" . php-this) 94 | ("->" . php-object-op) 95 | ("lastName" . php-property-name) 96 | (" ") 97 | ("=" . php-assignment-op) 98 | (" ") 99 | ("$" . php-variable-sigil) 100 | ("value" . php-variable-name) 101 | (";\n }\n }\n}\n\n") 102 | ("$" . php-variable-sigil) 103 | ("p" . php-variable-name) 104 | (" ") 105 | ("=" . php-assignment-op) 106 | (" ") 107 | ("new" . php-keyword) 108 | (" ") 109 | ("Person" . font-lock-type-face) 110 | ("();\n\n") 111 | ("$" . php-variable-sigil) 112 | ("p" . php-variable-name) 113 | ("->" . php-object-op) 114 | ("firstName" . php-property-name) 115 | (" ") 116 | ("=" . php-assignment-op) 117 | (" ") 118 | ("'peter'" . php-string) 119 | (";\n") 120 | ("print" . php-keyword) 121 | (" ") 122 | ("$" . php-variable-sigil) 123 | ("p" . php-variable-name) 124 | ("->" . php-object-op) 125 | ("firstName" . php-property-name) 126 | ("; ") 127 | ("// " . font-lock-comment-delimiter-face) 128 | ("Prints \"Peter\"\n" . font-lock-comment-face) 129 | ("$" . php-variable-sigil) 130 | ("p" . php-variable-name) 131 | ("->" . php-object-op) 132 | ("lastName" . php-property-name) 133 | (" ") 134 | ("=" . php-assignment-op) 135 | (" ") 136 | ("'Peterson'" . php-string) 137 | (";\n") 138 | ("print" . php-keyword) 139 | (" ") 140 | ("$" . php-variable-sigil) 141 | ("p" . php-variable-name) 142 | ("->" . php-object-op) 143 | ("fullName" . php-property-name) 144 | ("; ") 145 | ("// " . font-lock-comment-delimiter-face) 146 | ("Prints \"Peter Peterson\"\n" . font-lock-comment-face)) 147 | -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | Tests 2 | ===== 3 | 4 | This directory contains tests for PHP Mode. Each test begins with a 5 | comment header explaining the purpose of the test and a link to the 6 | relative [Github issue][github]. The main purpose of these tests are 7 | to demonstrate whether or not features like syntax highlighting and 8 | indentation work properly. Because of that, executing most of the 9 | tests is not important, since we do not care about how PHP itself 10 | interprets the test scripts. We only care about how Emacs and 11 | PHP Mode formats the code within each test. 12 | 13 | Please use the file `tests/template.php` as a start when creating new 14 | tests cases. 15 | 16 | 17 | 18 | [github]: https://github.com/emacs-php/php-mode 19 | -------------------------------------------------------------------------------- /tests/arrays.php: -------------------------------------------------------------------------------- 1 | something() 6 | ->something(); // ###php-mode-test### ((indent 4)) 7 | 8 | var_dump( 9 | $object->something() // ###php-mode-test### ((indent 4)) 10 | ->something(), // ###php-mode-test### ((indent 8)) 11 | ); // ###php-mode-test### ((indent 0)) 12 | 13 | $arr = [ 14 | $object->something() // ###php-mode-test### ((indent 4)) 15 | /* comment */ ->something() // ###php-mode-test### ((indent 8)) 16 | ->something(), // ###php-mode-test### ((indent 8)) 17 | ]; // ###php-mode-test### ((indent 0)) 18 | -------------------------------------------------------------------------------- /tests/indent/issue-702.php: -------------------------------------------------------------------------------- 1 | PHP_VERSION_ID === 80000 9 | ? 'foo' 10 | : 'bar', 11 | true && 12 | false, 13 | false 14 | || true, 15 | 'value1' 16 | , 17 | 'value2' 18 | , 19 | ]; 20 | 21 | var_dump( 22 | PHP_VERSION_ID === 80000 23 | ? 'foo' 24 | : 'bar', 25 | true && // ###php-mode-test### ((indent 4)) 26 | false, 27 | false // ###php-mode-test### ((indent 4)) 28 | || true, // ###php-mode-test### ((indent 8)) 29 | // ###php-mode-test### ((indent 4)) 30 | 1 // ###php-mode-test### ((indent 4)) 31 | + 2 // ###php-mode-test### ((indent 8)) 32 | / 3, // ###php-mode-test### ((indent 8)) 33 | 'value1' // ###php-mode-test### ((indent 4)) 34 | , // ###php-mode-test### ((indent 4)) 35 | 'value2' // ###php-mode-test### ((indent 4)) 36 | , // ###php-mode-test### ((indent 4)) 37 | ); 38 | -------------------------------------------------------------------------------- /tests/indent/issue-726.php: -------------------------------------------------------------------------------- 1 | [ 4 | 'bee' => 2, 5 | ], 6 | // 'foo' => [ 7 | // 'bar' => 1, 8 | // ], 9 | // ###php-mode-test### ((indent 4)) 10 | 'lee' => 2, 11 | // 'dee' => 3 12 | 'gee' => 4, // ###php-mode-test### ((indent 4)) 13 | ]; // ###php-mode-test### ((indent 0)) 14 | -------------------------------------------------------------------------------- /tests/indent/issue-774.php: -------------------------------------------------------------------------------- 1 | someFunction("some", "parameter") // ###php-mode-test### ((indent 0)) 4 | ->someOtherFunc(23, 42) // ###php-mode-test### ((indent 4)) 5 | ->andAThirdFunction(); // ###php-mode-test### ((indent 4)) 6 | 7 | $result = DateTime::createFromFormat('Y-m-d', '2112-09-03') // ###php-mode-test### ((indent 0)) 8 | ->someFunction(); // ###php-mode-test### ((indent 4)) 9 | 10 | $pages = $dbOld->createQueryBuilder() // ###php-mode-test### ((indent 0)) 11 | ->select('*'); // ###php-mode-test### ((indent 4)) 12 | -------------------------------------------------------------------------------- /tests/indent/issue-793.php: -------------------------------------------------------------------------------- 1 | 1, // ###php-mode-test### ((indent 4)) 5 | 'bar' => 2, 6 | 7 | 'buz' => 3, // ###php-mode-test### ((indent 4)) 8 | 'buzbuz' => 4, // ###php-mode-test### ((indent 4)) 9 | ]; 10 | -------------------------------------------------------------------------------- /tests/issue-100.php: -------------------------------------------------------------------------------- 1 | ' characters. 9 | * 10 | */ 11 | 12 | $x = ["x" => $this->foo() 13 | /* | column 18 */ 14 | ->bar() // ###php-mode-test### ((indent 18)) 15 | ->baz()]; // ###php-mode-test### ((indent 18)) 16 | 17 | $y = array("y" => $this->foo() 18 | /* | column 23 */ 19 | ->bar() // ###php-mode-test### ((indent 23)) 20 | ->baz()); // ###php-mode-test### ((indent 23)) 21 | 22 | // Test the combination of arglist indentation and cascaded calls 23 | $x = ['x' => M_PI, 24 | /* | column 6 */ 25 | 'x' => 123, // ###php-mode-test### ((indent 6)) 26 | 'x' => $y->method() // ###php-mode-test### ((indent 6)) 27 | /* | column 15 */ 28 | ->method()] // ###php-mode-test### ((indent 15)) -------------------------------------------------------------------------------- /tests/issue-124.php: -------------------------------------------------------------------------------- 1 | 'bar', // ###php-mode-test### ((indent 4)) 11 | 'spam' => 'ham', // ###php-mode-test### ((indent 4)) 12 | ); 13 | 14 | $levels = array(E_USER_NOTICE => 'notice', 15 | /* | column 16 */ 16 | E_USER_WARNING => 'warning', // ###php-mode-test### ((indent 16)) 17 | E_USER_ERROR => 'error'); // ###php-mode-test### ((indent 16)) 18 | 19 | array( 'a' => 1, 20 | /* | column 7 */ 21 | 'b' => 2 ); // ###php-mode-test### ((indent 7)) 22 | -------------------------------------------------------------------------------- /tests/issue-135.php: -------------------------------------------------------------------------------- 1 | method() // ###php-mode-test### ((indent 0)) 11 | /* | column 9 */ 12 | ->chained(); // ###php-mode-test### ((indent 9)) 13 | 14 | // Test indentation of statement continuations (statement-cont) 15 | $variable 16 | ->method() // ###php-mode-test### ((indent 4)) 17 | ->method(); // ###php-mode-test### ((indent 4)) 18 | 19 | ClassName::method() 20 | ->chained(); // ###php-mode-test### ((indent 4)) 21 | 22 | // Test same behaviour inside a block 23 | function foo() { 24 | $variable->method() // ###php-mode-test### ((indent 4)) 25 | /* | column 13 */ 26 | ->chained(); // ###php-mode-test### ((indent 13)) 27 | 28 | ClassName::method() 29 | ->chained(); // ###php-mode-test### ((indent 8)) 30 | } 31 | 32 | // Test same behaviour inside an arglist 33 | foo($db->baz() 34 | /* | column 7 */ 35 | ->quux()); // ###php-mode-test### ((indent 7)) 36 | 37 | foo( 38 | $variable->method() // ###php-mode-test### ((indent 4)) 39 | /* | column 13 */ 40 | ->chained(), // ###php-mode-test### ((indent 13)) 41 | 42 | 43 | // Note that below indentation is different than when not inside 44 | // an arglist. When inside an arglist, cc-mode doesn't provide the 45 | // information that we're in a statement-cont as well. 46 | // 47 | // Future improvement: create a function like c-lineup-cascaded-calls 48 | // to have this indented like statement-cont. 49 | ClassName::method() 50 | ->chained() // ###php-mode-test### ((indent 4)) 51 | ); 52 | 53 | // Test same behaviour inside method 54 | class Test { 55 | public function test() { 56 | $variable->method() // ###php-mode-test### ((indent 8)) 57 | /* | column 17 */ 58 | ->chained(); // ###php-mode-test### ((indent 17)) 59 | 60 | ClassName::method() // ###php-mode-test### ((indent 8)) 61 | ->chained(); // ###php-mode-test### ((indent 12)) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /tests/issue-136.php: -------------------------------------------------------------------------------- 1 | name; 27 | } 28 | 29 | public function getID() 30 | { 31 | return $this->id; 32 | } 33 | } 34 | 35 | $user = new User(); 36 | $user->name = "Eric"; 37 | 38 | $users = array($user); 39 | $index = 0; 40 | 41 | ob_start(); 42 | 43 | echo "My name is $name"; 44 | echo "My name is ${name}"; 45 | echo "My name is {$name}"; 46 | echo "My name is {$user->name}"; 47 | echo "My name is {$user->getName()}"; 48 | echo "My name is {$users[0]->name}"; 49 | echo "My name is {$users[$index]->name}"; 50 | echo "My name is {$users[$user->id]->name}"; 51 | echo "My name is {$users[$user->getID()]->name}"; 52 | 53 | ob_end_clean(); 54 | -------------------------------------------------------------------------------- /tests/issue-136.php.faces: -------------------------------------------------------------------------------- 1 | ;; -*- mode: emacs-lisp -*- 2 | (("\n * " . font-lock-doc-face) 13 | ("@link" php-doc-annotation-tag font-lock-doc-face) 14 | (" https://github.com/emacs-php/php-mode\n * " . font-lock-doc-face) 15 | ("@package" php-doc-annotation-tag font-lock-doc-face) 16 | (" " . font-lock-doc-face) 17 | ("Emacs\\PHPMode" php-string font-lock-doc-face) 18 | ("\n */" . font-lock-doc-face) 19 | ("\n\n") 20 | ("// " . font-lock-comment-delimiter-face) 21 | ("one-line comment\n" . font-lock-comment-face) 22 | ("// " . font-lock-comment-delimiter-face) 23 | ("@annotation This is NOT annotation. 1\n" . font-lock-comment-face) 24 | ("\n") 25 | ("/*" . font-lock-comment-delimiter-face) 26 | ("------------------------------------------------\n Multi-line comment\n\n * @annotation This is NOT annotation. 2\n -------------------------------------------------*/" . font-lock-comment-face) 27 | ("\n\n") 28 | ("// " . font-lock-comment-delimiter-face) 29 | ("/**\n" . font-lock-comment-face) 30 | ("// " . font-lock-comment-delimiter-face) 31 | ("* Comment outed class implementation\n" . font-lock-comment-face) 32 | ("// " . font-lock-comment-delimiter-face) 33 | ("*\n" . font-lock-comment-face) 34 | ("// " . font-lock-comment-delimiter-face) 35 | ("* @annotation This is NOT annotation. 3\n" . font-lock-comment-face) 36 | ("// " . font-lock-comment-delimiter-face) 37 | ("*/\n" . font-lock-comment-face) 38 | ("// " . font-lock-comment-delimiter-face) 39 | ("class CommentOuted\n" . font-lock-comment-face) 40 | ("// " . font-lock-comment-delimiter-face) 41 | ("{\n" . font-lock-comment-face) 42 | ("// " . font-lock-comment-delimiter-face) 43 | ("}\n" . font-lock-comment-face) 44 | ("\n") 45 | ("/**\n * Class level doc-comment\n *\n * Description " . font-lock-doc-face) 46 | ("{@internal " php-doc-annotation-tag font-lock-doc-face) 47 | ("Description" php-string php-doc-annotation-tag font-lock-doc-face) 48 | ("}" php-doc-annotation-tag font-lock-doc-face) 49 | (" inline tag.\n *\n * " . font-lock-doc-face) 50 | ("@property-read" php-doc-annotation-tag font-lock-doc-face) 51 | (" " . font-lock-doc-face) 52 | ("string" font-lock-type-face php-string font-lock-doc-face) 53 | ("[]" php-string font-lock-doc-face) 54 | (" " . font-lock-doc-face) 55 | ("$" php-doc-variable-sigil font-lock-doc-face) 56 | ("name" php-variable-name font-lock-doc-face) 57 | ("\n * " . font-lock-doc-face) 58 | ("@ORM\\Table" php-doc-annotation-tag font-lock-doc-face) 59 | ("(name=\"majormodes\")\n * " . font-lock-doc-face) 60 | ("@ORM\\Entity" php-doc-annotation-tag font-lock-doc-face) 61 | ("(repositoryClass=\"Emacs\\Repository\\MajorModeRepository\")\n */" . font-lock-doc-face) 62 | ("\n") 63 | ("final" . php-keyword) 64 | (" ") 65 | ("class" . php-class-declaration) 66 | (" ") 67 | ("SampleClass" . font-lock-type-face) 68 | ("\n{\n ") 69 | ("/** Const doc-comment */" . font-lock-doc-face) 70 | ("\n ") 71 | ("const" . php-keyword) 72 | (" ") 73 | ("SAMPLE" . font-lock-type-face) 74 | (" = ") 75 | ("'SAMPLE'" . php-string) 76 | (";\n ") 77 | ("/** " . font-lock-doc-face) 78 | ("@var" php-doc-annotation-tag font-lock-doc-face) 79 | (" " . font-lock-doc-face) 80 | ("string" font-lock-type-face php-string font-lock-doc-face) 81 | (" sample property doc-comment */" . font-lock-doc-face) 82 | ("\n ") 83 | ("private" . php-keyword) 84 | (" ") 85 | ("$" . php-variable-sigil) 86 | ("name" . php-variable-name) 87 | (";\n\n ") 88 | ("/**\n * " . font-lock-doc-face) 89 | ("@param" php-doc-annotation-tag font-lock-doc-face) 90 | (" " . font-lock-doc-face) 91 | ("string" font-lock-type-face php-string font-lock-doc-face) 92 | (" " . font-lock-doc-face) 93 | ("$" php-doc-variable-sigil font-lock-doc-face) 94 | ("name" php-variable-name font-lock-doc-face) 95 | ("\n */" . font-lock-doc-face) 96 | ("\n ") 97 | ("public" . php-keyword) 98 | (" ") 99 | ("function" . php-keyword) 100 | (" ") 101 | ("__construct" . php-function-name) 102 | ("(") 103 | ("$" . php-variable-sigil) 104 | ("name" . php-variable-name) 105 | (")\n {\n ") 106 | ("$" . php-this-sigil) 107 | ("this" . php-this) 108 | ("->" . php-object-op) 109 | ("name" . php-property-name) 110 | (" = ") 111 | ("$" . php-variable-sigil) 112 | ("name" . php-variable-name) 113 | ("; ") 114 | ("// " . font-lock-comment-delimiter-face) 115 | ("comment in after code\n" . font-lock-comment-face) 116 | ("\n ") 117 | ("/** " . font-lock-doc-face) 118 | ("@var" php-doc-annotation-tag font-lock-doc-face) 119 | (" " . font-lock-doc-face) 120 | ("string" font-lock-type-face php-string font-lock-doc-face) 121 | ("|" php-string font-lock-doc-face) 122 | ("bool" font-lock-type-face php-string font-lock-doc-face) 123 | ("|" php-string font-lock-doc-face) 124 | ("array" font-lock-type-face php-string font-lock-doc-face) 125 | ("[]|ArrayObject" php-string font-lock-doc-face) 126 | (" */" . font-lock-doc-face) 127 | ("\n ") 128 | ("$" . php-variable-sigil) 129 | ("foo" . php-variable-name) 130 | (" = hoge();\n\n ") 131 | ("// " . font-lock-comment-delimiter-face) 132 | ("one-line comment\n" . font-lock-comment-face) 133 | (" ") 134 | ("// " . font-lock-comment-delimiter-face) 135 | ("@annotation This is NOT annotation. 4\n" . font-lock-comment-face) 136 | ("\n ") 137 | ("/** " . font-lock-doc-face) 138 | ("@var" php-doc-annotation-tag font-lock-doc-face) 139 | (" " . font-lock-doc-face) 140 | ("int" font-lock-type-face php-string font-lock-doc-face) 141 | (" internal linter variable */" . font-lock-doc-face) 142 | ("\n ") 143 | ("$" . php-variable-sigil) 144 | ("offset" . php-variable-name) 145 | (" = 0;\n }\n\n ") 146 | ("/**\n * Summary\n *\n * " . font-lock-doc-face) 147 | ("@throws" php-doc-annotation-tag font-lock-doc-face) 148 | (" " . font-lock-doc-face) 149 | ("\\RuntimeException" php-string font-lock-doc-face) 150 | ("\n */" . font-lock-doc-face) 151 | ("\n ") 152 | ("public" . php-keyword) 153 | (" ") 154 | ("function" . php-keyword) 155 | (" ") 156 | ("test" . php-function-name) 157 | ("()\n {\n ") 158 | ("throw" . php-keyword) 159 | (" ") 160 | ("new" . php-keyword) 161 | (" ") 162 | ("\\RuntimeException" . font-lock-type-face) 163 | (";\n }\n}\n")) 164 | -------------------------------------------------------------------------------- /tests/issue-14.php: -------------------------------------------------------------------------------- 1 | find(array( 10 | * 'select' => 'title', 11 | * 'condition' => 'postID=:postID', 12 | * 'params' => array(':postID'=>10), 13 | * )); 14 | * 15 | */ 16 | 17 | $post = Post::model()->find(array( 18 | 'select' => 'title', // ###php-mode-test### ((indent c-basic-offset)) 19 | 'condition' => 'postID=:postID', // ###php-mode-test### ((indent c-basic-offset)) 20 | 'params' => array(':postID'=>10), // ###php-mode-test### ((indent c-basic-offset)) 21 | )); // ###php-mode-test### ((indent 0)) -------------------------------------------------------------------------------- /tests/issue-144.php: -------------------------------------------------------------------------------- 1 | 16 | -------------------------------------------------------------------------------- /tests/issue-145.php: -------------------------------------------------------------------------------- 1 | $value) {} 12 | 13 | class Test { 14 | use TestTrait { test as protected; } 15 | } 16 | -------------------------------------------------------------------------------- /tests/issue-18.php: -------------------------------------------------------------------------------- 1 | 16 | html; 17 | 18 | return; 19 | } -------------------------------------------------------------------------------- /tests/issue-186.php: -------------------------------------------------------------------------------- 1 | ' operators aligned: 8 | * 9 | * $object = new SomeClass(); 10 | * $object->method() 11 | * ->another(); 12 | * 13 | * Alignment should occur on the '->' characters regardless of the 14 | * scope in which the method calls appear. 15 | */ 16 | 17 | $object = new StdClass(); 18 | $object->call() 19 | ->something(); 20 | 21 | class Whatever 22 | { 23 | public function __construct() 24 | { 25 | $object = new StdClass(); 26 | $object->call() 27 | ->something(); 28 | } 29 | 30 | public function something() 31 | { 32 | $object = new StdClass(); 33 | $object->call() 34 | ->something(); 35 | } 36 | } 37 | 38 | $closure = function() { 39 | $object = new StdClass(); 40 | $object->call() 41 | ->something(); 42 | }; 43 | 44 | function something() 45 | { 46 | $object = new StdClass(); 47 | $object->call() 48 | ->something(); 49 | } 50 | -------------------------------------------------------------------------------- /tests/issue-197.php: -------------------------------------------------------------------------------- 1 | array; 10 | $test->int; 11 | $test->string; 12 | $test->int(); 13 | $test->string(); 14 | -------------------------------------------------------------------------------- /tests/issue-197.php.faces: -------------------------------------------------------------------------------- 1 | ;; -*- mode: emacs-lisp -*- 2 | (("" . php-object-op) 9 | ("array" . php-property-name) 10 | (";\n") 11 | ("$" . php-variable-sigil) 12 | ("test" . php-variable-name) 13 | ("->" . php-object-op) 14 | ("int" . php-property-name) 15 | (";\n") 16 | ("$" . php-variable-sigil) 17 | ("test" . php-variable-name) 18 | ("->" . php-object-op) 19 | ("string" . php-property-name) 20 | (";\n") 21 | ("$" . php-variable-sigil) 22 | ("test" . php-variable-name) 23 | ("->" . php-object-op) 24 | ("int" . php-method-call-traditional) 25 | ("();\n") 26 | ("$" . php-variable-sigil) 27 | ("test" . php-variable-name) 28 | ("->" . php-object-op) 29 | ("string" . php-method-call-traditional) 30 | ("();\n")) 31 | -------------------------------------------------------------------------------- /tests/issue-200.php: -------------------------------------------------------------------------------- 1 | di->get('provider') 10 | ->filterByLanguage('en'); // ###php-mode-test### ((indent c-basic-offset)) 11 | 12 | function foo() { 13 | if (true) { 14 | $provider = $this->di->get('provier') 15 | ->filterByLanguage('en'); // ###php-mode-test### ((indent (+ c-basic-offset 8))) 16 | } 17 | } -------------------------------------------------------------------------------- /tests/issue-253.php: -------------------------------------------------------------------------------- 1 | x = $x; 12 | } 13 | 14 | $STRING = '\'\'\''; 15 | 16 | function b($x = null) { 17 | $this->x = $x; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/issue-259.php: -------------------------------------------------------------------------------- 1 | /** 2 | * GitHub Issue: https://github.com/emacs-php/php-mode/issues/259 3 | * 4 | * This code shows how writing a closure which imports external 5 | * variables with the `use` keyword causes php-mode to incorrectly 6 | * indent one level deeper when the closure is used as the actual 7 | * parameter of another function. 8 | * 9 | * Expected indentation: 10 | * 11 | * $foo(function($par1, $par2) use ($ext) { 12 | * return $par1 + $par2 + $ext; 13 | * }); 14 | */ 15 | 16 | $foo(function($par1, $par2) use ($ext) { 17 | return $par1 + $par2 + $ext; 18 | }); 19 | 20 | array_map(function($par1, $par2) use ($ext) { 21 | return $par1 + $par2 + $ext; 22 | }, $foo); 23 | 24 | 25 | class Foo 26 | { 27 | protected function foo() 28 | { 29 | $foo(function($par1, $par2) use ($ext) { 30 | return $par1 + $par2 + $ext; 31 | }); 32 | 33 | array_map(function($par1, $par2) use ($ext) { 34 | return $par1 + $par2 + $ext; 35 | }, $foo); 36 | } 37 | } 38 | 39 | function foo() { 40 | $foo(function($par1, $par2) use ($ext) { 41 | return $par1 + $par2 + $ext; 42 | }); 43 | 44 | array_map(function($par1, $par2) use ($ext) { 45 | return $par1 + $par2 + $ext; 46 | }, $foo); 47 | } 48 | -------------------------------------------------------------------------------- /tests/issue-27.php: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | get("/index", function() { 9 | * $app->redirect("foo"); 10 | * }); 11 | * 12 | */ 13 | 14 | $app->get("/index", function() { 15 | $app->redirect("foo"); // ###php-mode-test### ((indent c-basic-offset)) 16 | }); // ###php-mode-test### ((indent 0)) 17 | -------------------------------------------------------------------------------- /tests/issue-305.php: -------------------------------------------------------------------------------- 1 | set('config', function () use ($config) { 13 | return $config; 14 | }); 15 | 16 | $di->set('logger', function() use ($config) { 17 | $filename = date('Ymd'); 18 | $logger = new \Logger($config->application->logger->dir . $filename); 19 | $logger->setFormat($config->application->logger->format); 20 | return $logger; 21 | }); 22 | -------------------------------------------------------------------------------- /tests/issue-439.php: -------------------------------------------------------------------------------- 1 | 2 | /** GitHub Issue: https://github.com/emacs-php/php-mode/issues/443 */ 3 | 4 | 5 | 6 | <% echo "obsolete ASP tags" %> 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/issue-443.php.27.faces: -------------------------------------------------------------------------------- 1 | ;; -*- mode: emacs-lisp -*- 2 | (("" . php-php-tag) 10 | ("\n") 11 | ("/** GitHub Issue: https://github.com/emacs-php/php-mode/issues/443 */" . font-lock-doc-face) 12 | ("\n") 13 | ("" . php-php-tag) 22 | ("\n") 23 | ("" . php-php-tag) 30 | ("\n") 31 | ("" . php-php-tag) 38 | ("\n") 39 | ("<%" . php-php-tag) 40 | (" ") 41 | ("echo" . php-keyword) 42 | (" ") 43 | ("\"obsolete ASP tags\"" . php-string) 44 | (" ") 45 | ("%>" . php-php-tag) 46 | ("\n") 47 | ("" . php-php-tag) 52 | ("\n") 53 | ("" . php-php-tag) 58 | ("\n") 59 | ("" . php-php-tag) 70 | ("\n") 71 | ("" . php-php-tag) 81 | ("\n")) 82 | -------------------------------------------------------------------------------- /tests/issue-443.php.faces: -------------------------------------------------------------------------------- 1 | ;; -*- mode: emacs-lisp -*- 2 | (("" . php-php-tag) 10 | ("\n") 11 | ("/** GitHub Issue: https://github.com/emacs-php/php-mode/issues/443 */" . font-lock-doc-face) 12 | ("\n") 13 | ("" . php-php-tag) 22 | ("\n") 23 | ("" . php-php-tag) 30 | ("\n") 31 | ("" . php-php-tag) 38 | ("\n") 39 | ("<%" . php-php-tag) 40 | (" ") 41 | ("echo" . php-keyword) 42 | (" ") 43 | ("\"obsolete ASP tags\"" . php-string) 44 | (" ") 45 | ("%>" . php-php-tag) 46 | ("\n") 47 | ("" . php-php-tag) 52 | ("\n") 53 | ("" . php-php-tag) 58 | ("\n") 59 | ("" . php-php-tag) 69 | ("\n") 70 | ("" . php-php-tag) 79 | ("\n")) 80 | -------------------------------------------------------------------------------- /tests/issue-503.php: -------------------------------------------------------------------------------- 1 | bar = $bar; 20 | } 21 | 22 | public function getBar() { 23 | // here is the whitespace 24 | return $this->bar; 25 | } 26 | 27 | } 28 | 29 | $foo = new Foo('bar'); 30 | $bar = $foo->getBar(); 31 | -------------------------------------------------------------------------------- /tests/issue-66-bracket-namespace.php: -------------------------------------------------------------------------------- 1 | 25 | -------------------------------------------------------------------------------- /tests/issue-66-multi-namespace.php: -------------------------------------------------------------------------------- 1 | 22 | -------------------------------------------------------------------------------- /tests/issue-66-namespace.php: -------------------------------------------------------------------------------- 1 | call() 21 | ->something(); 22 | } 23 | } 24 | // place code here 25 | 26 | } // end of namespace foo\bar 27 | 28 | namespace another\bar; 29 | use my\space\MyClass; 30 | use my\space\AnotherClass; 31 | { 32 | $more = "other"; 33 | 34 | } // end of namespace another\bar 35 | ?> -------------------------------------------------------------------------------- /tests/issue-66.php: -------------------------------------------------------------------------------- 1 | getMessage(), "\n"; 25 | } 26 | 27 | // http://www.php.net/manual/en/functions.anonymous.php 28 | 29 | $greet = function($name) 30 | { 31 | printf("Hello %s\r\n", $name); 32 | }; 33 | 34 | $greet('World'); 35 | $greet('PHP'); -------------------------------------------------------------------------------- /tests/issue-68.php: -------------------------------------------------------------------------------- 1 | 'mat_replica')); 26 | } catch (\MongoConnectionException $e) { 27 | throw $e; 28 | } catch (\Exception $e) { 29 | throw $e; 30 | } 31 | 32 | /* CC Mode uses the indentation syntax for 'topmost-intro' for the 33 | * 'catch' keywords in the remaining tests. 34 | */ 35 | 36 | try { 37 | $mongo = new \Mongo($dsn, array("replicaSet" => 'mat_replica')); 38 | } 39 | catch (\MongoConnectionException $e) { 40 | throw $e; 41 | } 42 | catch (\Exception $e) { 43 | throw $e; 44 | } 45 | 46 | try 47 | { 48 | $mongo = new \Mongo($dsn, array("replicaSet" => 'mat_replica')); 49 | } 50 | catch (\MongoConnectionException $e) 51 | { 52 | throw $e; 53 | } 54 | catch (\Exception $e) 55 | { 56 | throw $e; 57 | } 58 | -------------------------------------------------------------------------------- /tests/issue-73.php: -------------------------------------------------------------------------------- 1 | ' amd '::' and after '->' and 9 | * '::'. 10 | */ 11 | 12 | # Correct 13 | TEST::di->set('config', function () use ($config); 14 | 15 | # Test 16 | TEST 17 | :: 18 | di->set('config', function () use ($config); 19 | 20 | # Test 21 | TEST::di 22 | -> 23 | set('config', function () use ($config); 24 | 25 | # Test 26 | TEST::di->set('config' 27 | , function () use ($config); 28 | 29 | # Test 30 | TEST::di->set('config', function () use ($config) 31 | ; 32 | -------------------------------------------------------------------------------- /tests/issue-83.php: -------------------------------------------------------------------------------- 1 | tag should match the highlighting of its opening tag. 13 | */ 14 | 15 | ?> 16 | We'll go there -------------------------------------------------------------------------------- /tests/issue-99.php: -------------------------------------------------------------------------------- 1 | 10 | * @link https://github.com/emacs-php/php-mode 11 | * @package Emacs\PHPMode 12 | */ 13 | 14 | // one-line comment 15 | // @annotation This is NOT annotation. 1 16 | 17 | /*------------------------------------------------ 18 | Multi-line comment 19 | 20 | * @annotation This is NOT annotation. 2 21 | -------------------------------------------------*/ 22 | 23 | // /** 24 | // * Comment outed class implementation 25 | // * 26 | // * @annotation This is NOT annotation. 3 27 | // */ 28 | // class CommentOuted 29 | // { 30 | // } 31 | 32 | /** 33 | * Class level doc-comment 34 | * 35 | * Description {@internal Description} inline tag. 36 | * 37 | * @property-read string[] $name 38 | * @ORM\Table(name="majormodes") 39 | * @ORM\Entity(repositoryClass="Emacs\Repository\MajorModeRepository") 40 | */ 41 | final class SampleClass 42 | { 43 | /** Const doc-comment */ 44 | const SAMPLE = 'SAMPLE'; 45 | /** @var string sample property doc-comment */ 46 | private $name; 47 | 48 | /** 49 | * @param string $name 50 | */ 51 | public function __construct($name) 52 | { 53 | $this->name = $name; // comment in after code 54 | 55 | /** @var string|bool|array[]|ArrayObject */ 56 | $foo = hoge(); 57 | 58 | // one-line comment 59 | // @annotation This is NOT annotation. 4 60 | 61 | /** @var int internal linter variable */ 62 | $offset = 0; 63 | } 64 | 65 | /** 66 | * Summary 67 | * 68 | * @throws \RuntimeException 69 | */ 70 | public function test() 71 | { 72 | throw new \RuntimeException; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /tests/lang/doc-comment/comments.php.24.faces: -------------------------------------------------------------------------------- 1 | ;; -*- mode: emacs-lisp -*- 2 | (("\n * " . font-lock-doc-face) 13 | ("@link" php-doc-annotation-tag font-lock-doc-face) 14 | (" https://github.com/emacs-php/php-mode\n * " . font-lock-doc-face) 15 | ("@package" php-doc-annotation-tag font-lock-doc-face) 16 | (" " . font-lock-doc-face) 17 | ("Emacs\\PHPMode" php-string font-lock-doc-face) 18 | ("\n */" . font-lock-doc-face) 19 | ("\n\n") 20 | ("// " . font-lock-comment-delimiter-face) 21 | ("one-line comment\n" . font-lock-comment-face) 22 | ("// " . font-lock-comment-delimiter-face) 23 | ("@annotation This is NOT annotation. 1\n" . font-lock-comment-face) 24 | ("\n") 25 | ("/*" . font-lock-comment-delimiter-face) 26 | ("------------------------------------------------\n Multi-line comment\n\n * @annotation This is NOT annotation. 2\n -------------------------------------------------*/" . font-lock-comment-face) 27 | ("\n\n") 28 | ("// " . font-lock-comment-delimiter-face) 29 | ("/**\n" . font-lock-comment-face) 30 | ("// " . font-lock-comment-delimiter-face) 31 | ("* Comment outed class implementation\n" . font-lock-comment-face) 32 | ("// " . font-lock-comment-delimiter-face) 33 | ("*\n" . font-lock-comment-face) 34 | ("// " . font-lock-comment-delimiter-face) 35 | ("* @annotation This is NOT annotation. 3\n" . font-lock-comment-face) 36 | ("// " . font-lock-comment-delimiter-face) 37 | ("*/\n" . font-lock-comment-face) 38 | ("// " . font-lock-comment-delimiter-face) 39 | ("class CommentOuted\n" . font-lock-comment-face) 40 | ("// " . font-lock-comment-delimiter-face) 41 | ("{\n" . font-lock-comment-face) 42 | ("// " . font-lock-comment-delimiter-face) 43 | ("}\n" . font-lock-comment-face) 44 | ("\n") 45 | ("/**\n * Class level doc-comment\n *\n * Description " . font-lock-doc-face) 46 | ("{@internal " php-doc-annotation-tag font-lock-doc-face) 47 | ("Description" php-string php-doc-annotation-tag font-lock-doc-face) 48 | ("}" php-doc-annotation-tag font-lock-doc-face) 49 | (" inline tag.\n *\n * " . font-lock-doc-face) 50 | ("@property-read" php-doc-annotation-tag font-lock-doc-face) 51 | (" " . font-lock-doc-face) 52 | ("string" font-lock-type-face php-string font-lock-doc-face) 53 | ("[]" php-string font-lock-doc-face) 54 | (" " . font-lock-doc-face) 55 | ("$" php-doc-variable-sigil font-lock-doc-face) 56 | ("name" php-variable-name font-lock-doc-face) 57 | ("\n * " . font-lock-doc-face) 58 | ("@ORM\\Table" php-doc-annotation-tag font-lock-doc-face) 59 | ("(name=\"majormodes\")\n * " . font-lock-doc-face) 60 | ("@ORM\\Entity" php-doc-annotation-tag font-lock-doc-face) 61 | ("(repositoryClass=\"Emacs\\Repository\\MajorModeRepository\")\n */" . font-lock-doc-face) 62 | ("\n") 63 | ("final" . php-class-modifier) 64 | (" ") 65 | ("class" . php-class-declaration) 66 | (" ") 67 | ("SampleClass" . font-lock-type-face) 68 | ("\n{\n ") 69 | ("/** Const doc-comment */" . font-lock-doc-face) 70 | ("\n ") 71 | ("const" . php-keyword) 72 | (" ") 73 | ("SAMPLE" . php-constant-assign) 74 | (" ") 75 | ("=" . php-assignment-op) 76 | (" ") 77 | ("'SAMPLE'" . php-string) 78 | (";\n ") 79 | ("/** " . font-lock-doc-face) 80 | ("@var" php-doc-annotation-tag font-lock-doc-face) 81 | (" " . font-lock-doc-face) 82 | ("string" font-lock-type-face php-string font-lock-doc-face) 83 | (" sample property doc-comment */" . font-lock-doc-face) 84 | ("\n ") 85 | ("private" . php-keyword) 86 | (" ") 87 | ("$" . php-variable-sigil) 88 | ("name" . php-variable-name) 89 | (";\n\n ") 90 | ("/**\n * " . font-lock-doc-face) 91 | ("@param" php-doc-annotation-tag font-lock-doc-face) 92 | (" " . font-lock-doc-face) 93 | ("string" font-lock-type-face php-string font-lock-doc-face) 94 | (" " . font-lock-doc-face) 95 | ("$" php-doc-variable-sigil font-lock-doc-face) 96 | ("name" php-variable-name font-lock-doc-face) 97 | ("\n */" . font-lock-doc-face) 98 | ("\n ") 99 | ("public" . php-keyword) 100 | (" ") 101 | ("function" . php-keyword) 102 | (" ") 103 | ("__construct" . php-function-name) 104 | ("(") 105 | ("$" . php-variable-sigil) 106 | ("name" . php-variable-name) 107 | (")\n {\n ") 108 | ("$" . php-this-sigil) 109 | ("this" . php-this) 110 | ("->" . php-object-op) 111 | ("name" . php-property-name) 112 | (" ") 113 | ("=" . php-assignment-op) 114 | (" ") 115 | ("$" . php-variable-sigil) 116 | ("name" . php-variable-name) 117 | ("; ") 118 | ("// " . font-lock-comment-delimiter-face) 119 | ("comment in after code\n" . font-lock-comment-face) 120 | ("\n ") 121 | ("/** " . font-lock-doc-face) 122 | ("@var" php-doc-annotation-tag font-lock-doc-face) 123 | (" " . font-lock-doc-face) 124 | ("string" font-lock-type-face php-string font-lock-doc-face) 125 | ("|" php-string font-lock-doc-face) 126 | ("bool" font-lock-type-face php-string font-lock-doc-face) 127 | ("|" php-string font-lock-doc-face) 128 | ("array" font-lock-type-face php-string font-lock-doc-face) 129 | ("[]|ArrayObject" php-string font-lock-doc-face) 130 | (" */" . font-lock-doc-face) 131 | ("\n ") 132 | ("$" . php-variable-sigil) 133 | ("foo" . php-variable-name) 134 | (" ") 135 | ("=" . php-assignment-op) 136 | (" ") 137 | ("hoge" . php-function-call-traditional) 138 | ("();\n\n ") 139 | ("// " . font-lock-comment-delimiter-face) 140 | ("one-line comment\n" . font-lock-comment-face) 141 | (" ") 142 | ("// " . font-lock-comment-delimiter-face) 143 | ("@annotation This is NOT annotation. 4\n" . font-lock-comment-face) 144 | ("\n ") 145 | ("/** " . font-lock-doc-face) 146 | ("@var" php-doc-annotation-tag font-lock-doc-face) 147 | (" " . font-lock-doc-face) 148 | ("int" font-lock-type-face php-string font-lock-doc-face) 149 | (" internal linter variable */" . font-lock-doc-face) 150 | ("\n ") 151 | ("$" . php-variable-sigil) 152 | ("offset" . php-variable-name) 153 | (" ") 154 | ("=" . php-assignment-op) 155 | (" 0;\n }\n\n ") 156 | ("/**\n * Summary\n *\n * " . font-lock-doc-face) 157 | ("@throws" php-doc-annotation-tag font-lock-doc-face) 158 | (" " . font-lock-doc-face) 159 | ("\\RuntimeException" php-string font-lock-doc-face) 160 | ("\n */" . font-lock-doc-face) 161 | ("\n ") 162 | ("public" . php-keyword) 163 | (" ") 164 | ("function" . php-keyword) 165 | (" ") 166 | ("test" . php-function-name) 167 | ("()\n {\n ") 168 | ("throw" . php-keyword) 169 | (" ") 170 | ("new" . php-keyword) 171 | (" ") 172 | ("\\RuntimeException" . font-lock-type-face) 173 | (";\n }\n}\n")) 174 | -------------------------------------------------------------------------------- /tests/lang/doc-comment/comments.php.27.faces: -------------------------------------------------------------------------------- 1 | ;; -*- mode: emacs-lisp -*- 2 | (("\n * " . font-lock-doc-face) 13 | ("@link" php-doc-annotation-tag font-lock-doc-face) 14 | (" https://github.com/emacs-php/php-mode\n * " . font-lock-doc-face) 15 | ("@package" php-doc-annotation-tag font-lock-doc-face) 16 | (" " . font-lock-doc-face) 17 | ("Emacs\\PHPMode" php-string font-lock-doc-face) 18 | ("\n */" . font-lock-doc-face) 19 | ("\n\n") 20 | ("// " . font-lock-comment-delimiter-face) 21 | ("one-line comment\n" . font-lock-comment-face) 22 | ("// " . font-lock-comment-delimiter-face) 23 | ("@annotation This is NOT annotation. 1\n" . font-lock-comment-face) 24 | ("\n") 25 | ("/*" . font-lock-comment-delimiter-face) 26 | ("------------------------------------------------\n Multi-line comment\n\n * @annotation This is NOT annotation. 2\n -------------------------------------------------" . font-lock-comment-face) 27 | ("*/" . font-lock-comment-delimiter-face) 28 | ("\n\n") 29 | ("// " . font-lock-comment-delimiter-face) 30 | ("/**\n" . font-lock-comment-face) 31 | ("// " . font-lock-comment-delimiter-face) 32 | ("* Comment outed class implementation\n" . font-lock-comment-face) 33 | ("// " . font-lock-comment-delimiter-face) 34 | ("*\n" . font-lock-comment-face) 35 | ("// " . font-lock-comment-delimiter-face) 36 | ("* @annotation This is NOT annotation. 3\n" . font-lock-comment-face) 37 | ("// " . font-lock-comment-delimiter-face) 38 | ("*/\n" . font-lock-comment-face) 39 | ("// " . font-lock-comment-delimiter-face) 40 | ("class CommentOuted\n" . font-lock-comment-face) 41 | ("// " . font-lock-comment-delimiter-face) 42 | ("{\n" . font-lock-comment-face) 43 | ("// " . font-lock-comment-delimiter-face) 44 | ("}\n" . font-lock-comment-face) 45 | ("\n") 46 | ("/**\n * Class level doc-comment\n *\n * Description " . font-lock-doc-face) 47 | ("{@internal " php-doc-annotation-tag font-lock-doc-face) 48 | ("Description" php-string php-doc-annotation-tag font-lock-doc-face) 49 | ("}" php-doc-annotation-tag font-lock-doc-face) 50 | (" inline tag.\n *\n * " . font-lock-doc-face) 51 | ("@property-read" php-doc-annotation-tag font-lock-doc-face) 52 | (" " . font-lock-doc-face) 53 | ("string" font-lock-type-face php-string font-lock-doc-face) 54 | ("[]" php-string font-lock-doc-face) 55 | (" " . font-lock-doc-face) 56 | ("$" php-doc-variable-sigil font-lock-doc-face) 57 | ("name" php-variable-name font-lock-doc-face) 58 | ("\n * " . font-lock-doc-face) 59 | ("@ORM\\Table" php-doc-annotation-tag font-lock-doc-face) 60 | ("(name=\"majormodes\")\n * " . font-lock-doc-face) 61 | ("@ORM\\Entity" php-doc-annotation-tag font-lock-doc-face) 62 | ("(repositoryClass=\"Emacs\\Repository\\MajorModeRepository\")\n */" . font-lock-doc-face) 63 | ("\n") 64 | ("final" . php-class-modifier) 65 | (" ") 66 | ("class" . php-class-declaration) 67 | (" ") 68 | ("SampleClass" . font-lock-type-face) 69 | ("\n{\n ") 70 | ("/** Const doc-comment */" . font-lock-doc-face) 71 | ("\n ") 72 | ("const" . php-keyword) 73 | (" ") 74 | ("SAMPLE" . php-constant-assign) 75 | (" ") 76 | ("=" . php-assignment-op) 77 | (" ") 78 | ("'SAMPLE'" . php-string) 79 | (";\n ") 80 | ("/** " . font-lock-doc-face) 81 | ("@var" php-doc-annotation-tag font-lock-doc-face) 82 | (" " . font-lock-doc-face) 83 | ("string" font-lock-type-face php-string font-lock-doc-face) 84 | (" sample property doc-comment */" . font-lock-doc-face) 85 | ("\n ") 86 | ("private" . php-keyword) 87 | (" ") 88 | ("$" . php-variable-sigil) 89 | ("name" . php-variable-name) 90 | (";\n\n ") 91 | ("/**\n * " . font-lock-doc-face) 92 | ("@param" php-doc-annotation-tag font-lock-doc-face) 93 | (" " . font-lock-doc-face) 94 | ("string" font-lock-type-face php-string font-lock-doc-face) 95 | (" " . font-lock-doc-face) 96 | ("$" php-doc-variable-sigil font-lock-doc-face) 97 | ("name" php-variable-name font-lock-doc-face) 98 | ("\n */" . font-lock-doc-face) 99 | ("\n ") 100 | ("public" . php-keyword) 101 | (" ") 102 | ("function" . php-keyword) 103 | (" ") 104 | ("__construct" . php-function-name) 105 | ("(") 106 | ("$" . php-variable-sigil) 107 | ("name" . php-variable-name) 108 | (")\n {\n ") 109 | ("$" . php-this-sigil) 110 | ("this" . php-this) 111 | ("->" . php-object-op) 112 | ("name" . php-property-name) 113 | (" ") 114 | ("=" . php-assignment-op) 115 | (" ") 116 | ("$" . php-variable-sigil) 117 | ("name" . php-variable-name) 118 | ("; ") 119 | ("// " . font-lock-comment-delimiter-face) 120 | ("comment in after code\n" . font-lock-comment-face) 121 | ("\n ") 122 | ("/** " . font-lock-doc-face) 123 | ("@var" php-doc-annotation-tag font-lock-doc-face) 124 | (" " . font-lock-doc-face) 125 | ("string" font-lock-type-face php-string font-lock-doc-face) 126 | ("|" php-string font-lock-doc-face) 127 | ("bool" font-lock-type-face php-string font-lock-doc-face) 128 | ("|" php-string font-lock-doc-face) 129 | ("array" font-lock-type-face php-string font-lock-doc-face) 130 | ("[]|ArrayObject" php-string font-lock-doc-face) 131 | (" */" . font-lock-doc-face) 132 | ("\n ") 133 | ("$" . php-variable-sigil) 134 | ("foo" . php-variable-name) 135 | (" ") 136 | ("=" . php-assignment-op) 137 | (" ") 138 | ("hoge" . php-function-call-traditional) 139 | ("();\n\n ") 140 | ("// " . font-lock-comment-delimiter-face) 141 | ("one-line comment\n" . font-lock-comment-face) 142 | (" ") 143 | ("// " . font-lock-comment-delimiter-face) 144 | ("@annotation This is NOT annotation. 4\n" . font-lock-comment-face) 145 | ("\n ") 146 | ("/** " . font-lock-doc-face) 147 | ("@var" php-doc-annotation-tag font-lock-doc-face) 148 | (" " . font-lock-doc-face) 149 | ("int" font-lock-type-face php-string font-lock-doc-face) 150 | (" internal linter variable */" . font-lock-doc-face) 151 | ("\n ") 152 | ("$" . php-variable-sigil) 153 | ("offset" . php-variable-name) 154 | (" ") 155 | ("=" . php-assignment-op) 156 | (" 0;\n }\n\n ") 157 | ("/**\n * Summary\n *\n * " . font-lock-doc-face) 158 | ("@throws" php-doc-annotation-tag font-lock-doc-face) 159 | (" " . font-lock-doc-face) 160 | ("\\RuntimeException" php-string font-lock-doc-face) 161 | ("\n */" . font-lock-doc-face) 162 | ("\n ") 163 | ("public" . php-keyword) 164 | (" ") 165 | ("function" . php-keyword) 166 | (" ") 167 | ("test" . php-function-name) 168 | ("()\n {\n ") 169 | ("throw" . php-keyword) 170 | (" ") 171 | ("new" . php-keyword) 172 | (" ") 173 | ("\\RuntimeException" . font-lock-type-face) 174 | (";\n }\n}\n")) 175 | -------------------------------------------------------------------------------- /tests/lang/doc-comment/comments.php.faces: -------------------------------------------------------------------------------- 1 | ;; -*- mode: emacs-lisp -*- 2 | (("\n * " . font-lock-doc-face) 13 | ("@link" php-doc-annotation-tag font-lock-doc-face) 14 | (" https://github.com/emacs-php/php-mode\n * " . font-lock-doc-face) 15 | ("@package" php-doc-annotation-tag font-lock-doc-face) 16 | (" " . font-lock-doc-face) 17 | ("Emacs\\PHPMode" php-string font-lock-doc-face) 18 | ("\n */" . font-lock-doc-face) 19 | ("\n\n") 20 | ("// " . font-lock-comment-delimiter-face) 21 | ("one-line comment\n" . font-lock-comment-face) 22 | ("// " . font-lock-comment-delimiter-face) 23 | ("@annotation This is NOT annotation. 1\n" . font-lock-comment-face) 24 | ("\n") 25 | ("/*" . font-lock-comment-delimiter-face) 26 | ("------------------------------------------------\n Multi-line comment\n\n * @annotation This is NOT annotation. 2\n -------------------------------------------------*/" . font-lock-comment-face) 27 | ("\n\n") 28 | ("// " . font-lock-comment-delimiter-face) 29 | ("/**\n" . font-lock-comment-face) 30 | ("// " . font-lock-comment-delimiter-face) 31 | ("* Comment outed class implementation\n" . font-lock-comment-face) 32 | ("// " . font-lock-comment-delimiter-face) 33 | ("*\n" . font-lock-comment-face) 34 | ("// " . font-lock-comment-delimiter-face) 35 | ("* @annotation This is NOT annotation. 3\n" . font-lock-comment-face) 36 | ("// " . font-lock-comment-delimiter-face) 37 | ("*/\n" . font-lock-comment-face) 38 | ("// " . font-lock-comment-delimiter-face) 39 | ("class CommentOuted\n" . font-lock-comment-face) 40 | ("// " . font-lock-comment-delimiter-face) 41 | ("{\n" . font-lock-comment-face) 42 | ("// " . font-lock-comment-delimiter-face) 43 | ("}\n" . font-lock-comment-face) 44 | ("\n") 45 | ("/**\n * Class level doc-comment\n *\n * Description " . font-lock-doc-face) 46 | ("{@internal " php-doc-annotation-tag font-lock-doc-face) 47 | ("Description" php-string php-doc-annotation-tag font-lock-doc-face) 48 | ("}" php-doc-annotation-tag font-lock-doc-face) 49 | (" inline tag.\n *\n * " . font-lock-doc-face) 50 | ("@property-read" php-doc-annotation-tag font-lock-doc-face) 51 | (" " . font-lock-doc-face) 52 | ("string" font-lock-type-face php-string font-lock-doc-face) 53 | ("[]" php-string font-lock-doc-face) 54 | (" " . font-lock-doc-face) 55 | ("$" php-doc-variable-sigil font-lock-doc-face) 56 | ("name" php-variable-name font-lock-doc-face) 57 | ("\n * " . font-lock-doc-face) 58 | ("@ORM\\Table" php-doc-annotation-tag font-lock-doc-face) 59 | ("(name=\"majormodes\")\n * " . font-lock-doc-face) 60 | ("@ORM\\Entity" php-doc-annotation-tag font-lock-doc-face) 61 | ("(repositoryClass=\"Emacs\\Repository\\MajorModeRepository\")\n */" . font-lock-doc-face) 62 | ("\n") 63 | ("final" . php-class-modifier) 64 | (" ") 65 | ("class" . php-class-declaration) 66 | (" ") 67 | ("SampleClass" . font-lock-type-face) 68 | ("\n{\n ") 69 | ("/** Const doc-comment */" . font-lock-doc-face) 70 | ("\n ") 71 | ("const" . php-keyword) 72 | (" ") 73 | ("SAMPLE" . php-constant-assign) 74 | (" ") 75 | ("=" . php-assignment-op) 76 | (" ") 77 | ("'SAMPLE'" . php-string) 78 | (";\n ") 79 | ("/** " . font-lock-doc-face) 80 | ("@var" php-doc-annotation-tag font-lock-doc-face) 81 | (" " . font-lock-doc-face) 82 | ("string" font-lock-type-face php-string font-lock-doc-face) 83 | (" sample property doc-comment */" . font-lock-doc-face) 84 | ("\n ") 85 | ("private" . php-keyword) 86 | (" ") 87 | ("$" . php-variable-sigil) 88 | ("name" . php-variable-name) 89 | (";\n\n ") 90 | ("/**\n * " . font-lock-doc-face) 91 | ("@param" php-doc-annotation-tag font-lock-doc-face) 92 | (" " . font-lock-doc-face) 93 | ("string" font-lock-type-face php-string font-lock-doc-face) 94 | (" " . font-lock-doc-face) 95 | ("$" php-doc-variable-sigil font-lock-doc-face) 96 | ("name" php-variable-name font-lock-doc-face) 97 | ("\n */" . font-lock-doc-face) 98 | ("\n ") 99 | ("public" . php-keyword) 100 | (" ") 101 | ("function" . php-keyword) 102 | (" ") 103 | ("__construct" . php-function-name) 104 | ("(") 105 | ("$" . php-variable-sigil) 106 | ("name" . php-variable-name) 107 | (")\n {\n ") 108 | ("$" . php-this-sigil) 109 | ("this" . php-this) 110 | ("->" . php-object-op) 111 | ("name" . php-property-name) 112 | (" ") 113 | ("=" . php-assignment-op) 114 | (" ") 115 | ("$" . php-variable-sigil) 116 | ("name" . php-variable-name) 117 | ("; ") 118 | ("// " . font-lock-comment-delimiter-face) 119 | ("comment in after code\n" . font-lock-comment-face) 120 | ("\n ") 121 | ("/** " . font-lock-doc-face) 122 | ("@var" php-doc-annotation-tag font-lock-doc-face) 123 | (" " . font-lock-doc-face) 124 | ("string" font-lock-type-face php-string font-lock-doc-face) 125 | ("|" php-string font-lock-doc-face) 126 | ("bool" font-lock-type-face php-string font-lock-doc-face) 127 | ("|" php-string font-lock-doc-face) 128 | ("array" font-lock-type-face php-string font-lock-doc-face) 129 | ("[]|ArrayObject" php-string font-lock-doc-face) 130 | (" */" . font-lock-doc-face) 131 | ("\n ") 132 | ("$" . php-variable-sigil) 133 | ("foo" . php-variable-name) 134 | (" ") 135 | ("=" . php-assignment-op) 136 | (" ") 137 | ("hoge" . php-function-call-traditional) 138 | ("();\n\n ") 139 | ("// " . font-lock-comment-delimiter-face) 140 | ("one-line comment\n" . font-lock-comment-face) 141 | (" ") 142 | ("// " . font-lock-comment-delimiter-face) 143 | ("@annotation This is NOT annotation. 4\n" . font-lock-comment-face) 144 | ("\n ") 145 | ("/** " . font-lock-doc-face) 146 | ("@var" php-doc-annotation-tag font-lock-doc-face) 147 | (" " . font-lock-doc-face) 148 | ("int" font-lock-type-face php-string font-lock-doc-face) 149 | (" internal linter variable */" . font-lock-doc-face) 150 | ("\n ") 151 | ("$" . php-variable-sigil) 152 | ("offset" . php-variable-name) 153 | (" ") 154 | ("=" . php-assignment-op) 155 | (" 0;\n }\n\n ") 156 | ("/**\n * Summary\n *\n * " . font-lock-doc-face) 157 | ("@throws" php-doc-annotation-tag font-lock-doc-face) 158 | (" " . font-lock-doc-face) 159 | ("\\RuntimeException" php-string font-lock-doc-face) 160 | ("\n */" . font-lock-doc-face) 161 | ("\n ") 162 | ("public" . php-keyword) 163 | (" ") 164 | ("function" . php-keyword) 165 | (" ") 166 | ("test" . php-function-name) 167 | ("()\n {\n ") 168 | ("throw" . php-keyword) 169 | (" ") 170 | ("new" . php-keyword) 171 | (" ") 172 | ("\\RuntimeException" . font-lock-type-face) 173 | (";\n }\n}\n")) 174 | -------------------------------------------------------------------------------- /tests/lang/doc-comment/inheritdoc.php: -------------------------------------------------------------------------------- 1 | string(); 8 | $foo->isset(); 9 | 10 | 11 | $a->b(); 12 | $a = a(); 13 | $aaa = aaa(); 14 | $_aa = _aa(); 15 | $a_a = a_a(); 16 | $aa_ = aa_(); 17 | $a1c = a1c(); 18 | $あ = あ(); 19 | $_a = $a(); 20 | -------------------------------------------------------------------------------- /tests/lang/function/calls.php.faces: -------------------------------------------------------------------------------- 1 | ;; -*- mode: emacs-lisp -*- 2 | (("" . php-object-op) 19 | ("string" . php-method-call-traditional) 20 | ("();\n") 21 | ("$" . php-variable-sigil) 22 | ("foo" . php-variable-name) 23 | ("->" . php-object-op) 24 | ("isset" . php-method-call-traditional) 25 | ("();\n\n\n") 26 | ("$" . php-variable-sigil) 27 | ("a" . php-variable-name) 28 | ("->" . php-object-op) 29 | ("b" . php-method-call-traditional) 30 | ("();\n") 31 | ("$" . php-variable-sigil) 32 | ("a" . php-variable-name) 33 | (" ") 34 | ("=" . php-assignment-op) 35 | (" ") 36 | ("a" . php-function-call-traditional) 37 | ("();\n") 38 | ("$" . php-variable-sigil) 39 | ("aaa" . php-variable-name) 40 | (" ") 41 | ("=" . php-assignment-op) 42 | (" ") 43 | ("aaa" . php-function-call-traditional) 44 | ("();\n") 45 | ("$" . php-variable-sigil) 46 | ("_aa" . php-variable-name) 47 | (" ") 48 | ("=" . php-assignment-op) 49 | (" ") 50 | ("_aa" . php-function-call-traditional) 51 | ("();\n") 52 | ("$" . php-variable-sigil) 53 | ("a_a" . php-variable-name) 54 | (" ") 55 | ("=" . php-assignment-op) 56 | (" ") 57 | ("a_a" . php-function-call-traditional) 58 | ("();\n") 59 | ("$" . php-variable-sigil) 60 | ("aa_" . php-variable-name) 61 | (" ") 62 | ("=" . php-assignment-op) 63 | (" ") 64 | ("aa_" . php-function-call-traditional) 65 | ("();\n") 66 | ("$" . php-variable-sigil) 67 | ("a1c" . php-variable-name) 68 | (" ") 69 | ("=" . php-assignment-op) 70 | (" ") 71 | ("a1c" . php-function-call-traditional) 72 | ("();\n") 73 | ("$" . php-variable-sigil) 74 | ("あ" . php-variable-name) 75 | (" ") 76 | ("=" . php-assignment-op) 77 | (" ") 78 | ("あ" . php-function-call-traditional) 79 | ("();\n") 80 | ("$" . php-variable-sigil) 81 | ("_a" . php-variable-name) 82 | (" ") 83 | ("=" . php-assignment-op) 84 | (" ") 85 | ("$" . php-variable-sigil) 86 | ("a" . php-variable-name) 87 | ("();\n")) 88 | -------------------------------------------------------------------------------- /tests/lang/function/closure.php: -------------------------------------------------------------------------------- 1 | memberVariable; 19 | $object->funCall(); 20 | -------------------------------------------------------------------------------- /tests/variables.php.faces: -------------------------------------------------------------------------------- 1 | ;; -*- mode: emacs-lisp -*- 2 | (("" . php-object-op) 54 | ("memberVariable" . php-property-name) 55 | (";\n") 56 | ("$" . php-variable-sigil) 57 | ("object" . php-variable-name) 58 | ("->" . php-object-op) 59 | ("funCall" . php-method-call-traditional) 60 | ("();\n")) 61 | --------------------------------------------------------------------------------