helly           Sat Dec 10 21:17:35 2005 EDT

  Modified files:              (Branch: PHP_5_1)
    /php-src/sapi/cli   php.1.in php_cli.c 
  Log:
  - MFH --r* switches
  
  
http://cvs.php.net/diff.php/php-src/sapi/cli/php.1.in?r1=1.12&r2=1.12.2.1&ty=u
Index: php-src/sapi/cli/php.1.in
diff -u php-src/sapi/cli/php.1.in:1.12 php-src/sapi/cli/php.1.in:1.12.2.1
--- php-src/sapi/cli/php.1.in:1.12      Wed Aug  3 07:12:18 2005
+++ php-src/sapi/cli/php.1.in   Sat Dec 10 21:17:34 2005
@@ -14,7 +14,7 @@
 ./"    | Author: Marcus Boerger <[EMAIL PROTECTED]>                            
   |
 ./"    +----------------------------------------------------------------------+
 ./" 
-./" $Id: php.1.in,v 1.12 2005/08/03 11:12:18 sniper Exp $
+./" $Id: php.1.in,v 1.12.2.1 2005/12/11 02:17:34 helly Exp $
 ./" 
 .TH PHP 1 "Feb 2003" "The PHP Group" "Scripting Language"
 .SH NAME
@@ -283,6 +283,36 @@
 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
http://cvs.php.net/diff.php/php-src/sapi/cli/php_cli.c?r1=1.129.2.7&r2=1.129.2.8&ty=u
Index: php-src/sapi/cli/php_cli.c
diff -u php-src/sapi/cli/php_cli.c:1.129.2.7 
php-src/sapi/cli/php_cli.c:1.129.2.8
--- php-src/sapi/cli/php_cli.c:1.129.2.7        Mon Dec  5 20:08:49 2005
+++ php-src/sapi/cli/php_cli.c  Sat Dec 10 21:17:34 2005
@@ -20,13 +20,18 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_cli.c,v 1.129.2.7 2005/12/06 01:08:49 sniper Exp $ */
+/* $Id: php_cli.c,v 1.129.2.8 2005/12/11 02:17:34 helly 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 @@
        {'?', 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 @@
                                "  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 @@
        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;
@@ -897,6 +921,20 @@
                                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;
                        }
@@ -1130,6 +1168,52 @@
                                }
        
                                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:
+                                                       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 */
                        }
                }
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to