summaryrefslogtreecommitdiff
path: root/sapi/cli
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 00:35:13 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 00:35:13 -0400
commit0a36161e13484a99ccf69bb38f206462d27cc6d6 (patch)
treed5107db4b7369603ac7c753829e8972ee74949f7 /sapi/cli
parentce7edc9b3c7370f32fec0bc7a8ec3e29ed9a5f61 (diff)
downloadphp-0a36161e13484a99ccf69bb38f206462d27cc6d6.tar.gz
Imported Upstream version 5.1.2upstream/5.1.2
Diffstat (limited to 'sapi/cli')
-rw-r--r--sapi/cli/getopt.c8
-rw-r--r--sapi/cli/php.1.in67
-rw-r--r--sapi/cli/php_cli.c106
-rw-r--r--sapi/cli/php_cli_readline.c12
-rw-r--r--sapi/cli/php_cli_readline.h8
-rw-r--r--sapi/cli/php_getopt.h8
6 files changed, 156 insertions, 53 deletions
diff --git a/sapi/cli/getopt.c b/sapi/cli/getopt.c
index 24d1c8bf0..639eb9bb2 100644
--- a/sapi/cli/getopt.c
+++ b/sapi/cli/getopt.c
@@ -2,12 +2,12 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2005 The PHP Group |
+ | Copyright (c) 1997-2006 The PHP Group |
+----------------------------------------------------------------------+
- | This source file is subject to version 3.0 of the PHP license, |
+ | This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_0.txt. |
+ | http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: getopt.c,v 1.8 2005/08/03 11:12:18 sniper Exp $ */
+/* $Id: getopt.c,v 1.8.2.1 2006/01/01 12:50:19 sniper Exp $ */
#include <stdio.h>
#include <string.h>
diff --git a/sapi/cli/php.1.in b/sapi/cli/php.1.in
index 33613464a..dd959e7e4 100644
--- a/sapi/cli/php.1.in
+++ b/sapi/cli/php.1.in
@@ -1,26 +1,7 @@
-./" +----------------------------------------------------------------------+
-./" | PHP Version 5 |
-./" +----------------------------------------------------------------------+
-./" | Copyright (c) 1997-2005 The PHP Group |
-./" +----------------------------------------------------------------------+
-./" | This source file is subject to version 3.0 of the PHP license, |
-./" | that is bundled with this package in the file LICENSE, and is |
-./" | available through the world-wide-web at the following url: |
-./" | http://www.php.net/license/3_0.txt. |
-./" | If you did not receive a copy of the PHP license and are unable to |
-./" | obtain it through the world-wide-web, please send a note to |
-./" | license@php.net so we can mail you a copy immediately. |
-./" +----------------------------------------------------------------------+
-./" | Author: Marcus Boerger <helly@php.net> |
-./" +----------------------------------------------------------------------+
-./"
-./" $Id: php.1.in,v 1.12 2005/08/03 11:12:18 sniper Exp $
-./"
-.TH PHP 1 "Feb 2003" "The PHP Group" "Scripting Language"
+.TH PHP 1 "2006" "The PHP Group" "Scripting Language"
.SH NAME
.TP 15
-.B php
-PHP Command Line Interface 'CLI'
+php \- PHP Command Line Interface 'CLI'
.SH SYNOPSIS
.B php
[options] [
@@ -283,6 +264,36 @@ Arguments passed to script. Use
when first argument starts with
.B '\-'
or script is read from stdin
+.TP
+.PD 0
+.B \-\-rfunction
+.IR name
+.TP
+.PD 1
+.B \-\-rf
+.IR name
+Shows information about function
+.B name
+.TP
+.PD 0
+.B \-\-rclass
+.IR name
+.TP
+.PD 1
+.B \-\-rc
+.IR name
+Shows information about class
+.B name
+.TP
+.PD 0
+.B \-\-rextension
+.IR name
+.TP
+.PD 1
+.B \-\-re
+.IR name
+Shows information about extension
+.B name
.SH FILES
.TP 15
.B php\-cli.ini
@@ -357,8 +368,8 @@ A nice introduction to PHP by Stig Bakken can be found here:
.B http://www.zend.com/zend/art/intro.php
.PD 1
.SH BUGS
-You can view the list of known bugs or add any new bug you
-found here:
+You can view the list of known bugs or report any new bug you
+found at:
.PD 0
.P
.B http://bugs.php.net
@@ -379,17 +390,17 @@ contributors all around the world.
.SH VERSION INFORMATION
This manpage describes \fBphp\fP, version @PHP_VERSION@.
.SH COPYRIGHT
-Copyright \(co 1997\-2005 The PHP Group
+Copyright \(co 1997\-2006 The PHP Group
.LP
-This source file is subject to version 3.0 of the PHP license,
+This source file is subject to version 3.01 of the PHP license,
that is bundled with this package in the file LICENSE, and is
-available through the world-wide-web at
+available through the world-wide-web at the following url:
.PD 0
.P
-.B http://www.php.net/license/3_0.txt
+.B http://www.php.net/license/3_01.txt
.PD 1
.P
If you did not receive a copy of the PHP license and are unable to
obtain it through the world-wide-web, please send a note to
-.B license@php.net
+.B license@php.net
so we can mail you a copy immediately.
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index 7355e4931..e105bd70e 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -2,12 +2,12 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2005 The PHP Group |
+ | Copyright (c) 1997-2006 The PHP Group |
+----------------------------------------------------------------------+
- | This source file is subject to version 3.0 of the PHP license, |
+ | This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_0.txt. |
+ | http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -20,13 +20,18 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_cli.c,v 1.129.2.6 2005/11/17 08:37:31 sniper Exp $ */
+/* $Id: php_cli.c,v 1.129.2.10 2006/01/01 12:50:19 sniper Exp $ */
#include "php.h"
#include "php_globals.h"
#include "php_variables.h"
#include "zend_hash.h"
#include "zend_modules.h"
+#include "zend_interfaces.h"
+
+#ifdef HAVE_REFLECTION
+#include "ext/reflection/php_reflection.h"
+#endif
#include "SAPI.h"
@@ -82,6 +87,7 @@
#include "zend_execute.h"
#include "zend_highlight.h"
#include "zend_indent.h"
+#include "zend_exceptions.h"
#include "php_getopt.h"
@@ -96,6 +102,9 @@
#define PHP_MODE_STRIP 5
#define PHP_MODE_CLI_DIRECT 6
#define PHP_MODE_PROCESS_STDIN 7
+#define PHP_MODE_REFLECTION_FUNCTION 8
+#define PHP_MODE_REFLECTION_CLASS 9
+#define PHP_MODE_REFLECTION_EXTENSION 10
static char *php_optarg = NULL;
static int php_optind = 1;
@@ -129,6 +138,14 @@ static const opt_struct OPTIONS[] = {
{'?', 0, "usage"},/* help alias (both '?' and 'usage') */
{'v', 0, "version"},
{'z', 1, "zend-extension"},
+#ifdef HAVE_REFLECTION
+ {10, 1, "rf"},
+ {10, 1, "rfunction"},
+ {11, 1, "rc"},
+ {11, 1, "rclass"},
+ {12, 1, "re"},
+ {12, 1, "rextension"},
+#endif
{'-', 0, NULL} /* end of args */
};
@@ -417,6 +434,10 @@ static void php_cli_usage(char *argv0)
" args... Arguments passed to script. Use -- args when first argument\n"
" starts with - or script is read from stdin\n"
"\n"
+ " --rf <name> Show information about function <name>.\n"
+ " --rc <name> Show information about class <name>.\n"
+ " --re <name> Show information about extension <name>.\n"
+ "\n"
, prog, prog, prog, prog, prog, prog);
}
/* }}} */
@@ -561,6 +582,9 @@ int main(int argc, char *argv[])
zend_file_handle file_handle;
/* temporary locals */
int behavior=PHP_MODE_STANDARD;
+#ifdef HAVE_REFLECTION
+ char *reflection_what;
+#endif
int orig_optind=php_optind;
char *orig_optarg=php_optarg;
char *arg_free=NULL, **arg_excp=&arg_free;
@@ -727,9 +751,9 @@ int main(int argc, char *argv[])
goto err;
}
#if ZEND_DEBUG
- php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2005 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
+ php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2006 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
#else
- php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2005 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
+ php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2006 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
#endif
php_end_ob_buffers(1 TSRMLS_CC);
exit_status=0;
@@ -897,6 +921,20 @@ int main(int argc, char *argv[])
hide_argv = 1;
break;
+#ifdef HAVE_REFLECTION
+ case 10:
+ behavior=PHP_MODE_REFLECTION_FUNCTION;
+ reflection_what = php_optarg;
+ break;
+ case 11:
+ behavior=PHP_MODE_REFLECTION_CLASS;
+ reflection_what = php_optarg;
+ break;
+ case 12:
+ behavior=PHP_MODE_REFLECTION_EXTENSION;
+ reflection_what = php_optarg;
+ break;
+#endif
default:
break;
}
@@ -1084,7 +1122,7 @@ int main(int argc, char *argv[])
{
char *input;
size_t len, index = 0;
- pval *argn, *argi;
+ zval *argn, *argi;
cli_register_file_handles(TSRMLS_C);
@@ -1095,7 +1133,7 @@ int main(int argc, char *argv[])
Z_TYPE_P(argi) = IS_LONG;
Z_LVAL_P(argi) = index;
INIT_PZVAL(argi);
- zend_hash_update(&EG(symbol_table), "argi", sizeof("argi"), &argi, sizeof(pval *), NULL);
+ zend_hash_update(&EG(symbol_table), "argi", sizeof("argi"), &argi, sizeof(zval *), NULL);
while (exit_status == SUCCESS && (input=php_stream_gets(s_in_process, NULL, 0)) != NULL) {
len = strlen(input);
while (len-- && (input[len]=='\n' || input[len]=='\r')) {
@@ -1106,7 +1144,7 @@ int main(int argc, char *argv[])
Z_STRLEN_P(argn) = ++len;
Z_STRVAL_P(argn) = estrndup(input, len);
INIT_PZVAL(argn);
- zend_hash_update(&EG(symbol_table), "argn", sizeof("argn"), &argn, sizeof(pval *), NULL);
+ zend_hash_update(&EG(symbol_table), "argn", sizeof("argn"), &argn, sizeof(zval *), NULL);
Z_LVAL_P(argi) = ++index;
if (exec_run) {
if (zend_eval_string_ex(exec_run, NULL, "Command line run code", 1 TSRMLS_CC) == FAILURE) {
@@ -1130,6 +1168,56 @@ int main(int argc, char *argv[])
}
break;
+#ifdef HAVE_REFLECTION
+ case PHP_MODE_REFLECTION_FUNCTION:
+ case PHP_MODE_REFLECTION_CLASS:
+ case PHP_MODE_REFLECTION_EXTENSION:
+ {
+ zend_class_entry *pce;
+ zval *arg, *ref;
+ zend_execute_data execute_data;
+
+ switch (behavior) {
+ case PHP_MODE_REFLECTION_FUNCTION:
+ if (strstr(reflection_what, "::")) {
+ pce = reflection_method_ptr;
+ } else {
+ pce = reflection_function_ptr;
+ }
+ break;
+ case PHP_MODE_REFLECTION_CLASS:
+ pce = reflection_class_ptr;
+ break;
+ case PHP_MODE_REFLECTION_EXTENSION:
+ pce = reflection_extension_ptr;
+ break;
+ }
+
+ MAKE_STD_ZVAL(arg);
+ ZVAL_STRING(arg, reflection_what, 1);
+ ALLOC_ZVAL(ref);
+ object_init_ex(ref, pce);
+ INIT_PZVAL(ref);
+
+ memset(&execute_data, 0, sizeof(zend_execute_data));
+ EG(current_execute_data) = &execute_data;
+ EX(function_state).function = pce->constructor;
+ zend_call_method_with_1_params(&ref, pce, &pce->constructor, "__construct", NULL, arg);
+
+ if (EG(exception)) {
+ zval *msg = zend_read_property(zend_exception_get_default(), EG(exception), "message", sizeof("message")-1, 0 TSRMLS_CC);
+ zend_printf("Exception: %s\n", Z_STRVAL_P(msg));
+ zval_ptr_dtor(&EG(exception));
+ EG(exception) = NULL;
+ } else {
+ zend_call_method_with_1_params(NULL, reflection_ptr, NULL, "export", NULL, ref);
+ }
+ zval_ptr_dtor(&ref);
+ zval_ptr_dtor(&arg);
+
+ break;
+ }
+#endif /* reflection */
}
}
diff --git a/sapi/cli/php_cli_readline.c b/sapi/cli/php_cli_readline.c
index 97b2d0faf..6cca22436 100644
--- a/sapi/cli/php_cli_readline.c
+++ b/sapi/cli/php_cli_readline.c
@@ -2,12 +2,12 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2005 The PHP Group |
+ | Copyright (c) 1997-2006 The PHP Group |
+----------------------------------------------------------------------+
- | This source file is subject to version 3.0 of the PHP license, |
+ | This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_0.txt. |
+ | http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -17,12 +17,16 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_cli_readline.c,v 1.3.2.3 2005/11/17 08:37:31 sniper Exp $ */
+/* $Id: php_cli_readline.c,v 1.3.2.5 2006/01/01 12:50:19 sniper Exp $ */
#include "php.h"
#if (HAVE_LIBREADLINE || HAVE_LIBEDIT) && !defined(COMPILE_DL_READLINE)
+#ifndef HAVE_RL_COMPLETION_MATCHES
+#define rl_completion_matches completion_matches
+#endif
+
#include "php_globals.h"
#include "php_variables.h"
#include "zend_hash.h"
diff --git a/sapi/cli/php_cli_readline.h b/sapi/cli/php_cli_readline.h
index f840765ba..58b99398e 100644
--- a/sapi/cli/php_cli_readline.h
+++ b/sapi/cli/php_cli_readline.h
@@ -2,12 +2,12 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2005 The PHP Group |
+ | Copyright (c) 1997-2006 The PHP Group |
+----------------------------------------------------------------------+
- | This source file is subject to version 3.0 of the PHP license, |
+ | This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_0.txt. |
+ | http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_cli_readline.h,v 1.2 2005/08/03 11:12:18 sniper Exp $ */
+/* $Id: php_cli_readline.h,v 1.2.2.1 2006/01/01 12:50:19 sniper Exp $ */
#include "php.h"
diff --git a/sapi/cli/php_getopt.h b/sapi/cli/php_getopt.h
index 14f9ca5e8..8d38e2803 100644
--- a/sapi/cli/php_getopt.h
+++ b/sapi/cli/php_getopt.h
@@ -2,12 +2,12 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2005 The PHP Group |
+ | Copyright (c) 1997-2006 The PHP Group |
+----------------------------------------------------------------------+
- | This source file is subject to version 3.0 of the PHP license, |
+ | This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_0.txt. |
+ | http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_getopt.h,v 1.7 2005/08/03 11:12:18 sniper Exp $ */
+/* $Id: php_getopt.h,v 1.7.2.1 2006/01/01 12:50:19 sniper Exp $ */
#include "php.h"