root/lang/php/misc/dict.php @ 28489

Revision 28489, 1.8 kB (checked in by sotarok, 6 years ago)
  • たぶんこれが正しいと思うんだけど
Line 
1<?php
2/**
3 * Echo php builtin classes, interfaces, functions, constants for vim dictionary
4 *
5 * eg:# php dict.php | sort > ~/.vim/dict/php_functions.dict
6 *
7 * @version   $id$
8 * @copyright 2009 Heavens hell
9 * @author    Heavens hell <heavenshell.jp@gmail.com>
10 * @license   New BSD License
11 */
12$f = false;
13$c = false;
14$i = false;
15$d = false;
16$usage = null;
17if ($argc > 1) {
18    foreach ($argv as $key => $val) {
19        if ($argv[$key] === '-c') {
20            // Classes
21            $c = true;
22        } else if ($argv[$key] === '-f') {
23            // Functions
24            $f = true;
25        } else if ($argv[$key] === '-i') {
26            // Interfaces
27            $i = true;
28        } else if ($argv[$key] === '-v') {
29            // Constants
30            $d = true;
31        } else {
32            $usage  = 'Usage: php dict.php [-c] [-f] [-i] [-d]' . PHP_EOL;
33            $usage .= '       -c display built in classes' . PHP_EOL;
34            $usage .= '       -f display built in functions' . PHP_EOL;
35            $usage .= '       -i display builtin interfaces' . PHP_EOL;
36            $usage .= '       -d display builtin constants' . PHP_EOL;
37        }
38    }
39} else {
40    $f = true;
41    $c = true;
42    $i = true;
43    $d = true;
44}
45if (!is_null($usage)) {
46    echo $usage;
47    exit(0);
48}
49
50$buffer = '';
51if ($f === true) {
52    $functions = get_defined_functions();
53    $buffer    = join("\n",$functions["internal"]) . PHP_EOL;
54}
55
56if ($c === true) {
57    $class = get_declared_classes();
58    foreach ($class as $value) {
59        $buffer .= $value . PHP_EOL;
60    }
61}
62
63if ($i === true) {
64    $interface = get_declared_interfaces();
65    foreach ($interface as $value) {
66        $buffer .= $value . PHP_EOL;
67    }
68}
69
70if ($d === true) {
71    $constants = get_defined_constants();
72    foreach ($constants as $key => $value) {
73        $buffer .= $key . PHP_EOL;
74    }
75}
76
77echo $buffer;
Note: See TracBrowser for help on using the browser.