Skip to content

Commit 50bf3ae

Browse files
committed
Add php-runtime-shortdoc
1 parent 5e5d252 commit 50bf3ae

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

php-runtime-shortdoc.el

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
;;; php-runtime-shortdoc.el --- Shortdoc for php-runtime -*- lexical-binding: t; -*-
2+
3+
;; Copyright (C) 2023 Friends of Emacs-PHP development
4+
5+
;; Author: USAMI Kenta <[email protected]>
6+
7+
;; This program is free software; you can redistribute it and/or modify
8+
;; it under the terms of the GNU General Public License as published by
9+
;; the Free Software Foundation, either version 3 of the License, or
10+
;; (at your option) any later version.
11+
12+
;; This program is distributed in the hope that it will be useful,
13+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
;; GNU General Public License for more details.
16+
17+
;; You should have received a copy of the GNU General Public License
18+
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
20+
;;; Commentary:
21+
22+
;; Shortdoc implementation for php-runtime.
23+
24+
;;; Code:
25+
26+
(when (eval-when-compile (require 'shortdoc nil t))
27+
(define-short-documentation-group php-runtime
28+
"Evaluate PHP Code"
29+
(php-runtime-expr
30+
:no-eval (php-runtime-expr "1 + 2")
31+
:result-string "3"
32+
:no-eval (php-runtime-expr "PHP_VERSION")
33+
:result-string "8.2.4"
34+
:no-eval (php-runtime-expr "strtoupper('apple')")
35+
:result-string "APPLE"
36+
:no-eval (string-to-number (php-runtime-expr (format "strlen(%s)" (php-runtime-quote-string "abc"))))
37+
:result 3)
38+
(php-runtime-eval
39+
:no-eval (php-runtime-eval "echo strtoupper('apple');")
40+
:result-string "APPLE"
41+
:no-eval (php-runtime-eval "while ($line = fgets(STDIN)) { echo strtoupper($line); }"
42+
"apple\nbanana\norange")
43+
:result-string "APPLE\nBANANA\nORANGE")
44+
"Check PHP extension is loaded"
45+
(php-runtime-extension-loaded-p
46+
:no-eval (php-runtime-extension-loaded-p "xdebug")
47+
:result t
48+
:no-eval (php-runtime-extension_loaded "notinstalledmod")
49+
:result nil)))
50+
51+
(provide 'php-runtime-shortdoc)
52+
;;; php-runtime-shortdoc.el ends here

php-runtime.el

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
(require 'cl-lib))
4040
(require 'compat nil t)
4141
(require 'eieio)
42+
(when (eval-when-compile (require 'shortdoc nil t))
43+
(require 'php-runtime-shortdoc))
4244

4345
(defgroup php-runtime nil
4446
"Language binding bridge to PHP."

0 commit comments

Comments
 (0)