2005-11-30 21:53:20 +00:00
/*
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2014-09-19 16:33:14 +00:00
| PHP Version 7 |
2005-11-30 21:53:20 +00:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2015-01-15 15:27:30 +00:00
| Copyright ( c ) 1997 - 2015 The PHP Group |
2005-11-30 21:53:20 +00:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2006-01-01 12:51:34 +00:00
| This source file is subject to version 3.01 of the PHP license , |
2005-11-30 21:53:20 +00:00
| that is bundled with this package in the file LICENSE , and is |
| available through the world - wide - web at the following url : |
2006-01-01 12:51:34 +00:00
| http : //www.php.net/license/3_01.txt |
2005-11-30 21:53:20 +00:00
| 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 . |
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
| Authors : Timm Friebe < thekid @ thekid . de > |
| George Schlossnagle < george @ omniti . com > |
| Andrei Zmievski < andrei @ gravitonic . com > |
| Marcus Boerger < helly @ php . net > |
| Johannes Schlueter < johannes @ php . net > |
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
*/
/* $Id$ */
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
# include "php.h"
# include "php_ini.h"
# include "php_reflection.h"
# include "ext/standard/info.h"
# include "zend.h"
# include "zend_API.h"
# include "zend_exceptions.h"
# include "zend_operators.h"
# include "zend_constants.h"
# include "zend_ini.h"
# include "zend_interfaces.h"
2008-07-14 09:49:03 +00:00
# include "zend_closures.h"
2015-05-14 18:10:35 +00:00
# include "zend_generators.h"
2010-03-30 22:35:23 +00:00
# include "zend_extensions.h"
2015-05-14 18:10:35 +00:00
# include "zend_builtin_functions.h"
2005-11-30 21:53:20 +00:00
2010-05-24 14:11:39 +00:00
# define reflection_update_property(object, name, value) do { \
2014-02-10 06:04:30 +00:00
zval member ; \
ZVAL_STRINGL ( & member , name , sizeof ( name ) - 1 ) ; \
2014-12-13 22:06:14 +00:00
zend_std_write_property ( object , & member , value , NULL ) ; \
2014-03-05 09:55:56 +00:00
if ( Z_REFCOUNTED_P ( value ) ) Z_DELREF_P ( value ) ; \
2010-05-24 14:11:39 +00:00
zval_ptr_dtor ( & member ) ; \
} while ( 0 )
2005-11-30 21:53:20 +00:00
/* Class entry pointers */
PHPAPI zend_class_entry * reflector_ptr ;
PHPAPI zend_class_entry * reflection_exception_ptr ;
PHPAPI zend_class_entry * reflection_ptr ;
2006-06-10 00:40:57 +00:00
PHPAPI zend_class_entry * reflection_function_abstract_ptr ;
2005-11-30 21:53:20 +00:00
PHPAPI zend_class_entry * reflection_function_ptr ;
2015-05-14 18:10:35 +00:00
PHPAPI zend_class_entry * reflection_generator_ptr ;
2005-11-30 21:53:20 +00:00
PHPAPI zend_class_entry * reflection_parameter_ptr ;
PHPAPI zend_class_entry * reflection_class_ptr ;
PHPAPI zend_class_entry * reflection_object_ptr ;
PHPAPI zend_class_entry * reflection_method_ptr ;
PHPAPI zend_class_entry * reflection_property_ptr ;
PHPAPI zend_class_entry * reflection_extension_ptr ;
2010-03-30 22:35:23 +00:00
PHPAPI zend_class_entry * reflection_zend_extension_ptr ;
2005-11-30 21:53:20 +00:00
# if MBO_0
ZEND_BEGIN_MODULE_GLOBALS ( reflection )
int dummy ;
ZEND_END_MODULE_GLOBALS ( reflection )
# ifdef ZTS
# define REFLECTION_G(v) \
2014-10-15 17:19:23 +00:00
ZEND_TSRMG ( reflection_globals_id , zend_reflection_globals * , v )
2005-11-30 21:53:20 +00:00
extern int reflection_globals_id ;
# else
# define REFLECTION_G(v) (reflection_globals.v)
extern zend_reflection_globals reflectionglobals ;
# endif
ZEND_DECLARE_MODULE_GLOBALS ( reflection )
# endif /* MBO_0 */
/* Method macros */
# define METHOD_NOTSTATIC(ce) \
2014-12-13 22:06:14 +00:00
if ( ! Z_OBJ ( EX ( This ) ) | | ! instanceof_function ( Z_OBJCE ( EX ( This ) ) , ce ) ) { \
php_error_docref ( NULL , E_ERROR , " %s() cannot be called statically " , get_active_function_name ( ) ) ; \
2005-11-30 21:53:20 +00:00
return ; \
} \
/* Exception throwing macro */
# define _DO_THROW(msg) \
2014-12-13 22:06:14 +00:00
zend_throw_exception ( reflection_exception_ptr , msg , 0 ) ; \
2005-11-30 21:53:20 +00:00
return ; \
# define RETURN_ON_EXCEPTION \
2014-02-10 06:04:30 +00:00
if ( EG ( exception ) & & EG ( exception ) - > ce = = reflection_exception_ptr ) { \
2005-11-30 21:53:20 +00:00
return ; \
}
2014-04-22 13:46:34 +00:00
# define GET_REFLECTION_OBJECT() \
intern = Z_REFLECTION_P ( getThis ( ) ) ; \
2005-11-30 21:53:20 +00:00
if ( intern = = NULL | | intern - > ptr = = NULL ) { \
RETURN_ON_EXCEPTION \
2014-12-13 22:06:14 +00:00
php_error_docref ( NULL , E_ERROR , " Internal error: Failed to retrieve the reflection object " ) ; \
2005-11-30 21:53:20 +00:00
} \
2014-04-22 13:46:34 +00:00
# define GET_REFLECTION_OBJECT_PTR(target) \
GET_REFLECTION_OBJECT ( ) \
2005-11-30 21:53:20 +00:00
target = intern - > ptr ; \
/* Class constants */
2014-08-25 17:24:55 +00:00
# define REGISTER_REFLECTION_CLASS_CONST_LONG(class_name, const_name, value) \
2014-12-13 22:06:14 +00:00
zend_declare_class_constant_long ( reflection_ # # class_name # # _ptr , const_name , sizeof ( const_name ) - 1 , ( zend_long ) value ) ;
2005-11-30 21:53:20 +00:00
/* {{{ Smart string functions */
typedef struct _string {
2014-02-25 22:02:57 +00:00
zend_string * buf ;
2014-10-29 13:28:16 +00:00
size_t alloced ;
2005-11-30 21:53:20 +00:00
} string ;
static void string_init ( string * str )
{
2014-08-25 17:24:55 +00:00
str - > buf = zend_string_alloc ( 1024 , 0 ) ;
2005-11-30 21:53:20 +00:00
str - > alloced = 1024 ;
2014-02-25 22:02:57 +00:00
str - > buf - > val [ 0 ] = ' \0 ' ;
str - > buf - > len = 0 ;
2005-11-30 21:53:20 +00:00
}
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
static string * string_printf ( string * str , const char * format , . . . )
{
2014-10-29 13:28:16 +00:00
size_t len ;
2005-11-30 21:53:20 +00:00
va_list arg ;
char * s_tmp ;
va_start ( arg , format ) ;
len = zend_vspprintf ( & s_tmp , 0 , format , arg ) ;
if ( len ) {
2014-10-29 13:28:16 +00:00
register size_t nlen = ( str - > buf - > len + 1 + len + ( 1024 - 1 ) ) & ~ ( 1024 - 1 ) ;
2005-11-30 21:53:20 +00:00
if ( str - > alloced < nlen ) {
2014-10-29 13:28:16 +00:00
size_t old_len = str - > buf - > len ;
2005-11-30 21:53:20 +00:00
str - > alloced = nlen ;
2015-03-19 23:02:42 +00:00
str - > buf = zend_string_extend ( str - > buf , str - > alloced , 0 ) ;
2014-02-25 22:02:57 +00:00
str - > buf - > len = old_len ;
2005-11-30 21:53:20 +00:00
}
2014-02-25 22:02:57 +00:00
memcpy ( str - > buf - > val + str - > buf - > len , s_tmp , len + 1 ) ;
str - > buf - > len + = len ;
2005-11-30 21:53:20 +00:00
}
efree ( s_tmp ) ;
va_end ( arg ) ;
return str ;
}
2014-10-29 13:28:16 +00:00
static string * string_write ( string * str , char * buf , size_t len )
2005-11-30 21:53:20 +00:00
{
2014-10-29 13:28:16 +00:00
register size_t nlen = ( str - > buf - > len + 1 + len + ( 1024 - 1 ) ) & ~ ( 1024 - 1 ) ;
2005-11-30 21:53:20 +00:00
if ( str - > alloced < nlen ) {
2014-10-29 13:28:16 +00:00
size_t old_len = str - > buf - > len ;
2005-11-30 21:53:20 +00:00
str - > alloced = nlen ;
2015-03-19 23:02:42 +00:00
str - > buf = zend_string_extend ( str - > buf , str - > alloced , 0 ) ;
2014-02-25 22:02:57 +00:00
str - > buf - > len = old_len ;
2005-11-30 21:53:20 +00:00
}
2014-02-25 22:02:57 +00:00
memcpy ( str - > buf - > val + str - > buf - > len , buf , len ) ;
str - > buf - > len + = len ;
str - > buf - > val [ str - > buf - > len ] = ' \0 ' ;
2005-11-30 21:53:20 +00:00
return str ;
}
static string * string_append ( string * str , string * append )
{
2014-02-25 22:02:57 +00:00
if ( append - > buf - > len > 0 ) {
string_write ( str , append - > buf - > val , append - > buf - > len ) ;
2005-11-30 21:53:20 +00:00
}
return str ;
}
static void string_free ( string * str )
{
2014-08-25 17:24:55 +00:00
zend_string_release ( str - > buf ) ;
2005-11-30 21:53:20 +00:00
str - > alloced = 0 ;
2014-02-25 22:02:57 +00:00
str - > buf = NULL ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
2010-05-29 21:28:24 +00:00
/* {{{ Object structure */
2005-11-30 21:53:20 +00:00
/* Struct for properties */
typedef struct _property_reference {
zend_class_entry * ce ;
2007-03-17 23:00:49 +00:00
zend_property_info prop ;
2005-11-30 21:53:20 +00:00
} property_reference ;
/* Struct for parameters */
typedef struct _parameter_reference {
2014-08-25 17:28:33 +00:00
uint32_t offset ;
uint32_t required ;
2005-11-30 21:53:20 +00:00
struct _zend_arg_info * arg_info ;
zend_function * fptr ;
} parameter_reference ;
2008-08-11 12:43:21 +00:00
typedef enum {
REF_TYPE_OTHER , /* Must be 0 */
REF_TYPE_FUNCTION ,
2015-05-14 18:10:35 +00:00
REF_TYPE_GENERATOR ,
2008-08-11 12:43:21 +00:00
REF_TYPE_PARAMETER ,
2010-11-20 22:53:55 +00:00
REF_TYPE_PROPERTY ,
REF_TYPE_DYNAMIC_PROPERTY
2008-08-11 12:43:21 +00:00
} reflection_type_t ;
2005-11-30 21:53:20 +00:00
/* Struct for reflection objects */
typedef struct {
2014-02-25 13:03:48 +00:00
zval dummy ; /* holder for the second property */
2014-02-10 06:04:30 +00:00
zval obj ;
2014-09-14 10:32:38 +00:00
void * ptr ;
2005-11-30 21:53:20 +00:00
zend_class_entry * ce ;
2014-09-14 10:32:38 +00:00
reflection_type_t ref_type ;
2009-09-16 17:24:46 +00:00
unsigned int ignore_visibility : 1 ;
2014-03-17 04:15:22 +00:00
zend_object zo ;
2005-11-30 21:53:20 +00:00
} reflection_object ;
2015-03-14 06:06:57 +00:00
static inline reflection_object * reflection_object_from_obj ( zend_object * obj ) {
2014-03-17 04:15:22 +00:00
return ( reflection_object * ) ( ( char * ) ( obj ) - XtOffsetOf ( reflection_object , zo ) ) ;
}
# define Z_REFLECTION_P(zv) reflection_object_from_obj(Z_OBJ_P((zv)))
2010-05-29 21:28:24 +00:00
/* }}} */
2005-11-30 21:53:20 +00:00
static zend_object_handlers reflection_object_handlers ;
2014-12-13 22:06:14 +00:00
static zval * _default_load_entry ( zval * object , char * name , size_t name_len ) /* { { { */
2014-03-26 14:07:31 +00:00
{
zval * value ;
if ( ( value = zend_hash_str_find_ind ( Z_OBJPROP_P ( object ) , name , name_len ) ) = = NULL ) {
return NULL ;
}
return value ;
}
2015-03-14 06:06:57 +00:00
/* }}} */
2014-03-26 14:07:31 +00:00
2014-12-13 22:06:14 +00:00
static void _default_get_entry ( zval * object , char * name , int name_len , zval * return_value ) /* { { { */
2005-11-30 21:53:20 +00:00
{
2014-02-10 06:04:30 +00:00
zval * value ;
2005-11-30 21:53:20 +00:00
2014-12-13 22:06:14 +00:00
if ( ( value = _default_load_entry ( object , name , name_len ) ) = = NULL ) {
2005-11-30 21:53:20 +00:00
RETURN_FALSE ;
}
2014-02-10 06:04:30 +00:00
ZVAL_DUP ( return_value , value ) ;
2005-11-30 21:53:20 +00:00
}
2010-05-29 21:28:24 +00:00
/* }}} */
2005-11-30 21:53:20 +00:00
2009-04-02 21:30:09 +00:00
# ifdef ilia_0
2014-12-13 22:06:14 +00:00
static void _default_lookup_entry ( zval * object , char * name , int name_len , zval * * return_value ) /* { { { */
2009-01-03 14:20:22 +00:00
{
zval * * value ;
if ( zend_hash_find ( Z_OBJPROP_P ( object ) , name , name_len , ( void * * ) & value ) = = FAILURE ) {
* return_value = NULL ;
} else {
* return_value = * value ;
}
}
/* }}} */
2009-04-02 21:30:09 +00:00
# endif
2009-01-03 14:20:22 +00:00
2014-12-13 22:06:14 +00:00
static zend_function * _copy_function ( zend_function * fptr ) /* { { { */
2008-08-11 22:31:22 +00:00
{
if ( fptr
2015-04-10 20:01:00 +00:00
& & ( fptr - > internal_function . fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE ) )
2008-08-11 22:31:22 +00:00
{
zend_function * copy_fptr ;
copy_fptr = emalloc ( sizeof ( zend_function ) ) ;
memcpy ( copy_fptr , fptr , sizeof ( zend_function ) ) ;
2014-08-25 17:24:55 +00:00
copy_fptr - > internal_function . function_name = zend_string_copy ( fptr - > internal_function . function_name ) ;
2008-08-11 22:31:22 +00:00
return copy_fptr ;
} else {
/* no copy needed */
return fptr ;
}
}
/* }}} */
2014-12-13 22:06:14 +00:00
static void _free_function ( zend_function * fptr ) /* { { { */
2005-11-30 21:53:20 +00:00
{
2008-08-11 12:43:21 +00:00
if ( fptr
2015-04-10 20:01:00 +00:00
& & ( fptr - > internal_function . fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE ) )
2008-08-11 19:35:00 +00:00
{
2014-08-25 17:24:55 +00:00
zend_string_release ( fptr - > internal_function . function_name ) ;
2015-04-10 20:01:00 +00:00
zend_free_trampoline ( fptr ) ;
2005-11-30 21:53:20 +00:00
}
}
2008-08-11 12:43:21 +00:00
/* }}} */
2005-11-30 21:53:20 +00:00
2014-12-13 22:06:14 +00:00
static void reflection_free_objects_storage ( zend_object * object ) /* { { { */
2005-11-30 21:53:20 +00:00
{
2014-03-17 04:15:22 +00:00
reflection_object * intern = reflection_object_from_obj ( object ) ;
2008-08-11 12:43:21 +00:00
parameter_reference * reference ;
2010-11-20 22:53:55 +00:00
property_reference * prop_reference ;
2005-11-30 21:53:20 +00:00
2008-08-11 12:43:21 +00:00
if ( intern - > ptr ) {
switch ( intern - > ref_type ) {
case REF_TYPE_PARAMETER :
reference = ( parameter_reference * ) intern - > ptr ;
2014-12-13 22:06:14 +00:00
_free_function ( reference - > fptr ) ;
2008-08-11 12:43:21 +00:00
efree ( intern - > ptr ) ;
break ;
case REF_TYPE_FUNCTION :
2014-12-13 22:06:14 +00:00
_free_function ( intern - > ptr ) ;
2008-08-11 12:43:21 +00:00
break ;
case REF_TYPE_PROPERTY :
efree ( intern - > ptr ) ;
break ;
2010-11-20 22:53:55 +00:00
case REF_TYPE_DYNAMIC_PROPERTY :
prop_reference = ( property_reference * ) intern - > ptr ;
2014-08-25 17:24:55 +00:00
zend_string_release ( prop_reference - > prop . name ) ;
2010-11-20 22:53:55 +00:00
efree ( intern - > ptr ) ;
break ;
2015-05-14 18:10:35 +00:00
case REF_TYPE_GENERATOR :
break ;
2008-08-11 12:43:21 +00:00
case REF_TYPE_OTHER :
break ;
}
}
intern - > ptr = NULL ;
2014-02-10 06:04:30 +00:00
zval_ptr_dtor ( & intern - > obj ) ;
2014-12-13 22:06:14 +00:00
zend_object_std_dtor ( object ) ;
2005-11-30 21:53:20 +00:00
}
2010-05-29 21:28:24 +00:00
/* }}} */
2005-11-30 21:53:20 +00:00
2014-12-13 22:06:14 +00:00
static zend_object * reflection_objects_new ( zend_class_entry * class_type ) /* { { { */
2005-11-30 21:53:20 +00:00
{
reflection_object * intern ;
2015-02-04 12:24:13 +00:00
intern = ecalloc ( 1 , sizeof ( reflection_object ) + zend_object_properties_size ( class_type ) ) ;
2005-11-30 21:53:20 +00:00
intern - > zo . ce = class_type ;
2014-12-13 22:06:14 +00:00
zend_object_std_init ( & intern - > zo , class_type ) ;
2010-05-24 14:11:39 +00:00
object_properties_init ( & intern - > zo , class_type ) ;
2014-02-10 06:04:30 +00:00
intern - > zo . handlers = & reflection_object_handlers ;
2014-03-17 04:15:22 +00:00
return & intern - > zo ;
2005-11-30 21:53:20 +00:00
}
2010-05-29 21:28:24 +00:00
/* }}} */
2005-11-30 21:53:20 +00:00
2014-12-13 22:06:14 +00:00
static zval * reflection_instantiate ( zend_class_entry * pce , zval * object ) /* { { { */
2005-11-30 21:53:20 +00:00
{
object_init_ex ( object , pce ) ;
return object ;
}
2010-05-29 21:28:24 +00:00
/* }}} */
2005-11-30 21:53:20 +00:00
2014-12-13 22:06:14 +00:00
static void _const_string ( string * str , char * name , zval * value , char * indent ) ;
static void _function_string ( string * str , zend_function * fptr , zend_class_entry * scope , char * indent ) ;
static void _property_string ( string * str , zend_property_info * prop , char * prop_name , char * indent ) ;
static void _class_string ( string * str , zend_class_entry * ce , zval * obj , char * indent ) ;
static void _extension_string ( string * str , zend_module_entry * module , char * indent ) ;
static void _zend_extension_string ( string * str , zend_extension * extension , char * indent ) ;
2005-11-30 21:53:20 +00:00
/* {{{ _class_string */
2014-12-13 22:06:14 +00:00
static void _class_string ( string * str , zend_class_entry * ce , zval * obj , char * indent )
2005-11-30 21:53:20 +00:00
{
int count , count_static_props = 0 , count_static_funcs = 0 , count_shadow_props = 0 ;
string sub_indent ;
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
string_init ( & sub_indent ) ;
string_printf ( & sub_indent , " %s " , indent ) ;
/* TBD: Repair indenting of doc comment (or is this to be done in the parser?) */
2010-09-15 07:38:52 +00:00
if ( ce - > type = = ZEND_USER_CLASS & & ce - > info . user . doc_comment ) {
string_printf ( str , " %s%s " , indent , ce - > info . user . doc_comment ) ;
2005-11-30 21:53:20 +00:00
string_write ( str , " \n " , 1 ) ;
}
2014-02-25 22:02:57 +00:00
if ( obj & & Z_TYPE_P ( obj ) = = IS_OBJECT ) {
2005-11-30 21:53:20 +00:00
string_printf ( str , " %sObject of class [ " , indent ) ;
} else {
2010-05-29 20:40:58 +00:00
char * kind = " Class " ;
if ( ce - > ce_flags & ZEND_ACC_INTERFACE ) {
kind = " Interface " ;
2015-02-12 22:19:14 +00:00
} else if ( ce - > ce_flags & ZEND_ACC_TRAIT ) {
2010-05-29 20:40:58 +00:00
kind = " Trait " ;
}
string_printf ( str , " %s%s [ " , indent , kind ) ;
2005-11-30 21:53:20 +00:00
}
string_printf ( str , ( ce - > type = = ZEND_USER_CLASS ) ? " <user " : " <internal " ) ;
2010-09-15 07:38:52 +00:00
if ( ce - > type = = ZEND_INTERNAL_CLASS & & ce - > info . internal . module ) {
string_printf ( str , " :%s " , ce - > info . internal . module - > name ) ;
2005-11-30 21:53:20 +00:00
}
string_printf ( str , " > " ) ;
if ( ce - > get_iterator ! = NULL ) {
string_printf ( str , " <iterateable> " ) ;
}
if ( ce - > ce_flags & ZEND_ACC_INTERFACE ) {
string_printf ( str , " interface " ) ;
2015-02-12 22:19:14 +00:00
} else if ( ce - > ce_flags & ZEND_ACC_TRAIT ) {
2010-05-29 20:40:58 +00:00
string_printf ( str , " trait " ) ;
2005-11-30 21:53:20 +00:00
} else {
if ( ce - > ce_flags & ( ZEND_ACC_IMPLICIT_ABSTRACT_CLASS | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS ) ) {
string_printf ( str , " abstract " ) ;
}
2014-11-22 04:57:55 +00:00
if ( ce - > ce_flags & ZEND_ACC_FINAL ) {
2005-11-30 21:53:20 +00:00
string_printf ( str , " final " ) ;
2011-05-15 00:36:13 +00:00
}
2005-11-30 21:53:20 +00:00
string_printf ( str , " class " ) ;
}
2014-02-25 22:02:57 +00:00
string_printf ( str , " %s " , ce - > name - > val ) ;
2005-11-30 21:53:20 +00:00
if ( ce - > parent ) {
2014-02-25 22:02:57 +00:00
string_printf ( str , " extends %s " , ce - > parent - > name - > val ) ;
2005-11-30 21:53:20 +00:00
}
if ( ce - > num_interfaces ) {
2014-08-25 17:28:33 +00:00
uint32_t i ;
2005-11-30 21:53:20 +00:00
2008-11-14 19:22:43 +00:00
if ( ce - > ce_flags & ZEND_ACC_INTERFACE ) {
2014-02-25 22:02:57 +00:00
string_printf ( str , " extends %s " , ce - > interfaces [ 0 ] - > name - > val ) ;
2008-11-14 19:22:43 +00:00
} else {
2014-02-25 22:02:57 +00:00
string_printf ( str , " implements %s " , ce - > interfaces [ 0 ] - > name - > val ) ;
2008-11-14 19:22:43 +00:00
}
2005-11-30 21:53:20 +00:00
for ( i = 1 ; i < ce - > num_interfaces ; + + i ) {
2014-02-25 22:02:57 +00:00
string_printf ( str , " , %s " , ce - > interfaces [ i ] - > name - > val ) ;
2005-11-30 21:53:20 +00:00
}
}
string_printf ( str , " ] { \n " ) ;
/* The information where a class is declared is only available for user classes */
if ( ce - > type = = ZEND_USER_CLASS ) {
2014-02-25 22:02:57 +00:00
string_printf ( str , " %s @@ %s %d-%d \n " , indent , ce - > info . user . filename - > val ,
2010-09-15 07:38:52 +00:00
ce - > info . user . line_start , ce - > info . user . line_end ) ;
2005-11-30 21:53:20 +00:00
}
/* Constants */
if ( & ce - > constants_table ) {
string_printf ( str , " \n " ) ;
count = zend_hash_num_elements ( & ce - > constants_table ) ;
string_printf ( str , " %s - Constants [%d] { \n " , indent , count ) ;
if ( count > 0 ) {
2014-02-10 06:04:30 +00:00
zend_string * key ;
2014-12-23 21:00:18 +00:00
zval * value ;
2005-11-30 21:53:20 +00:00
2014-12-23 21:00:18 +00:00
ZEND_HASH_FOREACH_STR_KEY_VAL ( & ce - > constants_table , key , value ) {
2015-04-01 23:05:25 +00:00
zval_update_constant_ex ( value , 1 , NULL ) ;
2014-12-13 22:06:14 +00:00
_const_string ( str , key - > val , value , indent ) ;
2014-12-23 21:00:18 +00:00
} ZEND_HASH_FOREACH_END ( ) ;
2005-11-30 21:53:20 +00:00
}
string_printf ( str , " %s } \n " , indent ) ;
}
/* Static properties */
if ( & ce - > properties_info ) {
2011-05-15 00:36:13 +00:00
/* counting static properties */
2005-11-30 21:53:20 +00:00
count = zend_hash_num_elements ( & ce - > properties_info ) ;
if ( count > 0 ) {
zend_property_info * prop ;
2015-02-10 12:43:12 +00:00
ZEND_HASH_FOREACH_PTR ( & ce - > properties_info , prop ) {
2005-11-30 21:53:20 +00:00
if ( prop - > flags & ZEND_ACC_SHADOW ) {
count_shadow_props + + ;
} else if ( prop - > flags & ZEND_ACC_STATIC ) {
count_static_props + + ;
}
2015-02-10 12:43:12 +00:00
} ZEND_HASH_FOREACH_END ( ) ;
2005-11-30 21:53:20 +00:00
}
2011-05-15 00:36:13 +00:00
/* static properties */
2005-11-30 21:53:20 +00:00
string_printf ( str , " \n %s - Static properties [%d] { \n " , indent , count_static_props ) ;
if ( count_static_props > 0 ) {
zend_property_info * prop ;
2015-02-10 12:43:12 +00:00
ZEND_HASH_FOREACH_PTR ( & ce - > properties_info , prop ) {
2005-11-30 21:53:20 +00:00
if ( ( prop - > flags & ZEND_ACC_STATIC ) & & ! ( prop - > flags & ZEND_ACC_SHADOW ) ) {
2014-12-13 22:06:14 +00:00
_property_string ( str , prop , NULL , sub_indent . buf - > val ) ;
2005-11-30 21:53:20 +00:00
}
2015-02-10 12:43:12 +00:00
} ZEND_HASH_FOREACH_END ( ) ;
2005-11-30 21:53:20 +00:00
}
string_printf ( str , " %s } \n " , indent ) ;
}
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
/* Static methods */
if ( & ce - > function_table ) {
2011-05-15 00:36:13 +00:00
/* counting static methods */
2005-11-30 21:53:20 +00:00
count = zend_hash_num_elements ( & ce - > function_table ) ;
if ( count > 0 ) {
zend_function * mptr ;
2015-02-10 12:43:12 +00:00
ZEND_HASH_FOREACH_PTR ( & ce - > function_table , mptr ) {
2008-07-20 16:51:28 +00:00
if ( mptr - > common . fn_flags & ZEND_ACC_STATIC
2008-08-11 19:35:00 +00:00
& & ( ( mptr - > common . fn_flags & ZEND_ACC_PRIVATE ) = = 0 | | mptr - > common . scope = = ce ) )
{
2005-11-30 21:53:20 +00:00
count_static_funcs + + ;
}
2015-02-10 12:43:12 +00:00
} ZEND_HASH_FOREACH_END ( ) ;
2005-11-30 21:53:20 +00:00
}
2011-05-15 00:36:13 +00:00
/* static methods */
2005-11-30 21:53:20 +00:00
string_printf ( str , " \n %s - Static methods [%d] { " , indent , count_static_funcs ) ;
if ( count_static_funcs > 0 ) {
zend_function * mptr ;
2015-02-10 12:43:12 +00:00
ZEND_HASH_FOREACH_PTR ( & ce - > function_table , mptr ) {
2008-07-20 16:51:28 +00:00
if ( mptr - > common . fn_flags & ZEND_ACC_STATIC
2008-08-11 19:35:00 +00:00
& & ( ( mptr - > common . fn_flags & ZEND_ACC_PRIVATE ) = = 0 | | mptr - > common . scope = = ce ) )
{
2005-11-30 21:53:20 +00:00
string_printf ( str , " \n " ) ;
2014-12-13 22:06:14 +00:00
_function_string ( str , mptr , ce , sub_indent . buf - > val ) ;
2005-11-30 21:53:20 +00:00
}
2015-02-10 12:43:12 +00:00
} ZEND_HASH_FOREACH_END ( ) ;
2005-11-30 21:53:20 +00:00
} else {
string_printf ( str , " \n " ) ;
}
string_printf ( str , " %s } \n " , indent ) ;
}
/* Default/Implicit properties */
if ( & ce - > properties_info ) {
count = zend_hash_num_elements ( & ce - > properties_info ) - count_static_props - count_shadow_props ;
string_printf ( str , " \n %s - Properties [%d] { \n " , indent , count ) ;
if ( count > 0 ) {
zend_property_info * prop ;
2015-02-10 12:43:12 +00:00
ZEND_HASH_FOREACH_PTR ( & ce - > properties_info , prop ) {
2005-11-30 21:53:20 +00:00
if ( ! ( prop - > flags & ( ZEND_ACC_STATIC | ZEND_ACC_SHADOW ) ) ) {
2014-12-13 22:06:14 +00:00
_property_string ( str , prop , NULL , sub_indent . buf - > val ) ;
2005-11-30 21:53:20 +00:00
}
2015-02-10 12:43:12 +00:00
} ZEND_HASH_FOREACH_END ( ) ;
2005-11-30 21:53:20 +00:00
}
string_printf ( str , " %s } \n " , indent ) ;
}
2014-02-25 22:02:57 +00:00
if ( obj & & Z_TYPE_P ( obj ) = = IS_OBJECT & & Z_OBJ_HT_P ( obj ) - > get_properties ) {
2005-11-30 21:53:20 +00:00
string dyn ;
2014-12-13 22:06:14 +00:00
HashTable * properties = Z_OBJ_HT_P ( obj ) - > get_properties ( obj ) ;
2015-02-10 12:43:12 +00:00
zend_string * prop_name ;
2005-11-30 21:53:20 +00:00
string_init ( & dyn ) ;
count = 0 ;
2009-07-01 18:44:56 +00:00
if ( properties & & zend_hash_num_elements ( properties ) ) {
2015-02-10 12:43:12 +00:00
ZEND_HASH_FOREACH_STR_KEY ( properties , prop_name ) {
if ( prop_name & & prop_name - > len & & prop_name - > val [ 0 ] ) { /* skip all private and protected properties */
if ( ! zend_hash_exists ( & ce - > properties_info , prop_name ) ) {
count + + ;
_property_string ( & dyn , NULL , prop_name - > val , sub_indent . buf - > val ) ;
2005-11-30 21:53:20 +00:00
}
}
2015-02-10 12:43:12 +00:00
} ZEND_HASH_FOREACH_END ( ) ;
2005-11-30 21:53:20 +00:00
}
string_printf ( str , " \n %s - Dynamic properties [%d] { \n " , indent , count ) ;
string_append ( str , & dyn ) ;
string_printf ( str , " %s } \n " , indent ) ;
string_free ( & dyn ) ;
}
/* Non static methods */
if ( & ce - > function_table ) {
count = zend_hash_num_elements ( & ce - > function_table ) - count_static_funcs ;
if ( count > 0 ) {
zend_function * mptr ;
2015-02-10 12:43:12 +00:00
zend_string * key ;
2006-10-03 09:59:07 +00:00
string dyn ;
2005-11-30 21:53:20 +00:00
2006-10-03 09:59:07 +00:00
count = 0 ;
string_init ( & dyn ) ;
2005-11-30 21:53:20 +00:00
2015-02-10 12:43:12 +00:00
ZEND_HASH_FOREACH_STR_KEY_PTR ( & ce - > function_table , key , mptr ) {
2008-08-11 19:35:00 +00:00
if ( ( mptr - > common . fn_flags & ZEND_ACC_STATIC ) = = 0
& & ( ( mptr - > common . fn_flags & ZEND_ACC_PRIVATE ) = = 0 | | mptr - > common . scope = = ce ) )
{
2014-10-29 13:28:16 +00:00
size_t len = mptr - > common . function_name - > len ;
2006-09-26 07:55:21 +00:00
/* Do not display old-style inherited constructors */
2008-08-11 19:35:00 +00:00
if ( ( mptr - > common . fn_flags & ZEND_ACC_CTOR ) = = 0
| | mptr - > common . scope = = ce
2015-02-10 12:43:12 +00:00
| | ! key
2014-03-17 04:32:42 +00:00
| | zend_binary_strcasecmp ( key - > val , key - > len , mptr - > common . function_name - > val , len ) = = 0 )
2008-08-11 19:35:00 +00:00
{
2008-08-11 12:43:21 +00:00
zend_function * closure ;
/* see if this is a closure */
2008-08-11 19:35:00 +00:00
if ( ce = = zend_ce_closure & & obj & & ( len = = sizeof ( ZEND_INVOKE_FUNC_NAME ) - 1 )
2014-02-25 22:02:57 +00:00
& & memcmp ( mptr - > common . function_name - > val , ZEND_INVOKE_FUNC_NAME , sizeof ( ZEND_INVOKE_FUNC_NAME ) - 1 ) = = 0
2014-12-13 22:06:14 +00:00
& & ( closure = zend_get_closure_invoke_method ( Z_OBJ_P ( obj ) ) ) ! = NULL )
2008-08-11 19:35:00 +00:00
{
2008-08-11 12:43:21 +00:00
mptr = closure ;
} else {
closure = NULL ;
}
2006-10-03 09:59:07 +00:00
string_printf ( & dyn , " \n " ) ;
2014-12-13 22:06:14 +00:00
_function_string ( & dyn , mptr , ce , sub_indent . buf - > val ) ;
2006-10-03 09:59:07 +00:00
count + + ;
2014-12-13 22:06:14 +00:00
_free_function ( closure ) ;
2006-09-26 07:55:21 +00:00
}
2005-11-30 21:53:20 +00:00
}
2015-02-10 12:43:12 +00:00
} ZEND_HASH_FOREACH_END ( ) ;
2006-10-03 09:59:07 +00:00
string_printf ( str , " \n %s - Methods [%d] { " , indent , count ) ;
2008-01-16 14:21:07 +00:00
if ( ! count ) {
string_printf ( str , " \n " ) ;
}
2006-10-03 09:59:07 +00:00
string_append ( str , & dyn ) ;
string_free ( & dyn ) ;
2005-11-30 21:53:20 +00:00
} else {
2006-10-03 09:59:07 +00:00
string_printf ( str , " \n %s - Methods [0] { \n " , indent ) ;
2005-11-30 21:53:20 +00:00
}
string_printf ( str , " %s } \n " , indent ) ;
}
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
string_printf ( str , " %s} \n " , indent ) ;
string_free ( & sub_indent ) ;
}
/* }}} */
/* {{{ _const_string */
2014-12-13 22:06:14 +00:00
static void _const_string ( string * str , char * name , zval * value , char * indent )
2005-11-30 21:53:20 +00:00
{
2014-04-21 15:51:15 +00:00
char * type = zend_zval_type_name ( value ) ;
2014-04-21 18:36:01 +00:00
zend_string * value_str = zval_get_string ( value ) ;
2006-09-11 17:08:42 +00:00
string_printf ( str , " %s Constant [ %s %s ] { %s } \n " ,
2014-04-21 15:51:15 +00:00
indent , type , name , value_str - > val ) ;
2006-09-11 17:08:42 +00:00
2014-08-25 17:24:55 +00:00
zend_string_release ( value_str ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ _get_recv_opcode */
2014-08-25 17:28:33 +00:00
static zend_op * _get_recv_op ( zend_op_array * op_array , uint32_t offset )
2005-11-30 21:53:20 +00:00
{
zend_op * op = op_array - > opcodes ;
zend_op * end = op + op_array - > last ;
+ + offset ;
while ( op < end ) {
2015-01-03 09:22:58 +00:00
if ( ( op - > opcode = = ZEND_RECV | | op - > opcode = = ZEND_RECV_INIT
2014-08-26 09:23:25 +00:00
| | op - > opcode = = ZEND_RECV_VARIADIC ) & & op - > op1 . num = = ( zend_long ) offset )
2008-08-11 19:35:00 +00:00
{
return op ;
}
+ + op ;
2005-11-30 21:53:20 +00:00
}
return NULL ;
}
/* }}} */
/* {{{ _parameter_string */
2014-12-13 22:06:14 +00:00
static void _parameter_string ( string * str , zend_function * fptr , struct _zend_arg_info * arg_info , uint32_t offset , uint32_t required , char * indent )
2005-11-30 21:53:20 +00:00
{
string_printf ( str , " Parameter #%d [ " , offset ) ;
if ( offset > = required ) {
string_printf ( str , " <optional> " ) ;
} else {
string_printf ( str , " <required> " ) ;
}
if ( arg_info - > class_name ) {
2014-12-03 13:56:09 +00:00
string_printf ( str , " %s " ,
( fptr - > type = = ZEND_INTERNAL_FUNCTION ) ?
( ( zend_internal_arg_info * ) arg_info ) - > class_name :
arg_info - > class_name - > val ) ;
2005-11-30 21:53:20 +00:00
if ( arg_info - > allow_null ) {
string_printf ( str , " or NULL " ) ;
}
2010-05-20 19:18:35 +00:00
} else if ( arg_info - > type_hint ) {
string_printf ( str , " %s " , zend_get_type_by_const ( arg_info - > type_hint ) ) ;
2005-11-30 21:53:20 +00:00
if ( arg_info - > allow_null ) {
string_printf ( str , " or NULL " ) ;
}
}
if ( arg_info - > pass_by_reference ) {
string_write ( str , " & " , sizeof ( " & " ) - 1 ) ;
}
2013-09-26 16:39:17 +00:00
if ( arg_info - > is_variadic ) {
string_write ( str , " ... " , sizeof ( " ... " ) - 1 ) ;
}
2005-11-30 21:53:20 +00:00
if ( arg_info - > name ) {
2014-12-03 13:56:09 +00:00
string_printf ( str , " $%s " ,
( fptr - > type = = ZEND_INTERNAL_FUNCTION ) ?
( ( zend_internal_arg_info * ) arg_info ) - > name :
arg_info - > name - > val ) ;
2005-11-30 21:53:20 +00:00
} else {
string_printf ( str , " $param%d " , offset ) ;
}
if ( fptr - > type = = ZEND_USER_FUNCTION & & offset > = required ) {
zend_op * precv = _get_recv_op ( ( zend_op_array * ) fptr , offset ) ;
2010-04-20 10:57:45 +00:00
if ( precv & & precv - > opcode = = ZEND_RECV_INIT & & precv - > op2_type ! = IS_UNUSED ) {
2014-04-21 15:51:15 +00:00
zval zv ;
2014-07-23 20:37:15 +00:00
zend_class_entry * old_scope ;
2005-11-30 21:53:20 +00:00
string_write ( str , " = " , sizeof ( " = " ) - 1 ) ;
2014-12-12 07:19:41 +00:00
ZVAL_DUP ( & zv , RT_CONSTANT ( & fptr - > op_array , precv - > op2 ) ) ;
2014-07-23 20:37:15 +00:00
old_scope = EG ( scope ) ;
EG ( scope ) = fptr - > common . scope ;
2014-12-13 22:06:14 +00:00
zval_update_constant_ex ( & zv , 1 , NULL ) ;
2014-07-23 20:37:15 +00:00
EG ( scope ) = old_scope ;
2014-04-30 14:32:42 +00:00
if ( Z_TYPE ( zv ) = = IS_TRUE ) {
string_write ( str , " true " , sizeof ( " true " ) - 1 ) ;
} else if ( Z_TYPE ( zv ) = = IS_FALSE ) {
string_write ( str , " false " , sizeof ( " false " ) - 1 ) ;
2014-02-10 06:04:30 +00:00
} else if ( Z_TYPE ( zv ) = = IS_NULL ) {
2005-11-30 21:53:20 +00:00
string_write ( str , " NULL " , sizeof ( " NULL " ) - 1 ) ;
2014-02-10 06:04:30 +00:00
} else if ( Z_TYPE ( zv ) = = IS_STRING ) {
2005-11-30 21:53:20 +00:00
string_write ( str , " ' " , sizeof ( " ' " ) - 1 ) ;
2014-08-25 17:24:55 +00:00
string_write ( str , Z_STRVAL ( zv ) , MIN ( Z_STRLEN ( zv ) , 15 ) ) ;
if ( Z_STRLEN ( zv ) > 15 ) {
2005-11-30 21:53:20 +00:00
string_write ( str , " ... " , sizeof ( " ... " ) - 1 ) ;
}
string_write ( str , " ' " , sizeof ( " ' " ) - 1 ) ;
2014-02-10 06:04:30 +00:00
} else if ( Z_TYPE ( zv ) = = IS_ARRAY ) {
2011-11-22 10:11:06 +00:00
string_write ( str , " Array " , sizeof ( " Array " ) - 1 ) ;
2005-11-30 21:53:20 +00:00
} else {
2014-04-21 15:51:15 +00:00
zend_string * zv_str = zval_get_string ( & zv ) ;
string_write ( str , zv_str - > val , zv_str - > len ) ;
2014-08-25 17:24:55 +00:00
zend_string_release ( zv_str ) ;
2005-11-30 21:53:20 +00:00
}
zval_ptr_dtor ( & zv ) ;
}
}
string_write ( str , " ] " , sizeof ( " ] " ) - 1 ) ;
}
/* }}} */
/* {{{ _function_parameter_string */
2014-12-13 22:06:14 +00:00
static void _function_parameter_string ( string * str , zend_function * fptr , char * indent )
2005-11-30 21:53:20 +00:00
{
struct _zend_arg_info * arg_info = fptr - > common . arg_info ;
2014-12-22 13:44:39 +00:00
uint32_t i , num_args , required = fptr - > common . required_num_args ;
2005-11-30 21:53:20 +00:00
if ( ! arg_info ) {
return ;
}
2014-12-22 13:44:39 +00:00
num_args = fptr - > common . num_args ;
if ( fptr - > common . fn_flags & ZEND_ACC_VARIADIC ) {
num_args + + ;
}
2005-11-30 21:53:20 +00:00
string_printf ( str , " \n " ) ;
2014-12-22 13:44:39 +00:00
string_printf ( str , " %s- Parameters [%d] { \n " , indent , num_args ) ;
for ( i = 0 ; i < num_args ; i + + ) {
2005-11-30 21:53:20 +00:00
string_printf ( str , " %s " , indent ) ;
2014-12-13 22:06:14 +00:00
_parameter_string ( str , fptr , arg_info , i , required , indent ) ;
2005-11-30 21:53:20 +00:00
string_write ( str , " \n " , sizeof ( " \n " ) - 1 ) ;
arg_info + + ;
}
string_printf ( str , " %s} \n " , indent ) ;
}
/* }}} */
2009-01-26 22:54:34 +00:00
/* {{{ _function_closure_string */
2014-12-13 22:06:14 +00:00
static void _function_closure_string ( string * str , zend_function * fptr , char * indent )
2009-01-26 22:54:34 +00:00
{
2014-08-25 17:28:33 +00:00
uint32_t i , count ;
2014-02-10 06:04:30 +00:00
zend_string * key ;
2009-01-26 22:54:34 +00:00
HashTable * static_variables ;
if ( fptr - > type ! = ZEND_USER_FUNCTION | | ! fptr - > op_array . static_variables ) {
return ;
}
static_variables = fptr - > op_array . static_variables ;
count = zend_hash_num_elements ( static_variables ) ;
if ( ! count ) {
return ;
}
string_printf ( str , " \n " ) ;
string_printf ( str , " %s- Bound Variables [%d] { \n " , indent , zend_hash_num_elements ( static_variables ) ) ;
i = 0 ;
2015-02-10 12:43:12 +00:00
ZEND_HASH_FOREACH_STR_KEY ( static_variables , key ) {
2014-02-10 06:04:30 +00:00
string_printf ( str , " %s Variable #%d [ $%s ] \n " , indent , i + + , key - > val ) ;
2015-02-10 12:43:12 +00:00
} ZEND_HASH_FOREACH_END ( ) ;
2009-01-26 22:54:34 +00:00
string_printf ( str , " %s} \n " , indent ) ;
}
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ _function_string */
2014-12-13 22:06:14 +00:00
static void _function_string ( string * str , zend_function * fptr , zend_class_entry * scope , char * indent )
2005-11-30 21:53:20 +00:00
{
string param_indent ;
zend_function * overwrites ;
2014-02-10 06:04:30 +00:00
zend_string * lc_name ;
2014-10-29 13:28:16 +00:00
size_t lc_name_len ;
2005-11-30 21:53:20 +00:00
/* TBD: Repair indenting of doc comment (or is this to be done in the parser?)
2011-05-15 00:36:13 +00:00
* What ' s " wrong " is that any whitespace before the doc comment start is
2005-11-30 21:53:20 +00:00
* swallowed , leading to an unaligned comment .
*/
if ( fptr - > type = = ZEND_USER_FUNCTION & & fptr - > op_array . doc_comment ) {
2014-03-02 08:02:32 +00:00
string_printf ( str , " %s%s \n " , indent , fptr - > op_array . doc_comment - > val ) ;
2005-11-30 21:53:20 +00:00
}
2009-01-03 12:39:27 +00:00
string_write ( str , indent , strlen ( indent ) ) ;
2009-01-26 22:54:34 +00:00
string_printf ( str , fptr - > common . fn_flags & ZEND_ACC_CLOSURE ? " Closure [ " : ( fptr - > common . scope ? " Method [ " : " Function [ " ) ) ;
2005-11-30 21:53:20 +00:00
string_printf ( str , ( fptr - > type = = ZEND_USER_FUNCTION ) ? " <user " : " <internal " ) ;
2006-02-25 18:25:45 +00:00
if ( fptr - > common . fn_flags & ZEND_ACC_DEPRECATED ) {
string_printf ( str , " , deprecated " ) ;
}
2005-11-30 21:53:20 +00:00
if ( fptr - > type = = ZEND_INTERNAL_FUNCTION & & ( ( zend_internal_function * ) fptr ) - > module ) {
string_printf ( str , " :%s " , ( ( zend_internal_function * ) fptr ) - > module - > name ) ;
}
2007-05-29 08:44:05 +00:00
2005-11-30 21:53:20 +00:00
if ( scope & & fptr - > common . scope ) {
if ( fptr - > common . scope ! = scope ) {
2014-02-25 22:02:57 +00:00
string_printf ( str , " , inherits %s " , fptr - > common . scope - > name - > val ) ;
2005-11-30 21:53:20 +00:00
} else if ( fptr - > common . scope - > parent ) {
2014-02-10 06:04:30 +00:00
lc_name_len = fptr - > common . function_name - > len ;
2014-08-25 17:24:55 +00:00
lc_name = zend_string_alloc ( lc_name_len , 0 ) ;
2014-02-10 06:04:30 +00:00
zend_str_tolower_copy ( lc_name - > val , fptr - > common . function_name - > val , lc_name_len ) ;
if ( ( overwrites = zend_hash_find_ptr ( & fptr - > common . scope - > parent - > function_table , lc_name ) ) ! = NULL ) {
2005-11-30 21:53:20 +00:00
if ( fptr - > common . scope ! = overwrites - > common . scope ) {
2014-02-25 22:02:57 +00:00
string_printf ( str , " , overwrites %s " , overwrites - > common . scope - > name - > val ) ;
2005-11-30 21:53:20 +00:00
}
}
efree ( lc_name ) ;
}
}
if ( fptr - > common . prototype & & fptr - > common . prototype - > common . scope ) {
2014-02-25 22:02:57 +00:00
string_printf ( str , " , prototype %s " , fptr - > common . prototype - > common . scope - > name - > val ) ;
2005-11-30 21:53:20 +00:00
}
if ( fptr - > common . fn_flags & ZEND_ACC_CTOR ) {
string_printf ( str , " , ctor " ) ;
}
if ( fptr - > common . fn_flags & ZEND_ACC_DTOR ) {
string_printf ( str , " , dtor " ) ;
}
string_printf ( str , " > " ) ;
if ( fptr - > common . fn_flags & ZEND_ACC_ABSTRACT ) {
string_printf ( str , " abstract " ) ;
}
if ( fptr - > common . fn_flags & ZEND_ACC_FINAL ) {
string_printf ( str , " final " ) ;
}
if ( fptr - > common . fn_flags & ZEND_ACC_STATIC ) {
string_printf ( str , " static " ) ;
}
2007-04-12 18:39:46 +00:00
if ( fptr - > common . scope ) {
/* These are mutually exclusive */
switch ( fptr - > common . fn_flags & ZEND_ACC_PPP_MASK ) {
case ZEND_ACC_PUBLIC :
string_printf ( str , " public " ) ;
break ;
case ZEND_ACC_PRIVATE :
string_printf ( str , " private " ) ;
break ;
case ZEND_ACC_PROTECTED :
string_printf ( str , " protected " ) ;
break ;
default :
2008-08-11 19:35:00 +00:00
string_printf ( str , " <visibility error> " ) ;
break ;
2007-04-12 18:39:46 +00:00
}
string_printf ( str , " method " ) ;
} else {
string_printf ( str , " function " ) ;
}
2010-09-15 07:38:52 +00:00
if ( fptr - > op_array . fn_flags & ZEND_ACC_RETURN_REFERENCE ) {
2005-11-30 21:53:20 +00:00
string_printf ( str , " & " ) ;
}
2014-02-25 22:02:57 +00:00
string_printf ( str , " %s ] { \n " , fptr - > common . function_name - > val ) ;
2005-11-30 21:53:20 +00:00
/* The information where a function is declared is only available for user classes */
if ( fptr - > type = = ZEND_USER_FUNCTION ) {
2011-05-15 00:36:13 +00:00
string_printf ( str , " %s @@ %s %d - %d \n " , indent ,
2014-02-25 22:02:57 +00:00
fptr - > op_array . filename - > val ,
2008-08-11 19:35:00 +00:00
fptr - > op_array . line_start ,
fptr - > op_array . line_end ) ;
2005-11-30 21:53:20 +00:00
}
string_init ( & param_indent ) ;
string_printf ( & param_indent , " %s " , indent ) ;
2009-01-26 22:54:34 +00:00
if ( fptr - > common . fn_flags & ZEND_ACC_CLOSURE ) {
2014-12-13 22:06:14 +00:00
_function_closure_string ( str , fptr , param_indent . buf - > val ) ;
2009-01-26 22:54:34 +00:00
}
2014-12-13 22:06:14 +00:00
_function_parameter_string ( str , fptr , param_indent . buf - > val ) ;
2005-11-30 21:53:20 +00:00
string_free ( & param_indent ) ;
2015-01-08 20:40:36 +00:00
if ( fptr - > op_array . fn_flags & ZEND_ACC_HAS_RETURN_TYPE ) {
string_printf ( str , " %s- Return [ " , indent ) ;
if ( fptr - > common . arg_info [ - 1 ] . class_name ) {
string_printf ( str , " %s " ,
( fptr - > type = = ZEND_INTERNAL_FUNCTION ) ?
( ( zend_internal_arg_info * ) ( fptr - > common . arg_info - 1 ) ) - > class_name :
fptr - > common . arg_info [ - 1 ] . class_name - > val ) ;
if ( fptr - > common . arg_info [ - 1 ] . allow_null ) {
string_printf ( str , " or NULL " ) ;
}
} else if ( fptr - > common . arg_info [ - 1 ] . type_hint ) {
string_printf ( str , " %s " , zend_get_type_by_const ( fptr - > common . arg_info [ - 1 ] . type_hint ) ) ;
if ( fptr - > common . arg_info [ - 1 ] . allow_null ) {
string_printf ( str , " or NULL " ) ;
}
}
string_printf ( str , " ] \n " ) ;
}
2005-11-30 21:53:20 +00:00
string_printf ( str , " %s} \n " , indent ) ;
}
/* }}} */
/* {{{ _property_string */
2014-12-13 22:06:14 +00:00
static void _property_string ( string * str , zend_property_info * prop , char * prop_name , char * indent )
2005-11-30 21:53:20 +00:00
{
2011-09-13 13:29:35 +00:00
const char * class_name ;
2005-11-30 21:53:20 +00:00
string_printf ( str , " %sProperty [ " , indent ) ;
if ( ! prop ) {
string_printf ( str , " <dynamic> public $%s " , prop_name ) ;
} else {
if ( ! ( prop - > flags & ZEND_ACC_STATIC ) ) {
if ( prop - > flags & ZEND_ACC_IMPLICIT_PUBLIC ) {
string_write ( str , " <implicit> " , sizeof ( " <implicit> " ) - 1 ) ;
} else {
string_write ( str , " <default> " , sizeof ( " <default> " ) - 1 ) ;
}
}
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
/* These are mutually exclusive */
switch ( prop - > flags & ZEND_ACC_PPP_MASK ) {
case ZEND_ACC_PUBLIC :
string_printf ( str , " public " ) ;
break ;
case ZEND_ACC_PRIVATE :
string_printf ( str , " private " ) ;
break ;
case ZEND_ACC_PROTECTED :
string_printf ( str , " protected " ) ;
break ;
}
if ( prop - > flags & ZEND_ACC_STATIC ) {
string_printf ( str , " static " ) ;
}
2014-09-15 22:23:58 +00:00
zend_unmangle_property_name ( prop - > name , & class_name , ( const char * * ) & prop_name ) ;
2005-11-30 21:53:20 +00:00
string_printf ( str , " $%s " , prop_name ) ;
}
string_printf ( str , " ] \n " ) ;
}
/* }}} */
2014-12-13 22:06:14 +00:00
static int _extension_ini_string ( zval * el , int num_args , va_list args , zend_hash_key * hash_key ) /* { { { */
2005-11-30 21:53:20 +00:00
{
2014-03-02 07:14:00 +00:00
zend_ini_entry * ini_entry = ( zend_ini_entry * ) Z_PTR_P ( el ) ;
2005-11-30 21:53:20 +00:00
string * str = va_arg ( args , string * ) ;
char * indent = va_arg ( args , char * ) ;
int number = va_arg ( args , int ) ;
char * comma = " " ;
if ( number = = ini_entry - > module_number ) {
2014-09-01 16:57:33 +00:00
string_printf ( str , " %sEntry [ %s < " , indent , ini_entry - > name - > val ) ;
2007-05-28 10:46:21 +00:00
if ( ini_entry - > modifiable = = ZEND_INI_ALL ) {
2005-11-30 21:53:20 +00:00
string_printf ( str , " ALL " ) ;
} else {
if ( ini_entry - > modifiable & ZEND_INI_USER ) {
string_printf ( str , " USER " ) ;
comma = " , " ;
}
if ( ini_entry - > modifiable & ZEND_INI_PERDIR ) {
string_printf ( str , " %sPERDIR " , comma ) ;
comma = " , " ;
}
if ( ini_entry - > modifiable & ZEND_INI_SYSTEM ) {
string_printf ( str , " %sSYSTEM " , comma ) ;
}
}
2008-08-11 19:35:00 +00:00
2005-11-30 21:53:20 +00:00
string_printf ( str , " > ] \n " ) ;
2014-09-01 16:57:33 +00:00
string_printf ( str , " %s Current = '%s' \n " , indent , ini_entry - > value ? ini_entry - > value - > val : " " ) ;
2005-11-30 21:53:20 +00:00
if ( ini_entry - > modified ) {
2014-09-01 16:57:33 +00:00
string_printf ( str , " %s Default = '%s' \n " , indent , ini_entry - > orig_value ? ini_entry - > orig_value - > val : " " ) ;
2005-11-30 21:53:20 +00:00
}
string_printf ( str , " %s} \n " , indent ) ;
}
return ZEND_HASH_APPLY_KEEP ;
}
2010-05-29 21:28:24 +00:00
/* }}} */
2005-11-30 21:53:20 +00:00
2014-12-13 22:06:14 +00:00
static int _extension_class_string ( zval * el , int num_args , va_list args , zend_hash_key * hash_key ) /* { { { */
2005-11-30 21:53:20 +00:00
{
2014-03-02 07:14:00 +00:00
zend_class_entry * ce = ( zend_class_entry * ) Z_PTR_P ( el ) ;
2005-11-30 21:53:20 +00:00
string * str = va_arg ( args , string * ) ;
char * indent = va_arg ( args , char * ) ;
struct _zend_module_entry * module = va_arg ( args , struct _zend_module_entry * ) ;
int * num_classes = va_arg ( args , int * ) ;
2014-03-02 07:14:00 +00:00
if ( ( ce - > type = = ZEND_INTERNAL_CLASS ) & & ce - > info . internal . module & & ! strcasecmp ( ce - > info . internal . module - > name , module - > name ) ) {
2014-09-26 06:56:42 +00:00
/* dump class if it is not an alias */
2014-09-26 07:28:02 +00:00
if ( ! zend_binary_strcasecmp ( ce - > name - > val , ce - > name - > len , hash_key - > key - > val , hash_key - > key - > len ) ) {
2014-09-26 06:56:42 +00:00
string_printf ( str , " \n " ) ;
2014-12-13 22:06:14 +00:00
_class_string ( str , ce , NULL , indent ) ;
2014-09-26 06:56:42 +00:00
( * num_classes ) + + ;
}
2005-11-30 21:53:20 +00:00
}
return ZEND_HASH_APPLY_KEEP ;
}
2010-05-29 21:28:24 +00:00
/* }}} */
2005-11-30 21:53:20 +00:00
2014-12-13 22:06:14 +00:00
static int _extension_const_string ( zval * el , int num_args , va_list args , zend_hash_key * hash_key ) /* { { { */
2005-11-30 21:53:20 +00:00
{
2014-03-02 07:14:00 +00:00
zend_constant * constant = ( zend_constant * ) Z_PTR_P ( el ) ;
2005-11-30 21:53:20 +00:00
string * str = va_arg ( args , string * ) ;
char * indent = va_arg ( args , char * ) ;
struct _zend_module_entry * module = va_arg ( args , struct _zend_module_entry * ) ;
int * num_classes = va_arg ( args , int * ) ;
if ( constant - > module_number = = module - > module_number ) {
2014-12-13 22:06:14 +00:00
_const_string ( str , constant - > name - > val , & constant - > value , indent ) ;
2005-11-30 21:53:20 +00:00
( * num_classes ) + + ;
}
return ZEND_HASH_APPLY_KEEP ;
}
2010-05-29 21:28:24 +00:00
/* }}} */
2005-11-30 21:53:20 +00:00
2014-12-13 22:06:14 +00:00
static void _extension_string ( string * str , zend_module_entry * module , char * indent ) /* { { { */
2005-11-30 21:53:20 +00:00
{
string_printf ( str , " %sExtension [ " , indent ) ;
if ( module - > type = = MODULE_PERSISTENT ) {
string_printf ( str , " <persistent> " ) ;
}
if ( module - > type = = MODULE_TEMPORARY ) {
string_printf ( str , " <temporary> " ) ;
}
string_printf ( str , " extension #%d %s version %s ] { \n " ,
2008-08-11 19:35:00 +00:00
module - > module_number , module - > name ,
( module - > version = = NO_VERSION_YET ) ? " <no_version> " : module - > version ) ;
2005-11-30 21:53:20 +00:00
2006-02-25 21:17:18 +00:00
if ( module - > deps ) {
2007-09-27 18:00:48 +00:00
const zend_module_dep * dep = module - > deps ;
2006-02-25 21:17:18 +00:00
string_printf ( str , " \n - Dependencies { \n " ) ;
while ( dep - > name ) {
string_printf ( str , " %s Dependency [ %s ( " , indent , dep - > name ) ;
2011-05-15 00:36:13 +00:00
2006-02-25 21:17:18 +00:00
switch ( dep - > type ) {
case MODULE_DEP_REQUIRED :
string_write ( str , " Required " , sizeof ( " Required " ) - 1 ) ;
break ;
case MODULE_DEP_CONFLICTS :
string_write ( str , " Conflicts " , sizeof ( " Conflicts " ) - 1 ) ;
break ;
case MODULE_DEP_OPTIONAL :
string_write ( str , " Optional " , sizeof ( " Optional " ) - 1 ) ;
break ;
default :
string_write ( str , " Error " , sizeof ( " Error " ) - 1 ) ; /* shouldn't happen */
break ;
}
2011-05-15 00:36:13 +00:00
if ( dep - > rel ) {
2006-02-25 21:17:18 +00:00
string_printf ( str , " %s " , dep - > rel ) ;
}
2011-05-15 00:36:13 +00:00
if ( dep - > version ) {
2006-02-25 21:17:18 +00:00
string_printf ( str , " %s " , dep - > version ) ;
}
string_write ( str , " ) ] \n " , sizeof ( " ) ] \n " ) - 1 ) ;
dep + + ;
}
string_printf ( str , " %s } \n " , indent ) ;
}
2005-11-30 21:53:20 +00:00
{
string str_ini ;
string_init ( & str_ini ) ;
2014-12-13 22:06:14 +00:00
zend_hash_apply_with_arguments ( EG ( ini_directives ) , ( apply_func_args_t ) _extension_ini_string , 3 , & str_ini , indent , module - > module_number ) ;
2014-02-25 22:02:57 +00:00
if ( str_ini . buf - > len > 0 ) {
2005-11-30 21:53:20 +00:00
string_printf ( str , " \n - INI { \n " ) ;
string_append ( str , & str_ini ) ;
string_printf ( str , " %s } \n " , indent ) ;
}
string_free ( & str_ini ) ;
}
{
string str_constants ;
int num_constants = 0 ;
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
string_init ( & str_constants ) ;
2014-12-13 22:06:14 +00:00
zend_hash_apply_with_arguments ( EG ( zend_constants ) , ( apply_func_args_t ) _extension_const_string , 4 , & str_constants , indent , module , & num_constants ) ;
2005-11-30 21:53:20 +00:00
if ( num_constants ) {
string_printf ( str , " \n - Constants [%d] { \n " , num_constants ) ;
string_append ( str , & str_constants ) ;
string_printf ( str , " %s } \n " , indent ) ;
}
string_free ( & str_constants ) ;
}
2013-12-10 15:07:16 +00:00
{
2005-11-30 21:53:20 +00:00
zend_function * fptr ;
2013-12-10 15:07:16 +00:00
int first = 1 ;
2015-02-10 12:43:12 +00:00
ZEND_HASH_FOREACH_PTR ( CG ( function_table ) , fptr ) {
2013-12-10 15:07:16 +00:00
if ( fptr - > common . type = = ZEND_INTERNAL_FUNCTION
& & fptr - > internal_function . module = = module ) {
if ( first ) {
string_printf ( str , " \n - Functions { \n " ) ;
first = 0 ;
}
2014-12-13 22:06:14 +00:00
_function_string ( str , fptr , NULL , " " ) ;
2005-11-30 21:53:20 +00:00
}
2015-02-10 12:43:12 +00:00
} ZEND_HASH_FOREACH_END ( ) ;
2013-12-10 15:07:16 +00:00
if ( ! first ) {
string_printf ( str , " %s } \n " , indent ) ;
2005-11-30 21:53:20 +00:00
}
}
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
{
string str_classes ;
string sub_indent ;
int num_classes = 0 ;
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
string_init ( & sub_indent ) ;
string_printf ( & sub_indent , " %s " , indent ) ;
string_init ( & str_classes ) ;
2014-12-13 22:06:14 +00:00
zend_hash_apply_with_arguments ( EG ( class_table ) , ( apply_func_args_t ) _extension_class_string , 4 , & str_classes , sub_indent . buf - > val , module , & num_classes ) ;
2005-11-30 21:53:20 +00:00
if ( num_classes ) {
string_printf ( str , " \n - Classes [%d] { " , num_classes ) ;
string_append ( str , & str_classes ) ;
string_printf ( str , " %s } \n " , indent ) ;
}
string_free ( & str_classes ) ;
string_free ( & sub_indent ) ;
}
string_printf ( str , " %s} \n " , indent ) ;
}
/* }}} */
2014-12-13 22:06:14 +00:00
static void _zend_extension_string ( string * str , zend_extension * extension , char * indent ) /* { { { */
2010-03-30 22:35:23 +00:00
{
string_printf ( str , " %sZend Extension [ %s " , indent , extension - > name ) ;
if ( extension - > version ) {
string_printf ( str , " %s " , extension - > version ) ;
}
if ( extension - > copyright ) {
string_printf ( str , " %s " , extension - > copyright ) ;
}
if ( extension - > author ) {
string_printf ( str , " by %s " , extension - > author ) ;
}
if ( extension - > URL ) {
string_printf ( str , " <%s> " , extension - > URL ) ;
}
string_printf ( str , " ] \n " ) ;
}
2010-05-29 21:28:24 +00:00
/* }}} */
2010-03-30 22:35:23 +00:00
2005-11-30 21:53:20 +00:00
/* {{{ _function_check_flag */
static void _function_check_flag ( INTERNAL_FUNCTION_PARAMETERS , int mask )
{
reflection_object * intern ;
zend_function * mptr ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( mptr ) ;
RETURN_BOOL ( mptr - > common . fn_flags & mask ) ;
}
/* }}} */
/* {{{ zend_reflection_class_factory */
2014-12-13 22:06:14 +00:00
PHPAPI void zend_reflection_class_factory ( zend_class_entry * ce , zval * object )
2005-11-30 21:53:20 +00:00
{
reflection_object * intern ;
2014-02-10 06:04:30 +00:00
zval name ;
2005-11-30 21:53:20 +00:00
2014-09-19 13:32:50 +00:00
ZVAL_STR_COPY ( & name , ce - > name ) ;
2014-12-13 22:06:14 +00:00
reflection_instantiate ( reflection_class_ptr , object ) ;
2014-03-17 04:15:22 +00:00
intern = Z_REFLECTION_P ( object ) ;
2005-11-30 21:53:20 +00:00
intern - > ptr = ce ;
2008-08-11 12:43:21 +00:00
intern - > ref_type = REF_TYPE_OTHER ;
2005-11-30 21:53:20 +00:00
intern - > ce = ce ;
2014-02-10 06:04:30 +00:00
reflection_update_property ( object , " name " , & name ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ reflection_extension_factory */
2014-12-13 22:06:14 +00:00
static void reflection_extension_factory ( zval * object , const char * name_str )
2005-11-30 21:53:20 +00:00
{
reflection_object * intern ;
2014-02-10 06:04:30 +00:00
zval name ;
2014-10-29 13:28:16 +00:00
size_t name_len = strlen ( name_str ) ;
2014-02-10 06:04:30 +00:00
zend_string * lcname ;
2005-11-30 21:53:20 +00:00
struct _zend_module_entry * module ;
2014-08-25 17:24:55 +00:00
lcname = zend_string_alloc ( name_len , 0 ) ;
2014-02-10 06:04:30 +00:00
zend_str_tolower_copy ( lcname - > val , name_str , name_len ) ;
module = zend_hash_find_ptr ( & module_registry , lcname ) ;
2014-08-25 17:24:55 +00:00
zend_string_free ( lcname ) ;
2014-02-10 06:04:30 +00:00
if ( ! module ) {
2005-11-30 21:53:20 +00:00
return ;
}
2014-12-13 22:06:14 +00:00
reflection_instantiate ( reflection_extension_ptr , object ) ;
2014-03-17 04:15:22 +00:00
intern = Z_REFLECTION_P ( object ) ;
2014-02-10 06:04:30 +00:00
ZVAL_STRINGL ( & name , module - > name , name_len ) ;
2005-11-30 21:53:20 +00:00
intern - > ptr = module ;
2008-08-11 12:43:21 +00:00
intern - > ref_type = REF_TYPE_OTHER ;
2005-11-30 21:53:20 +00:00
intern - > ce = NULL ;
2014-02-10 06:04:30 +00:00
reflection_update_property ( object , " name " , & name ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ reflection_parameter_factory */
2014-12-13 22:06:14 +00:00
static void reflection_parameter_factory ( zend_function * fptr , zval * closure_object , struct _zend_arg_info * arg_info , uint32_t offset , uint32_t required , zval * object )
2005-11-30 21:53:20 +00:00
{
reflection_object * intern ;
parameter_reference * reference ;
2014-02-10 06:04:30 +00:00
zval name ;
2005-11-30 21:53:20 +00:00
if ( arg_info - > name ) {
2014-12-03 13:56:09 +00:00
if ( fptr - > type = = ZEND_INTERNAL_FUNCTION ) {
ZVAL_STRING ( & name , ( ( zend_internal_arg_info * ) arg_info ) - > name ) ;
} else {
2015-03-12 13:53:51 +00:00
ZVAL_STR_COPY ( & name , arg_info - > name ) ;
2014-12-03 13:56:09 +00:00
}
2005-11-30 21:53:20 +00:00
} else {
2014-02-10 06:04:30 +00:00
ZVAL_NULL ( & name ) ;
2005-11-30 21:53:20 +00:00
}
2014-12-13 22:06:14 +00:00
reflection_instantiate ( reflection_parameter_ptr , object ) ;
2014-03-17 04:15:22 +00:00
intern = Z_REFLECTION_P ( object ) ;
2005-11-30 21:53:20 +00:00
reference = ( parameter_reference * ) emalloc ( sizeof ( parameter_reference ) ) ;
reference - > arg_info = arg_info ;
reference - > offset = offset ;
reference - > required = required ;
reference - > fptr = fptr ;
intern - > ptr = reference ;
2008-08-11 12:43:21 +00:00
intern - > ref_type = REF_TYPE_PARAMETER ;
2005-11-30 21:53:20 +00:00
intern - > ce = fptr - > common . scope ;
2014-03-02 07:14:00 +00:00
if ( closure_object ) {
Z_ADDREF_P ( closure_object ) ;
ZVAL_COPY_VALUE ( & intern - > obj , closure_object ) ;
}
2014-02-10 06:04:30 +00:00
reflection_update_property ( object , " name " , & name ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ reflection_function_factory */
2014-12-13 22:06:14 +00:00
static void reflection_function_factory ( zend_function * function , zval * closure_object , zval * object )
2005-11-30 21:53:20 +00:00
{
reflection_object * intern ;
2014-02-10 06:04:30 +00:00
zval name ;
2005-11-30 21:53:20 +00:00
2014-09-19 13:32:50 +00:00
ZVAL_STR_COPY ( & name , function - > common . function_name ) ;
2005-11-30 21:53:20 +00:00
2014-12-13 22:06:14 +00:00
reflection_instantiate ( reflection_function_ptr , object ) ;
2014-03-17 04:15:22 +00:00
intern = Z_REFLECTION_P ( object ) ;
2005-11-30 21:53:20 +00:00
intern - > ptr = function ;
2008-08-11 12:43:21 +00:00
intern - > ref_type = REF_TYPE_FUNCTION ;
2005-11-30 21:53:20 +00:00
intern - > ce = NULL ;
2014-03-02 07:14:00 +00:00
if ( closure_object ) {
Z_ADDREF_P ( closure_object ) ;
ZVAL_COPY_VALUE ( & intern - > obj , closure_object ) ;
}
2014-02-10 06:04:30 +00:00
reflection_update_property ( object , " name " , & name ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ reflection_method_factory */
2014-12-13 22:06:14 +00:00
static void reflection_method_factory ( zend_class_entry * ce , zend_function * method , zval * closure_object , zval * object )
2005-11-30 21:53:20 +00:00
{
reflection_object * intern ;
2014-02-10 06:04:30 +00:00
zval name ;
zval classname ;
2005-11-30 21:53:20 +00:00
2014-09-19 13:32:50 +00:00
ZVAL_STR_COPY ( & name , ( method - > common . scope & & method - > common . scope - > trait_aliases ) ?
zend_resolve_method_name ( ce , method ) : method - > common . function_name ) ;
ZVAL_STR_COPY ( & classname , method - > common . scope - > name ) ;
2014-12-13 22:06:14 +00:00
reflection_instantiate ( reflection_method_ptr , object ) ;
2014-03-17 04:15:22 +00:00
intern = Z_REFLECTION_P ( object ) ;
2005-11-30 21:53:20 +00:00
intern - > ptr = method ;
2008-08-11 12:43:21 +00:00
intern - > ref_type = REF_TYPE_FUNCTION ;
2005-11-30 21:53:20 +00:00
intern - > ce = ce ;
2014-03-02 07:14:00 +00:00
if ( closure_object ) {
Z_ADDREF_P ( closure_object ) ;
ZVAL_COPY_VALUE ( & intern - > obj , closure_object ) ;
}
2014-02-10 06:04:30 +00:00
reflection_update_property ( object , " name " , & name ) ;
reflection_update_property ( object , " class " , & classname ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ reflection_property_factory */
2014-12-13 22:06:14 +00:00
static void reflection_property_factory ( zend_class_entry * ce , zend_property_info * prop , zval * object )
2005-11-30 21:53:20 +00:00
{
reflection_object * intern ;
2014-02-10 06:04:30 +00:00
zval name ;
zval classname ;
2005-11-30 21:53:20 +00:00
property_reference * reference ;
2011-09-13 13:29:35 +00:00
const char * class_name , * prop_name ;
2014-09-15 22:23:58 +00:00
size_t prop_name_len ;
2005-11-30 21:53:20 +00:00
2014-09-15 22:23:58 +00:00
zend_unmangle_property_name_ex ( prop - > name , & class_name , & prop_name , & prop_name_len ) ;
2014-09-14 10:30:01 +00:00
2005-11-30 21:53:20 +00:00
if ( ! ( prop - > flags & ZEND_ACC_PRIVATE ) ) {
2006-09-10 13:25:47 +00:00
/* we have to search the class hierarchy for this (implicit) public or protected property */
2007-02-10 20:52:42 +00:00
zend_class_entry * tmp_ce = ce , * store_ce = ce ;
zend_property_info * tmp_info = NULL ;
2014-09-14 10:30:01 +00:00
while ( tmp_ce & & ( tmp_info = zend_hash_str_find_ptr ( & tmp_ce - > properties_info , prop_name , prop_name_len ) ) = = NULL ) {
2005-11-30 21:53:20 +00:00
ce = tmp_ce ;
tmp_ce = tmp_ce - > parent ;
}
2007-02-10 20:52:42 +00:00
if ( tmp_info & & ! ( tmp_info - > flags & ZEND_ACC_SHADOW ) ) { /* found something and it's not a parent's private */
prop = tmp_info ;
} else { /* not found, use initial value */
ce = store_ce ;
}
2005-11-30 21:53:20 +00:00
}
2014-09-14 10:30:01 +00:00
ZVAL_STRINGL ( & name , prop_name , prop_name_len ) ;
2014-09-19 13:32:50 +00:00
ZVAL_STR_COPY ( & classname , prop - > ce - > name ) ;
2005-11-30 21:53:20 +00:00
2014-12-13 22:06:14 +00:00
reflection_instantiate ( reflection_property_ptr , object ) ;
2014-03-17 04:15:22 +00:00
intern = Z_REFLECTION_P ( object ) ;
2005-11-30 21:53:20 +00:00
reference = ( property_reference * ) emalloc ( sizeof ( property_reference ) ) ;
reference - > ce = ce ;
2007-03-17 23:00:49 +00:00
reference - > prop = * prop ;
2005-11-30 21:53:20 +00:00
intern - > ptr = reference ;
2008-08-11 12:43:21 +00:00
intern - > ref_type = REF_TYPE_PROPERTY ;
2005-11-30 21:53:20 +00:00
intern - > ce = ce ;
2009-09-16 17:24:46 +00:00
intern - > ignore_visibility = 0 ;
2014-02-10 06:04:30 +00:00
reflection_update_property ( object , " name " , & name ) ;
reflection_update_property ( object , " class " , & classname ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ _reflection_export */
static void _reflection_export ( INTERNAL_FUNCTION_PARAMETERS , zend_class_entry * ce_ptr , int ctor_argc )
{
2014-02-10 06:04:30 +00:00
zval reflector ;
2005-11-30 21:53:20 +00:00
zval output , * output_ptr = & output ;
zval * argument_ptr , * argument2_ptr ;
2014-02-10 06:04:30 +00:00
zval retval , params [ 2 ] ;
2005-11-30 21:53:20 +00:00
int result ;
int return_output = 0 ;
zend_fcall_info fci ;
zend_fcall_info_cache fcc ;
if ( ctor_argc = = 1 ) {
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " z|b " , & argument_ptr , & return_output ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
2014-02-25 22:02:57 +00:00
ZVAL_COPY_VALUE ( & params [ 0 ] , argument_ptr ) ;
ZVAL_NULL ( & params [ 1 ] ) ;
2005-11-30 21:53:20 +00:00
} else {
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " zz|b " , & argument_ptr , & argument2_ptr , & return_output ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
2014-02-25 22:02:57 +00:00
ZVAL_COPY_VALUE ( & params [ 0 ] , argument_ptr ) ;
ZVAL_COPY_VALUE ( & params [ 1 ] , argument2_ptr ) ;
2005-11-30 21:53:20 +00:00
}
/* Create object */
2014-02-10 06:04:30 +00:00
if ( object_and_properties_init ( & reflector , ce_ptr , NULL ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
_DO_THROW ( " Could not create reflector " ) ;
}
/* Call __construct() */
fci . size = sizeof ( fci ) ;
fci . function_table = NULL ;
2014-02-10 06:04:30 +00:00
ZVAL_UNDEF ( & fci . function_name ) ;
2005-11-30 21:53:20 +00:00
fci . symbol_table = NULL ;
2014-03-27 22:11:22 +00:00
fci . object = Z_OBJ ( reflector ) ;
2014-02-10 06:04:30 +00:00
fci . retval = & retval ;
2005-11-30 21:53:20 +00:00
fci . param_count = ctor_argc ;
fci . params = params ;
fci . no_separation = 1 ;
fcc . initialized = 1 ;
fcc . function_handler = ce_ptr - > constructor ;
fcc . calling_scope = ce_ptr ;
2014-02-10 06:04:30 +00:00
fcc . called_scope = Z_OBJCE ( reflector ) ;
2014-03-27 22:11:22 +00:00
fcc . object = Z_OBJ ( reflector ) ;
2005-11-30 21:53:20 +00:00
2014-12-13 22:06:14 +00:00
result = zend_call_function ( & fci , & fcc ) ;
2011-05-15 00:36:13 +00:00
2014-02-10 06:04:30 +00:00
zval_ptr_dtor ( & retval ) ;
2005-11-30 21:53:20 +00:00
if ( EG ( exception ) ) {
2014-02-10 06:04:30 +00:00
zval_ptr_dtor ( & reflector ) ;
2005-11-30 21:53:20 +00:00
return ;
}
if ( result = = FAILURE ) {
2014-02-10 06:04:30 +00:00
zval_ptr_dtor ( & reflector ) ;
2005-11-30 21:53:20 +00:00
_DO_THROW ( " Could not create reflector " ) ;
}
/* Call static reflection::export */
ZVAL_BOOL ( & output , return_output ) ;
2014-02-10 06:04:30 +00:00
ZVAL_COPY_VALUE ( & params [ 0 ] , & reflector ) ;
ZVAL_COPY_VALUE ( & params [ 1 ] , output_ptr ) ;
2005-11-30 21:53:20 +00:00
2014-02-25 22:02:57 +00:00
ZVAL_STRINGL ( & fci . function_name , " reflection::export " , sizeof ( " reflection::export " ) - 1 ) ;
2005-11-30 21:53:20 +00:00
fci . function_table = & reflection_ptr - > function_table ;
2014-03-27 22:11:22 +00:00
fci . object = NULL ;
2014-02-10 06:04:30 +00:00
fci . retval = & retval ;
2005-11-30 21:53:20 +00:00
fci . param_count = 2 ;
fci . params = params ;
fci . no_separation = 1 ;
2014-12-13 22:06:14 +00:00
result = zend_call_function ( & fci , NULL ) ;
2005-11-30 21:53:20 +00:00
2014-02-25 22:02:57 +00:00
zval_ptr_dtor ( & fci . function_name ) ;
2005-11-30 21:53:20 +00:00
if ( result = = FAILURE & & EG ( exception ) = = NULL ) {
2014-02-10 06:04:30 +00:00
zval_ptr_dtor ( & reflector ) ;
zval_ptr_dtor ( & retval ) ;
2005-11-30 21:53:20 +00:00
_DO_THROW ( " Could not execute reflection::export() " ) ;
}
if ( return_output ) {
2014-04-15 11:40:40 +00:00
ZVAL_COPY_VALUE ( return_value , & retval ) ;
2005-11-30 21:53:20 +00:00
} else {
2014-02-10 06:04:30 +00:00
zval_ptr_dtor ( & retval ) ;
2005-11-30 21:53:20 +00:00
}
/* Destruct reflector which is no longer needed */
2014-02-10 06:04:30 +00:00
zval_ptr_dtor ( & reflector ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
2012-05-31 15:31:00 +00:00
/* {{{ _reflection_param_get_default_param */
static parameter_reference * _reflection_param_get_default_param ( INTERNAL_FUNCTION_PARAMETERS )
{
reflection_object * intern ;
parameter_reference * param ;
2014-03-17 04:15:22 +00:00
intern = Z_REFLECTION_P ( getThis ( ) ) ;
2012-05-31 15:31:00 +00:00
if ( intern = = NULL | | intern - > ptr = = NULL ) {
2014-02-10 06:04:30 +00:00
if ( EG ( exception ) & & EG ( exception ) - > ce = = reflection_exception_ptr ) {
2012-05-31 15:31:00 +00:00
return NULL ;
}
2014-12-13 22:06:14 +00:00
php_error_docref ( NULL , E_ERROR , " Internal error: Failed to retrieve the reflection object " ) ;
2012-05-31 15:31:00 +00:00
}
param = intern - > ptr ;
if ( param - > fptr - > type ! = ZEND_USER_FUNCTION ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 , " Cannot determine default value for internal functions " ) ;
2012-05-31 15:31:00 +00:00
return NULL ;
}
return param ;
}
/* }}} */
/* {{{ _reflection_param_get_default_precv */
static zend_op * _reflection_param_get_default_precv ( INTERNAL_FUNCTION_PARAMETERS , parameter_reference * param )
{
zend_op * precv ;
if ( param = = NULL ) {
return NULL ;
}
precv = _get_recv_op ( ( zend_op_array * ) param - > fptr , param - > offset ) ;
if ( ! precv | | precv - > opcode ! = ZEND_RECV_INIT | | precv - > op2_type = = IS_UNUSED ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 , " Internal error: Failed to retrieve the default value " ) ;
2012-05-31 15:31:00 +00:00
return NULL ;
}
return precv ;
}
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ Preventing __clone from being called */
ZEND_METHOD ( reflection , __clone )
{
/* Should never be executable */
_DO_THROW ( " Cannot clone object using __clone() " ) ;
}
/* }}} */
/* {{{ proto public static mixed Reflection::export(Reflector r [, bool return])
Exports a reflection object . Returns the output if TRUE is specified for return , printing it otherwise . */
ZEND_METHOD ( reflection , export )
{
2014-02-10 06:04:30 +00:00
zval * object , fname , retval ;
2005-11-30 21:53:20 +00:00
int result ;
zend_bool return_output = 0 ;
2014-07-11 12:32:20 +00:00
# ifndef FAST_ZPP
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " O|b " , & object , reflector_ptr , & return_output ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
2014-07-11 12:32:20 +00:00
# else
ZEND_PARSE_PARAMETERS_START ( 1 , 2 )
Z_PARAM_OBJECT_OF_CLASS ( object , reflector_ptr )
Z_PARAM_OPTIONAL
Z_PARAM_BOOL ( return_output )
ZEND_PARSE_PARAMETERS_END ( ) ;
# endif
2005-11-30 21:53:20 +00:00
/* Invoke the __toString() method */
2014-02-10 06:04:30 +00:00
ZVAL_STRINGL ( & fname , " __tostring " , sizeof ( " __tostring " ) - 1 ) ;
2014-12-13 22:06:14 +00:00
result = call_user_function_ex ( NULL , object , & fname , & retval , 0 , NULL , 0 , NULL ) ;
2005-11-30 21:53:20 +00:00
zval_dtor ( & fname ) ;
if ( result = = FAILURE ) {
_DO_THROW ( " Invocation of method __toString() failed " ) ;
/* Returns from this function */
}
2014-02-10 06:04:30 +00:00
if ( Z_TYPE ( retval ) = = IS_UNDEF ) {
2014-12-13 22:06:14 +00:00
php_error_docref ( NULL , E_WARNING , " %s::__toString() did not return anything " , Z_OBJCE_P ( object ) - > name - > val ) ;
2005-11-30 21:53:20 +00:00
RETURN_FALSE ;
}
if ( return_output ) {
2014-04-15 11:40:40 +00:00
ZVAL_COPY_VALUE ( return_value , & retval ) ;
2005-11-30 21:53:20 +00:00
} else {
/* No need for _r variant, return of __toString should always be a string */
2014-12-13 22:06:14 +00:00
zend_print_zval ( & retval , 0 ) ;
2005-11-30 21:53:20 +00:00
zend_printf ( " \n " ) ;
2014-02-10 06:04:30 +00:00
zval_ptr_dtor ( & retval ) ;
2005-11-30 21:53:20 +00:00
}
}
/* }}} */
/* {{{ proto public static array Reflection::getModifierNames(int modifiers)
Returns an array of modifier names */
ZEND_METHOD ( reflection , getModifierNames )
{
2014-08-25 17:24:55 +00:00
zend_long modifiers ;
2005-11-30 21:53:20 +00:00
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " l " , & modifiers ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
array_init ( return_value ) ;
if ( modifiers & ( ZEND_ACC_ABSTRACT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS ) ) {
2014-04-15 11:40:40 +00:00
add_next_index_stringl ( return_value , " abstract " , sizeof ( " abstract " ) - 1 ) ;
2005-11-30 21:53:20 +00:00
}
2014-11-22 04:57:55 +00:00
if ( modifiers & ZEND_ACC_FINAL ) {
2014-04-15 11:40:40 +00:00
add_next_index_stringl ( return_value , " final " , sizeof ( " final " ) - 1 ) ;
2005-11-30 21:53:20 +00:00
}
2008-10-29 12:56:29 +00:00
if ( modifiers & ZEND_ACC_IMPLICIT_PUBLIC ) {
2014-04-15 11:40:40 +00:00
add_next_index_stringl ( return_value , " public " , sizeof ( " public " ) - 1 ) ;
2008-10-29 12:56:29 +00:00
}
2005-11-30 21:53:20 +00:00
/* These are mutually exclusive */
switch ( modifiers & ZEND_ACC_PPP_MASK ) {
case ZEND_ACC_PUBLIC :
2014-04-15 11:40:40 +00:00
add_next_index_stringl ( return_value , " public " , sizeof ( " public " ) - 1 ) ;
2005-11-30 21:53:20 +00:00
break ;
case ZEND_ACC_PRIVATE :
2014-04-15 11:40:40 +00:00
add_next_index_stringl ( return_value , " private " , sizeof ( " private " ) - 1 ) ;
2005-11-30 21:53:20 +00:00
break ;
case ZEND_ACC_PROTECTED :
2014-04-15 11:40:40 +00:00
add_next_index_stringl ( return_value , " protected " , sizeof ( " protected " ) - 1 ) ;
2005-11-30 21:53:20 +00:00
break ;
}
if ( modifiers & ZEND_ACC_STATIC ) {
2014-04-15 11:40:40 +00:00
add_next_index_stringl ( return_value , " static " , sizeof ( " static " ) - 1 ) ;
2005-11-30 21:53:20 +00:00
}
}
/* }}} */
2006-03-06 23:26:28 +00:00
/* {{{ proto public static mixed ReflectionFunction::export(string name [, bool return])
2005-11-30 21:53:20 +00:00
Exports a reflection object . Returns the output if TRUE is specified for return , printing it otherwise . */
ZEND_METHOD ( reflection_function , export )
{
_reflection_export ( INTERNAL_FUNCTION_PARAM_PASSTHRU , reflection_function_ptr , 1 ) ;
}
/* }}} */
2006-03-06 09:50:44 +00:00
/* {{{ proto public void ReflectionFunction::__construct(string name)
2005-11-30 21:53:20 +00:00
Constructor . Throws an Exception in case the given function does not exist */
ZEND_METHOD ( reflection_function , __construct )
{
2014-02-10 06:04:30 +00:00
zval name ;
2005-11-30 21:53:20 +00:00
zval * object ;
2009-01-03 12:39:27 +00:00
zval * closure = NULL ;
2015-04-02 16:52:32 +00:00
char * lcname , * nsname ;
2005-11-30 21:53:20 +00:00
reflection_object * intern ;
zend_function * fptr ;
char * name_str ;
2014-08-27 13:31:48 +00:00
size_t name_len ;
2005-11-30 21:53:20 +00:00
object = getThis ( ) ;
2014-03-17 04:15:22 +00:00
intern = Z_REFLECTION_P ( object ) ;
2005-11-30 21:53:20 +00:00
if ( intern = = NULL ) {
return ;
}
2009-01-03 12:39:27 +00:00
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters_ex ( ZEND_PARSE_PARAMS_QUIET , ZEND_NUM_ARGS ( ) , " O " , & closure , zend_ce_closure ) = = SUCCESS ) {
fptr = ( zend_function * ) zend_get_closure_method_def ( closure ) ;
2009-01-03 12:39:27 +00:00
Z_ADDREF_P ( closure ) ;
2015-03-01 13:06:58 +00:00
} else {
2015-04-02 16:52:32 +00:00
if ( zend_parse_parameters_throw ( ZEND_NUM_ARGS ( ) , " s " , & name_str , & name_len ) = = FAILURE ) {
return ;
}
lcname = zend_str_tolower_dup ( name_str , name_len ) ;
/* Ignore leading "\" */
nsname = lcname ;
if ( lcname [ 0 ] = = ' \\ ' ) {
nsname = & lcname [ 1 ] ;
name_len - - ;
}
if ( ( fptr = zend_hash_str_find_ptr ( EG ( function_table ) , nsname , name_len ) ) = = NULL ) {
2009-01-03 12:39:27 +00:00
efree ( lcname ) ;
2015-04-02 16:52:32 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
" Function %s() does not exist " , name_str ) ;
2009-01-03 12:39:27 +00:00
return ;
}
2015-04-02 16:52:32 +00:00
efree ( lcname ) ;
2005-11-30 21:53:20 +00:00
}
2009-01-03 12:39:27 +00:00
2014-09-19 13:32:50 +00:00
ZVAL_STR_COPY ( & name , fptr - > common . function_name ) ;
2014-02-10 06:04:30 +00:00
reflection_update_property ( object , " name " , & name ) ;
2005-11-30 21:53:20 +00:00
intern - > ptr = fptr ;
2008-08-11 12:43:21 +00:00
intern - > ref_type = REF_TYPE_FUNCTION ;
2014-02-25 13:03:48 +00:00
if ( closure ) {
ZVAL_COPY_VALUE ( & intern - > obj , closure ) ;
} else {
ZVAL_UNDEF ( & intern - > obj ) ;
}
2005-11-30 21:53:20 +00:00
intern - > ce = NULL ;
}
/* }}} */
/* {{{ proto public string ReflectionFunction::__toString()
Returns a string representation */
ZEND_METHOD ( reflection_function , __toString )
{
reflection_object * intern ;
zend_function * fptr ;
string str ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( fptr ) ;
string_init ( & str ) ;
2014-12-13 22:06:14 +00:00
_function_string ( & str , fptr , intern - > ce , " " ) ;
2015-03-12 13:53:51 +00:00
RETURN_NEW_STR ( str . buf ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public string ReflectionFunction::getName()
Returns this function ' s name */
2009-01-03 12:39:27 +00:00
ZEND_METHOD ( reflection_function , getName )
2005-11-30 21:53:20 +00:00
{
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2014-12-13 22:06:14 +00:00
_default_get_entry ( getThis ( ) , " name " , sizeof ( " name " ) - 1 , return_value ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
2009-01-03 12:39:27 +00:00
/* {{{ proto public bool ReflectionFunction::isClosure()
Returns whether this is a closure */
ZEND_METHOD ( reflection_function , isClosure )
{
reflection_object * intern ;
zend_function * fptr ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2009-01-03 12:39:27 +00:00
GET_REFLECTION_OBJECT_PTR ( fptr ) ;
2009-01-26 22:54:34 +00:00
RETURN_BOOL ( fptr - > common . fn_flags & ZEND_ACC_CLOSURE ) ;
2009-01-03 19:08:47 +00:00
}
/* }}} */
2010-04-19 19:45:03 +00:00
/* {{{ proto public bool ReflectionFunction::getClosureThis()
Returns this pointer bound to closure */
ZEND_METHOD ( reflection_function , getClosureThis )
{
reflection_object * intern ;
zval * closure_this ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2014-04-22 13:46:34 +00:00
GET_REFLECTION_OBJECT ( ) ;
2014-05-03 08:06:27 +00:00
if ( ! Z_ISUNDEF ( intern - > obj ) ) {
2014-12-13 22:06:14 +00:00
closure_this = zend_get_closure_this_ptr ( & intern - > obj ) ;
2014-05-03 08:06:27 +00:00
if ( ! Z_ISUNDEF_P ( closure_this ) ) {
2010-04-19 19:45:03 +00:00
RETURN_ZVAL ( closure_this , 1 , 0 ) ;
}
}
}
/* }}} */
2011-09-07 06:46:27 +00:00
/* {{{ proto public ReflectionClass ReflectionFunction::getClosureScopeClass()
Returns the scope associated to the closure */
ZEND_METHOD ( reflection_function , getClosureScopeClass )
{
reflection_object * intern ;
const zend_function * closure_func ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2014-04-22 13:46:34 +00:00
GET_REFLECTION_OBJECT ( ) ;
2014-05-03 08:06:27 +00:00
if ( ! Z_ISUNDEF ( intern - > obj ) ) {
2014-12-13 22:06:14 +00:00
closure_func = zend_get_closure_method_def ( & intern - > obj ) ;
2011-09-07 06:46:27 +00:00
if ( closure_func & & closure_func - > common . scope ) {
2014-12-13 22:06:14 +00:00
zend_reflection_class_factory ( closure_func - > common . scope , return_value ) ;
2011-09-07 06:46:27 +00:00
}
}
}
/* }}} */
2010-04-19 19:45:03 +00:00
/* {{{ proto public mixed ReflectionFunction::getClosure()
Returns a dynamically created closure for the function */
ZEND_METHOD ( reflection_function , getClosure )
{
reflection_object * intern ;
zend_function * fptr ;
2011-05-15 00:36:13 +00:00
2010-04-19 19:45:03 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
GET_REFLECTION_OBJECT_PTR ( fptr ) ;
2015-05-05 19:40:28 +00:00
zend_create_closure ( return_value , fptr , NULL , NULL , NULL ) ;
2010-04-19 19:45:03 +00:00
}
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ proto public bool ReflectionFunction::isInternal()
Returns whether this is an internal function */
2009-01-03 12:39:27 +00:00
ZEND_METHOD ( reflection_function , isInternal )
2005-11-30 21:53:20 +00:00
{
reflection_object * intern ;
zend_function * fptr ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( fptr ) ;
RETURN_BOOL ( fptr - > type = = ZEND_INTERNAL_FUNCTION ) ;
}
/* }}} */
/* {{{ proto public bool ReflectionFunction::isUserDefined()
2015-05-13 18:05:59 +00:00
Returns whether this is a user - defined function */
2005-11-30 21:53:20 +00:00
ZEND_METHOD ( reflection_function , isUserDefined )
{
reflection_object * intern ;
zend_function * fptr ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( fptr ) ;
RETURN_BOOL ( fptr - > type = = ZEND_USER_FUNCTION ) ;
}
/* }}} */
2006-07-07 11:55:23 +00:00
/* {{{ proto public bool ReflectionFunction::isDisabled()
Returns whether this function has been disabled or not */
ZEND_METHOD ( reflection_function , isDisabled )
{
reflection_object * intern ;
zend_function * fptr ;
METHOD_NOTSTATIC ( reflection_function_ptr ) ;
GET_REFLECTION_OBJECT_PTR ( fptr ) ;
RETURN_BOOL ( fptr - > type = = ZEND_INTERNAL_FUNCTION & & fptr - > internal_function . handler = = zif_display_disabled_function ) ;
}
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ proto public string ReflectionFunction::getFileName()
Returns the filename of the file this function was declared in */
ZEND_METHOD ( reflection_function , getFileName )
{
reflection_object * intern ;
zend_function * fptr ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( fptr ) ;
if ( fptr - > type = = ZEND_USER_FUNCTION ) {
2015-03-12 13:53:51 +00:00
RETURN_STR_COPY ( fptr - > op_array . filename ) ;
2005-11-30 21:53:20 +00:00
}
RETURN_FALSE ;
}
/* }}} */
/* {{{ proto public int ReflectionFunction::getStartLine()
Returns the line this function ' s declaration starts at */
ZEND_METHOD ( reflection_function , getStartLine )
{
reflection_object * intern ;
zend_function * fptr ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( fptr ) ;
if ( fptr - > type = = ZEND_USER_FUNCTION ) {
2014-08-25 17:24:55 +00:00
RETURN_LONG ( fptr - > op_array . line_start ) ;
2005-11-30 21:53:20 +00:00
}
RETURN_FALSE ;
}
/* }}} */
/* {{{ proto public int ReflectionFunction::getEndLine()
Returns the line this function ' s declaration ends at */
ZEND_METHOD ( reflection_function , getEndLine )
{
reflection_object * intern ;
zend_function * fptr ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( fptr ) ;
if ( fptr - > type = = ZEND_USER_FUNCTION ) {
2014-08-25 17:24:55 +00:00
RETURN_LONG ( fptr - > op_array . line_end ) ;
2005-11-30 21:53:20 +00:00
}
RETURN_FALSE ;
}
/* }}} */
/* {{{ proto public string ReflectionFunction::getDocComment()
Returns the doc comment for this function */
ZEND_METHOD ( reflection_function , getDocComment )
{
reflection_object * intern ;
zend_function * fptr ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( fptr ) ;
if ( fptr - > type = = ZEND_USER_FUNCTION & & fptr - > op_array . doc_comment ) {
2015-03-12 13:53:51 +00:00
RETURN_STR_COPY ( fptr - > op_array . doc_comment ) ;
2005-11-30 21:53:20 +00:00
}
RETURN_FALSE ;
}
/* }}} */
/* {{{ proto public array ReflectionFunction::getStaticVariables()
Returns an associative array containing this function ' s static variables and their values */
ZEND_METHOD ( reflection_function , getStaticVariables )
{
reflection_object * intern ;
zend_function * fptr ;
2015-04-01 23:05:25 +00:00
zval * val ;
2011-05-15 00:36:13 +00:00
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( fptr ) ;
/* Return an empty array in case no static variables exist */
array_init ( return_value ) ;
if ( fptr - > type = = ZEND_USER_FUNCTION & & fptr - > op_array . static_variables ! = NULL ) {
2015-02-20 10:28:26 +00:00
if ( GC_REFCOUNT ( fptr - > op_array . static_variables ) > 1 ) {
if ( ! ( GC_FLAGS ( fptr - > op_array . static_variables ) & IS_ARRAY_IMMUTABLE ) ) {
GC_REFCOUNT ( fptr - > op_array . static_variables ) - - ;
}
fptr - > op_array . static_variables = zend_array_dup ( fptr - > op_array . static_variables ) ;
}
2015-04-01 23:05:25 +00:00
ZEND_HASH_FOREACH_VAL ( fptr - > op_array . static_variables , val ) {
if ( UNEXPECTED ( zval_update_constant_ex ( val , 1 , fptr - > common . scope ) ! = SUCCESS ) ) {
return ;
}
} ZEND_HASH_FOREACH_END ( ) ;
2014-02-10 06:04:30 +00:00
zend_hash_copy ( Z_ARRVAL_P ( return_value ) , fptr - > op_array . static_variables , zval_add_ref ) ;
2005-11-30 21:53:20 +00:00
}
}
/* }}} */
2009-07-01 17:38:03 +00:00
/* {{{ proto public mixed ReflectionFunction::invoke([mixed* args])
2005-11-30 21:53:20 +00:00
Invokes the function */
ZEND_METHOD ( reflection_function , invoke )
{
2014-02-10 06:04:30 +00:00
zval retval ;
zval * params = NULL ;
2008-06-21 02:41:27 +00:00
int result , num_args = 0 ;
2005-11-30 21:53:20 +00:00
zend_fcall_info fci ;
zend_fcall_info_cache fcc ;
reflection_object * intern ;
zend_function * fptr ;
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
METHOD_NOTSTATIC ( reflection_function_ptr ) ;
GET_REFLECTION_OBJECT_PTR ( fptr ) ;
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " * " , & params , & num_args ) = = FAILURE ) {
2008-06-21 02:41:27 +00:00
return ;
2005-11-30 21:53:20 +00:00
}
fci . size = sizeof ( fci ) ;
fci . function_table = NULL ;
2014-02-10 06:04:30 +00:00
ZVAL_UNDEF ( & fci . function_name ) ;
2005-11-30 21:53:20 +00:00
fci . symbol_table = NULL ;
2014-03-27 22:11:22 +00:00
fci . object = NULL ;
2014-02-10 06:04:30 +00:00
fci . retval = & retval ;
2008-06-21 02:41:27 +00:00
fci . param_count = num_args ;
2005-11-30 21:53:20 +00:00
fci . params = params ;
fci . no_separation = 1 ;
fcc . initialized = 1 ;
fcc . function_handler = fptr ;
fcc . calling_scope = EG ( scope ) ;
2008-07-25 08:23:07 +00:00
fcc . called_scope = NULL ;
2014-03-27 22:11:22 +00:00
fcc . object = NULL ;
2005-11-30 21:53:20 +00:00
2014-12-13 22:06:14 +00:00
result = zend_call_function ( & fci , & fcc ) ;
2005-11-30 21:53:20 +00:00
if ( result = = FAILURE ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2014-02-25 22:02:57 +00:00
" Invocation of function %s() failed " , fptr - > common . function_name - > val ) ;
2005-11-30 21:53:20 +00:00
return ;
}
2014-02-10 06:04:30 +00:00
if ( Z_TYPE ( retval ) ! = IS_UNDEF ) {
2014-04-15 11:40:40 +00:00
ZVAL_COPY_VALUE ( return_value , & retval ) ;
2005-11-30 21:53:20 +00:00
}
}
/* }}} */
/* {{{ proto public mixed ReflectionFunction::invokeArgs(array args)
Invokes the function and pass its arguments as array . */
ZEND_METHOD ( reflection_function , invokeArgs )
{
2014-02-10 06:04:30 +00:00
zval retval ;
2014-05-28 08:34:08 +00:00
zval * params , * val ;
2005-11-30 21:53:20 +00:00
int result ;
2014-04-16 13:06:25 +00:00
int i , argc ;
2005-11-30 21:53:20 +00:00
zend_fcall_info fci ;
zend_fcall_info_cache fcc ;
reflection_object * intern ;
zend_function * fptr ;
zval * param_array ;
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
METHOD_NOTSTATIC ( reflection_function_ptr ) ;
GET_REFLECTION_OBJECT_PTR ( fptr ) ;
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " a " , & param_array ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
argc = zend_hash_num_elements ( Z_ARRVAL_P ( param_array ) ) ;
2011-05-15 00:36:13 +00:00
2014-02-10 06:04:30 +00:00
params = safe_emalloc ( sizeof ( zval ) , argc , 0 ) ;
2014-05-28 08:34:08 +00:00
argc = 0 ;
ZEND_HASH_FOREACH_VAL ( Z_ARRVAL_P ( param_array ) , val ) {
ZVAL_COPY ( & params [ argc ] , val ) ;
argc + + ;
} ZEND_HASH_FOREACH_END ( ) ;
2005-11-30 21:53:20 +00:00
fci . size = sizeof ( fci ) ;
fci . function_table = NULL ;
2014-02-10 06:04:30 +00:00
ZVAL_UNDEF ( & fci . function_name ) ;
2005-11-30 21:53:20 +00:00
fci . symbol_table = NULL ;
2014-03-27 22:11:22 +00:00
fci . object = NULL ;
2014-02-10 06:04:30 +00:00
fci . retval = & retval ;
2005-11-30 21:53:20 +00:00
fci . param_count = argc ;
fci . params = params ;
fci . no_separation = 1 ;
fcc . initialized = 1 ;
fcc . function_handler = fptr ;
fcc . calling_scope = EG ( scope ) ;
2008-07-25 08:23:07 +00:00
fcc . called_scope = NULL ;
2014-03-27 22:11:22 +00:00
fcc . object = NULL ;
2005-11-30 21:53:20 +00:00
2014-12-13 22:06:14 +00:00
result = zend_call_function ( & fci , & fcc ) ;
2005-11-30 21:53:20 +00:00
2014-04-16 13:06:25 +00:00
for ( i = 0 ; i < argc ; i + + ) {
zval_ptr_dtor ( & params [ i ] ) ;
}
2005-11-30 21:53:20 +00:00
efree ( params ) ;
if ( result = = FAILURE ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2014-02-25 22:02:57 +00:00
" Invocation of function %s() failed " , fptr - > common . function_name - > val ) ;
2005-11-30 21:53:20 +00:00
return ;
}
2014-02-10 06:04:30 +00:00
if ( Z_TYPE ( retval ) ! = IS_UNDEF ) {
2014-04-15 11:40:40 +00:00
ZVAL_COPY_VALUE ( return_value , & retval ) ;
2005-11-30 21:53:20 +00:00
}
}
/* }}} */
/* {{{ proto public bool ReflectionFunction::returnsReference()
Gets whether this function returns a reference */
ZEND_METHOD ( reflection_function , returnsReference )
{
reflection_object * intern ;
zend_function * fptr ;
2006-06-10 00:40:57 +00:00
METHOD_NOTSTATIC ( reflection_function_abstract_ptr ) ;
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( fptr ) ;
2010-09-15 07:38:52 +00:00
RETURN_BOOL ( ( fptr - > op_array . fn_flags & ZEND_ACC_RETURN_REFERENCE ) ! = 0 ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public bool ReflectionFunction::getNumberOfParameters()
Gets the number of required parameters */
ZEND_METHOD ( reflection_function , getNumberOfParameters )
{
reflection_object * intern ;
zend_function * fptr ;
2014-12-22 13:44:39 +00:00
uint32_t num_args ;
2005-11-30 21:53:20 +00:00
2006-06-10 00:40:57 +00:00
METHOD_NOTSTATIC ( reflection_function_abstract_ptr ) ;
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( fptr ) ;
2014-12-22 13:44:39 +00:00
num_args = fptr - > common . num_args ;
if ( fptr - > common . fn_flags & ZEND_ACC_VARIADIC ) {
num_args + + ;
}
RETURN_LONG ( num_args ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public bool ReflectionFunction::getNumberOfRequiredParameters()
Gets the number of required parameters */
ZEND_METHOD ( reflection_function , getNumberOfRequiredParameters )
{
reflection_object * intern ;
zend_function * fptr ;
2006-06-10 00:40:57 +00:00
METHOD_NOTSTATIC ( reflection_function_abstract_ptr ) ;
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( fptr ) ;
2014-08-25 17:24:55 +00:00
RETURN_LONG ( fptr - > common . required_num_args ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public ReflectionParameter[] ReflectionFunction::getParameters()
Returns an array of parameter objects for this function */
ZEND_METHOD ( reflection_function , getParameters )
{
reflection_object * intern ;
zend_function * fptr ;
2014-12-22 13:44:39 +00:00
uint32_t i , num_args ;
2005-11-30 21:53:20 +00:00
struct _zend_arg_info * arg_info ;
2006-06-10 00:40:57 +00:00
METHOD_NOTSTATIC ( reflection_function_abstract_ptr ) ;
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( fptr ) ;
arg_info = fptr - > common . arg_info ;
2014-12-22 13:44:39 +00:00
num_args = fptr - > common . num_args ;
if ( fptr - > common . fn_flags & ZEND_ACC_VARIADIC ) {
num_args + + ;
}
2005-11-30 21:53:20 +00:00
array_init ( return_value ) ;
2014-12-22 13:44:39 +00:00
for ( i = 0 ; i < num_args ; i + + ) {
2014-02-10 06:04:30 +00:00
zval parameter ;
2005-11-30 21:53:20 +00:00
2014-12-13 22:06:14 +00:00
reflection_parameter_factory ( _copy_function ( fptr ) , Z_ISUNDEF ( intern - > obj ) ? NULL : & intern - > obj , arg_info , i , fptr - > common . required_num_args , & parameter ) ;
2014-02-10 06:04:30 +00:00
add_next_index_zval ( return_value , & parameter ) ;
2008-08-11 19:35:00 +00:00
arg_info + + ;
2005-11-30 21:53:20 +00:00
}
}
/* }}} */
/* {{{ proto public ReflectionExtension|NULL ReflectionFunction::getExtension()
Returns NULL or the extension the function belongs to */
ZEND_METHOD ( reflection_function , getExtension )
{
reflection_object * intern ;
zend_function * fptr ;
zend_internal_function * internal ;
2006-06-10 00:40:57 +00:00
METHOD_NOTSTATIC ( reflection_function_abstract_ptr ) ;
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( fptr ) ;
if ( fptr - > type ! = ZEND_INTERNAL_FUNCTION ) {
RETURN_NULL ( ) ;
}
internal = ( zend_internal_function * ) fptr ;
if ( internal - > module ) {
2014-12-13 22:06:14 +00:00
reflection_extension_factory ( return_value , internal - > module - > name ) ;
2005-11-30 21:53:20 +00:00
} else {
RETURN_NULL ( ) ;
}
}
/* }}} */
/* {{{ proto public string|false ReflectionFunction::getExtensionName()
Returns false or the name of the extension the function belongs to */
ZEND_METHOD ( reflection_function , getExtensionName )
{
reflection_object * intern ;
zend_function * fptr ;
zend_internal_function * internal ;
2006-06-10 00:40:57 +00:00
METHOD_NOTSTATIC ( reflection_function_abstract_ptr ) ;
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( fptr ) ;
if ( fptr - > type ! = ZEND_INTERNAL_FUNCTION ) {
RETURN_FALSE ;
}
internal = ( zend_internal_function * ) fptr ;
if ( internal - > module ) {
2014-02-10 06:04:30 +00:00
RETURN_STRING ( internal - > module - > name ) ;
2005-11-30 21:53:20 +00:00
} else {
RETURN_FALSE ;
}
}
/* }}} */
2015-05-14 18:10:35 +00:00
/* {{{ proto public void ReflectionGenerator::__construct(Generator) */
ZEND_METHOD ( reflection_generator , __construct )
{
zval * generator , * object ;
reflection_object * intern ;
zend_execute_data * ex ;
object = getThis ( ) ;
intern = Z_REFLECTION_P ( object ) ;
if ( intern = = NULL ) {
return ;
}
if ( zend_parse_parameters_throw ( ZEND_NUM_ARGS ( ) , " O " , & generator , zend_ce_generator ) = = FAILURE ) {
return ;
}
ex = ( ( zend_generator * ) Z_OBJ_P ( generator ) ) - > execute_data ;
if ( ! ex ) {
zend_throw_exception ( NULL , " Cannot create ReflectionGenerator based on a terminated Generator " , 0 ) ;
return ;
}
intern - > ref_type = REF_TYPE_GENERATOR ;
ZVAL_COPY ( & intern - > obj , generator ) ;
intern - > ce = zend_ce_generator ;
}
/* }}} */
# define REFLECTION_CHECK_VALID_GENERATOR(ex) \
if ( ! ex ) { \
zend_throw_exception ( NULL , " Cannot fetch information from a terminated Generator " , 0 ) ; \
return ; \
}
/* {{{ proto public array ReflectionGenerator::getTrace($options = DEBUG_BACKTRACE_PROVIDE_OBJECT) */
ZEND_METHOD ( reflection_generator , getTrace )
{
zend_long options = DEBUG_BACKTRACE_PROVIDE_OBJECT ;
zend_generator * generator = ( zend_generator * ) Z_OBJ ( Z_REFLECTION_P ( getThis ( ) ) - > obj ) ;
zend_generator * root_generator ;
zend_execute_data * ex_backup = EG ( current_execute_data ) ;
zend_execute_data * ex = generator - > execute_data ;
zend_execute_data * root_prev , * cur_prev ;
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " |l " , & options ) = = FAILURE ) {
return ;
}
REFLECTION_CHECK_VALID_GENERATOR ( ex )
root_generator = zend_generator_get_current ( generator ) ;
cur_prev = generator - > execute_data - > prev_execute_data ;
if ( generator = = root_generator ) {
generator - > execute_data - > prev_execute_data = NULL ;
} else {
root_prev = root_generator - > execute_data - > prev_execute_data ;
generator - > execute_fake . prev_execute_data = NULL ;
root_generator - > execute_data - > prev_execute_data = & generator - > execute_fake ;
}
EG ( current_execute_data ) = root_generator - > execute_data ;
zend_fetch_debug_backtrace ( return_value , 0 , options , 0 ) ;
EG ( current_execute_data ) = ex_backup ;
root_generator - > execute_data - > prev_execute_data = root_prev ;
generator - > execute_data - > prev_execute_data = cur_prev ;
}
/* }}} */
/* {{{ proto public int ReflectionGenerator::getExecutingLine() */
ZEND_METHOD ( reflection_generator , getExecutingLine )
{
zend_generator * generator = ( zend_generator * ) Z_OBJ ( Z_REFLECTION_P ( getThis ( ) ) - > obj ) ;
zend_execute_data * ex = generator - > execute_data ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
REFLECTION_CHECK_VALID_GENERATOR ( ex )
ZVAL_LONG ( return_value , ex - > opline - > lineno ) ;
}
/* }}} */
/* {{{ proto public string ReflectionGenerator::getExecutingFile() */
ZEND_METHOD ( reflection_generator , getExecutingFile )
{
zend_generator * generator = ( zend_generator * ) Z_OBJ ( Z_REFLECTION_P ( getThis ( ) ) - > obj ) ;
zend_execute_data * ex = generator - > execute_data ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
REFLECTION_CHECK_VALID_GENERATOR ( ex )
ZVAL_STR_COPY ( return_value , ex - > func - > op_array . filename ) ;
}
/* }}} */
/* {{{ proto public ReflectionFunctionAbstract ReflectionGenerator::getFunction() */
ZEND_METHOD ( reflection_generator , getFunction )
{
zend_generator * generator = ( zend_generator * ) Z_OBJ ( Z_REFLECTION_P ( getThis ( ) ) - > obj ) ;
zend_execute_data * ex = generator - > execute_data ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
REFLECTION_CHECK_VALID_GENERATOR ( ex )
if ( ex - > func - > common . fn_flags & ZEND_ACC_CLOSURE ) {
zval closure ;
ZVAL_OBJ ( & closure , ( zend_object * ) ex - > func - > common . prototype ) ;
reflection_function_factory ( ex - > func , & closure , return_value ) ;
} else if ( ex - > func - > op_array . scope ) {
reflection_method_factory ( ex - > func - > op_array . scope , ex - > func , NULL , return_value ) ;
} else {
reflection_function_factory ( ex - > func , NULL , return_value ) ;
}
}
/* }}} */
/* {{{ proto public object ReflectionGenerator::getThis() */
ZEND_METHOD ( reflection_generator , getThis )
{
zend_generator * generator = ( zend_generator * ) Z_OBJ ( Z_REFLECTION_P ( getThis ( ) ) - > obj ) ;
zend_execute_data * ex = generator - > execute_data ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
REFLECTION_CHECK_VALID_GENERATOR ( ex )
if ( Z_OBJ ( ex - > This ) ) {
ZVAL_COPY ( return_value , & ex - > This ) ;
} else {
ZVAL_NULL ( return_value ) ;
}
}
/* }}} */
/* {{{ proto public Generator ReflectionGenerator::getExecutingGenerator() */
ZEND_METHOD ( reflection_generator , getExecutingGenerator )
{
zend_generator * generator = ( zend_generator * ) Z_OBJ ( Z_REFLECTION_P ( getThis ( ) ) - > obj ) ;
zend_execute_data * ex = generator - > execute_data ;
zend_generator * current ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
REFLECTION_CHECK_VALID_GENERATOR ( ex )
current = zend_generator_get_current ( generator ) ;
+ + GC_REFCOUNT ( current ) ;
ZVAL_OBJ ( return_value , ( zend_object * ) current ) ;
}
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ proto public static mixed ReflectionParameter::export(mixed function, mixed parameter [, bool return]) throws ReflectionException
Exports a reflection object . Returns the output if TRUE is specified for return , printing it otherwise . */
ZEND_METHOD ( reflection_parameter , export )
{
_reflection_export ( INTERNAL_FUNCTION_PARAM_PASSTHRU , reflection_parameter_ptr , 2 ) ;
}
/* }}} */
2006-03-06 09:50:44 +00:00
/* {{{ proto public void ReflectionParameter::__construct(mixed function, mixed parameter)
2005-11-30 21:53:20 +00:00
Constructor . Throws an Exception in case the given method does not exist */
ZEND_METHOD ( reflection_parameter , __construct )
{
parameter_reference * ref ;
2014-02-10 06:04:30 +00:00
zval * reference , * parameter ;
2005-11-30 21:53:20 +00:00
zval * object ;
2014-02-10 06:04:30 +00:00
zval name ;
2005-11-30 21:53:20 +00:00
reflection_object * intern ;
zend_function * fptr ;
struct _zend_arg_info * arg_info ;
int position ;
2014-12-22 13:44:39 +00:00
uint32_t num_args ;
2005-11-30 21:53:20 +00:00
zend_class_entry * ce = NULL ;
2009-01-26 22:54:34 +00:00
zend_bool is_closure = 0 ;
2014-12-03 13:56:09 +00:00
zend_bool is_invoke = 0 ;
2005-11-30 21:53:20 +00:00
2015-04-02 16:52:32 +00:00
if ( zend_parse_parameters_throw ( ZEND_NUM_ARGS ( ) , " zz " , & reference , & parameter ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
object = getThis ( ) ;
2014-03-17 04:15:22 +00:00
intern = Z_REFLECTION_P ( object ) ;
2005-11-30 21:53:20 +00:00
if ( intern = = NULL ) {
return ;
}
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
/* First, find the function */
switch ( Z_TYPE_P ( reference ) ) {
case IS_STRING : {
2014-10-29 13:28:16 +00:00
size_t lcname_len ;
2006-08-31 16:15:24 +00:00
char * lcname ;
2005-11-30 21:53:20 +00:00
2014-08-25 17:24:55 +00:00
lcname_len = Z_STRLEN_P ( reference ) ;
2005-11-30 21:53:20 +00:00
lcname = zend_str_tolower_dup ( Z_STRVAL_P ( reference ) , lcname_len ) ;
2014-02-10 06:04:30 +00:00
if ( ( fptr = zend_hash_str_find_ptr ( EG ( function_table ) , lcname , lcname_len ) ) = = NULL ) {
2005-11-30 21:53:20 +00:00
efree ( lcname ) ;
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2005-11-30 21:53:20 +00:00
" Function %s() does not exist " , Z_STRVAL_P ( reference ) ) ;
return ;
}
efree ( lcname ) ;
}
2006-03-12 17:22:34 +00:00
ce = fptr - > common . scope ;
2005-11-30 21:53:20 +00:00
break ;
case IS_ARRAY : {
2014-02-10 06:04:30 +00:00
zval * classref ;
zval * method ;
2014-10-29 13:28:16 +00:00
size_t lcname_len ;
2005-11-30 21:53:20 +00:00
char * lcname ;
2011-05-15 00:36:13 +00:00
2014-02-10 06:04:30 +00:00
if ( ( ( classref = zend_hash_index_find ( Z_ARRVAL_P ( reference ) , 0 ) ) = = NULL )
| | ( ( method = zend_hash_index_find ( Z_ARRVAL_P ( reference ) , 1 ) ) = = NULL ) )
2008-08-11 19:35:00 +00:00
{
2005-11-30 21:53:20 +00:00
_DO_THROW ( " Expected array($object, $method) or array($classname, $method) " ) ;
/* returns out of this function */
}
2014-02-10 06:04:30 +00:00
if ( Z_TYPE_P ( classref ) = = IS_OBJECT ) {
ce = Z_OBJCE_P ( classref ) ;
2005-11-30 21:53:20 +00:00
} else {
convert_to_string_ex ( classref ) ;
2014-12-13 22:06:14 +00:00
if ( ( ce = zend_lookup_class ( Z_STR_P ( classref ) ) ) = = NULL ) {
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2014-02-10 06:04:30 +00:00
" Class %s does not exist " , Z_STRVAL_P ( classref ) ) ;
2005-11-30 21:53:20 +00:00
return ;
}
}
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
convert_to_string_ex ( method ) ;
2014-08-25 17:24:55 +00:00
lcname_len = Z_STRLEN_P ( method ) ;
2014-02-10 06:04:30 +00:00
lcname = zend_str_tolower_dup ( Z_STRVAL_P ( method ) , lcname_len ) ;
if ( ce = = zend_ce_closure & & Z_TYPE_P ( classref ) = = IS_OBJECT
2008-08-11 19:35:00 +00:00
& & ( lcname_len = = sizeof ( ZEND_INVOKE_FUNC_NAME ) - 1 )
& & memcmp ( lcname , ZEND_INVOKE_FUNC_NAME , sizeof ( ZEND_INVOKE_FUNC_NAME ) - 1 ) = = 0
2014-12-13 22:06:14 +00:00
& & ( fptr = zend_get_closure_invoke_method ( Z_OBJ_P ( classref ) ) ) ! = NULL )
2015-01-03 09:22:58 +00:00
{
2010-04-19 19:45:03 +00:00
/* nothing to do. don't set is_closure since is the invoke handler,
2014-12-03 13:56:09 +00:00
not the closure itself */
is_invoke = 1 ;
2014-02-10 06:04:30 +00:00
} else if ( ( fptr = zend_hash_str_find_ptr ( & ce - > function_table , lcname , lcname_len ) ) = = NULL ) {
2005-11-30 21:53:20 +00:00
efree ( lcname ) ;
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2014-02-10 06:04:30 +00:00
" Method %s::%s() does not exist " , ce - > name - > val , Z_STRVAL_P ( method ) ) ;
2005-11-30 21:53:20 +00:00
return ;
}
efree ( lcname ) ;
}
break ;
2011-05-15 00:36:13 +00:00
2008-08-11 12:43:21 +00:00
case IS_OBJECT : {
ce = Z_OBJCE_P ( reference ) ;
2011-05-15 00:36:13 +00:00
2014-12-13 22:06:14 +00:00
if ( instanceof_function ( ce , zend_ce_closure ) ) {
fptr = ( zend_function * ) zend_get_closure_method_def ( reference ) ;
2009-01-26 22:54:34 +00:00
Z_ADDREF_P ( reference ) ;
is_closure = 1 ;
2014-02-10 06:04:30 +00:00
} else if ( ( fptr = zend_hash_str_find_ptr ( & ce - > function_table , ZEND_INVOKE_FUNC_NAME , sizeof ( ZEND_INVOKE_FUNC_NAME ) ) ) = = NULL ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2014-02-25 22:02:57 +00:00
" Method %s::%s() does not exist " , ce - > name - > val , ZEND_INVOKE_FUNC_NAME ) ;
2008-08-11 12:43:21 +00:00
return ;
}
}
break ;
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
default :
2008-08-11 12:43:21 +00:00
_DO_THROW ( " The parameter class is expected to be either a string, an array(class, method) or a callable object " ) ;
2005-11-30 21:53:20 +00:00
/* returns out of this function */
}
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
/* Now, search for the parameter */
arg_info = fptr - > common . arg_info ;
2014-12-22 13:44:39 +00:00
num_args = fptr - > common . num_args ;
if ( fptr - > common . fn_flags & ZEND_ACC_VARIADIC ) {
num_args + + ;
}
2014-08-25 17:24:55 +00:00
if ( Z_TYPE_P ( parameter ) = = IS_LONG ) {
2014-10-29 13:28:16 +00:00
position = ( int ) Z_LVAL_P ( parameter ) ;
2014-12-22 13:44:39 +00:00
if ( position < 0 | | ( uint32_t ) position > = num_args ) {
2015-04-10 20:01:00 +00:00
if ( fptr - > common . fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE ) {
2008-10-01 07:30:31 +00:00
if ( fptr - > type ! = ZEND_OVERLOADED_FUNCTION ) {
2014-08-25 17:24:55 +00:00
zend_string_release ( fptr - > common . function_name ) ;
2008-10-01 07:30:31 +00:00
}
2015-04-10 20:01:00 +00:00
zend_free_trampoline ( fptr ) ;
2008-10-01 07:30:31 +00:00
}
2009-02-01 15:06:19 +00:00
if ( is_closure ) {
2014-02-10 06:04:30 +00:00
zval_ptr_dtor ( reference ) ;
2009-02-01 15:06:19 +00:00
}
2005-11-30 21:53:20 +00:00
_DO_THROW ( " The parameter specified by its offset could not be found " ) ;
/* returns out of this function */
}
} else {
2014-08-25 17:28:33 +00:00
uint32_t i ;
2005-11-30 21:53:20 +00:00
position = - 1 ;
2006-08-31 16:15:24 +00:00
convert_to_string_ex ( parameter ) ;
2014-12-03 13:56:09 +00:00
if ( ! is_invoke & & fptr - > type = = ZEND_INTERNAL_FUNCTION ) {
2014-12-22 13:44:39 +00:00
for ( i = 0 ; i < num_args ; i + + ) {
2014-12-03 13:56:09 +00:00
if ( arg_info [ i ] . name ) {
if ( strcmp ( ( ( zend_internal_arg_info * ) arg_info ) [ i ] . name , Z_STRVAL_P ( parameter ) ) = = 0 ) {
position = i ;
break ;
}
}
}
} else {
2014-12-22 13:44:39 +00:00
for ( i = 0 ; i < num_args ; i + + ) {
2014-12-03 13:56:09 +00:00
if ( arg_info [ i ] . name ) {
if ( strcmp ( arg_info [ i ] . name - > val , Z_STRVAL_P ( parameter ) ) = = 0 ) {
position = i ;
break ;
}
}
2005-11-30 21:53:20 +00:00
}
}
if ( position = = - 1 ) {
2015-04-10 20:01:00 +00:00
if ( fptr - > common . fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE ) {
2008-10-01 07:30:31 +00:00
if ( fptr - > type ! = ZEND_OVERLOADED_FUNCTION ) {
2014-08-25 17:24:55 +00:00
zend_string_release ( fptr - > common . function_name ) ;
2008-10-01 07:30:31 +00:00
}
2015-04-10 20:01:00 +00:00
zend_free_trampoline ( fptr ) ;
2008-10-01 07:30:31 +00:00
}
2009-02-01 15:06:19 +00:00
if ( is_closure ) {
2014-02-10 06:04:30 +00:00
zval_ptr_dtor ( reference ) ;
2009-02-01 15:06:19 +00:00
}
2005-11-30 21:53:20 +00:00
_DO_THROW ( " The parameter specified by its name could not be found " ) ;
/* returns out of this function */
}
}
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
if ( arg_info [ position ] . name ) {
2014-12-03 13:56:09 +00:00
if ( fptr - > type = = ZEND_INTERNAL_FUNCTION ) {
ZVAL_STRING ( & name , ( ( zend_internal_arg_info * ) arg_info ) [ position ] . name ) ;
} else {
2015-03-12 13:53:51 +00:00
ZVAL_STR_COPY ( & name , arg_info [ position ] . name ) ;
2014-12-03 13:56:09 +00:00
}
2005-11-30 21:53:20 +00:00
} else {
2014-02-10 06:04:30 +00:00
ZVAL_NULL ( & name ) ;
2005-11-30 21:53:20 +00:00
}
2014-02-10 06:04:30 +00:00
reflection_update_property ( object , " name " , & name ) ;
2005-11-30 21:53:20 +00:00
ref = ( parameter_reference * ) emalloc ( sizeof ( parameter_reference ) ) ;
ref - > arg_info = & arg_info [ position ] ;
2014-08-25 17:28:33 +00:00
ref - > offset = ( uint32_t ) position ;
2005-11-30 21:53:20 +00:00
ref - > required = fptr - > common . required_num_args ;
ref - > fptr = fptr ;
2009-01-26 22:54:34 +00:00
/* TODO: copy fptr */
2005-11-30 21:53:20 +00:00
intern - > ptr = ref ;
2008-08-11 12:43:21 +00:00
intern - > ref_type = REF_TYPE_PARAMETER ;
2005-11-30 21:53:20 +00:00
intern - > ce = ce ;
2009-01-26 22:54:34 +00:00
if ( reference & & is_closure ) {
2014-02-10 06:04:30 +00:00
ZVAL_COPY_VALUE ( & intern - > obj , reference ) ;
2009-01-26 22:54:34 +00:00
}
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public string ReflectionParameter::__toString()
Returns a string representation */
ZEND_METHOD ( reflection_parameter , __toString )
{
reflection_object * intern ;
parameter_reference * param ;
string str ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( param ) ;
string_init ( & str ) ;
2014-12-13 22:06:14 +00:00
_parameter_string ( & str , param - > fptr , param - > arg_info , param - > offset , param - > required , " " ) ;
2015-03-12 13:53:51 +00:00
RETURN_NEW_STR ( str . buf ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public string ReflectionParameter::getName()
Returns this parameters ' s name */
ZEND_METHOD ( reflection_parameter , getName )
{
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2014-12-13 22:06:14 +00:00
_default_get_entry ( getThis ( ) , " name " , sizeof ( " name " ) - 1 , return_value ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
2006-03-12 17:22:34 +00:00
/* {{{ proto public ReflectionFunction ReflectionParameter::getDeclaringFunction()
Returns the ReflectionFunction for the function of this parameter */
ZEND_METHOD ( reflection_parameter , getDeclaringFunction )
2005-11-30 21:53:20 +00:00
{
reflection_object * intern ;
parameter_reference * param ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( param ) ;
2006-03-12 17:22:34 +00:00
if ( ! param - > fptr - > common . scope ) {
2014-12-13 22:06:14 +00:00
reflection_function_factory ( _copy_function ( param - > fptr ) , Z_ISUNDEF ( intern - > obj ) ? NULL : & intern - > obj , return_value ) ;
2005-11-30 21:53:20 +00:00
} else {
2014-12-13 22:06:14 +00:00
reflection_method_factory ( param - > fptr - > common . scope , _copy_function ( param - > fptr ) , Z_ISUNDEF ( intern - > obj ) ? NULL : & intern - > obj , return_value ) ;
2006-03-12 17:22:34 +00:00
}
}
/* }}} */
/* {{{ proto public ReflectionClass|NULL ReflectionParameter::getDeclaringClass()
Returns in which class this parameter is defined ( not the typehint of the parameter ) */
ZEND_METHOD ( reflection_parameter , getDeclaringClass )
{
reflection_object * intern ;
parameter_reference * param ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2006-03-12 17:22:34 +00:00
GET_REFLECTION_OBJECT_PTR ( param ) ;
if ( param - > fptr - > common . scope ) {
2014-12-13 22:06:14 +00:00
zend_reflection_class_factory ( param - > fptr - > common . scope , return_value ) ;
2011-05-15 00:36:13 +00:00
}
2006-03-12 17:22:34 +00:00
}
/* }}} */
/* {{{ proto public ReflectionClass|NULL ReflectionParameter::getClass()
Returns this parameters ' s class hint or NULL if there is none */
ZEND_METHOD ( reflection_parameter , getClass )
{
reflection_object * intern ;
parameter_reference * param ;
2014-02-10 06:04:30 +00:00
zend_class_entry * ce ;
2006-03-12 17:22:34 +00:00
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2006-03-12 17:22:34 +00:00
GET_REFLECTION_OBJECT_PTR ( param ) ;
2005-11-30 21:53:20 +00:00
2006-03-12 17:22:34 +00:00
if ( param - > arg_info - > class_name ) {
2006-12-22 15:37:48 +00:00
/* Class name is stored as a string, we might also get "self" or "parent"
* - For " self " , simply use the function scope . If scope is NULL then
* the function is global and thus self does not make any sense
*
* - For " parent " , use the function scope ' s parent . If scope is NULL then
* the function is global and thus parent does not make any sense .
* If the parent is NULL then the class does not extend anything and
* thus parent does not make any sense , either .
*
* TODO : Think about moving these checks to the compiler or some sort of
* lint - mode .
*/
2014-12-03 13:56:09 +00:00
const char * class_name ;
size_t class_name_len ;
if ( param - > fptr - > type = = ZEND_INTERNAL_FUNCTION ) {
class_name = ( ( zend_internal_arg_info * ) param - > arg_info ) - > class_name ;
class_name_len = strlen ( class_name ) ;
} else {
class_name = param - > arg_info - > class_name - > val ;
class_name_len = param - > arg_info - > class_name - > len ;
}
if ( 0 = = zend_binary_strcasecmp ( class_name , class_name_len , " self " , sizeof ( " self " ) - 1 ) ) {
2007-09-27 09:15:09 +00:00
ce = param - > fptr - > common . scope ;
2006-12-22 15:37:48 +00:00
if ( ! ce ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2008-08-11 19:35:00 +00:00
" Parameter uses 'self' as type hint but function is not a class member! " ) ;
return ;
2006-12-22 15:37:48 +00:00
}
2014-12-03 13:56:09 +00:00
} else if ( 0 = = zend_binary_strcasecmp ( class_name , class_name_len , " parent " , sizeof ( " parent " ) - 1 ) ) {
2007-09-27 09:15:09 +00:00
ce = param - > fptr - > common . scope ;
2006-12-22 15:37:48 +00:00
if ( ! ce ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2008-08-11 19:35:00 +00:00
" Parameter uses 'parent' as type hint but function is not a class member! " ) ;
return ;
2006-12-22 15:37:48 +00:00
}
if ( ! ce - > parent ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2008-08-11 19:35:00 +00:00
" Parameter uses 'parent' as type hint although class does not have a parent! " ) ;
return ;
2006-12-22 15:37:48 +00:00
}
2014-02-10 06:04:30 +00:00
ce = ce - > parent ;
} else {
2014-12-03 13:56:09 +00:00
if ( param - > fptr - > type = = ZEND_INTERNAL_FUNCTION ) {
zend_string * name = zend_string_init ( class_name , class_name_len , 0 ) ;
2014-12-13 22:06:14 +00:00
ce = zend_lookup_class ( name ) ;
2014-12-03 13:56:09 +00:00
zend_string_release ( name ) ;
} else {
2014-12-13 22:06:14 +00:00
ce = zend_lookup_class ( param - > arg_info - > class_name ) ;
2014-12-03 13:56:09 +00:00
}
2014-02-10 06:04:30 +00:00
if ( ! ce ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2014-12-03 13:56:09 +00:00
" Class %s does not exist " , class_name ) ;
2014-02-10 06:04:30 +00:00
return ;
}
2005-11-30 21:53:20 +00:00
}
2014-12-13 22:06:14 +00:00
zend_reflection_class_factory ( ce , return_value ) ;
2005-11-30 21:53:20 +00:00
}
}
/* }}} */
/* {{{ proto public bool ReflectionParameter::isArray()
Returns whether parameter MUST be an array */
ZEND_METHOD ( reflection_parameter , isArray )
{
reflection_object * intern ;
parameter_reference * param ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( param ) ;
2010-05-20 19:18:35 +00:00
RETVAL_BOOL ( param - > arg_info - > type_hint = = IS_ARRAY ) ;
}
/* }}} */
2011-08-16 10:44:47 +00:00
/* {{{ proto public bool ReflectionParameter::isCallable()
Returns whether parameter MUST be callable */
ZEND_METHOD ( reflection_parameter , isCallable )
{
reflection_object * intern ;
parameter_reference * param ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
GET_REFLECTION_OBJECT_PTR ( param ) ;
RETVAL_BOOL ( param - > arg_info - > type_hint = = IS_CALLABLE ) ;
}
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ proto public bool ReflectionParameter::allowsNull()
Returns whether NULL is allowed as this parameters ' s value */
ZEND_METHOD ( reflection_parameter , allowsNull )
{
reflection_object * intern ;
parameter_reference * param ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( param ) ;
RETVAL_BOOL ( param - > arg_info - > allow_null ) ;
}
/* }}} */
/* {{{ proto public bool ReflectionParameter::isPassedByReference()
Returns whether this parameters is passed to by reference */
ZEND_METHOD ( reflection_parameter , isPassedByReference )
{
reflection_object * intern ;
parameter_reference * param ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( param ) ;
RETVAL_BOOL ( param - > arg_info - > pass_by_reference ) ;
}
/* }}} */
2010-10-26 15:01:36 +00:00
/* {{{ proto public bool ReflectionParameter::canBePassedByValue()
Returns whether this parameter can be passed by value */
ZEND_METHOD ( reflection_parameter , canBePassedByValue )
{
reflection_object * intern ;
parameter_reference * param ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
GET_REFLECTION_OBJECT_PTR ( param ) ;
/* true if it's ZEND_SEND_BY_VAL or ZEND_SEND_PREFER_REF */
RETVAL_BOOL ( param - > arg_info - > pass_by_reference ! = ZEND_SEND_BY_REF ) ;
}
/* }}} */
2006-03-12 17:22:34 +00:00
/* {{{ proto public bool ReflectionParameter::getPosition()
Returns whether this parameter is an optional parameter */
ZEND_METHOD ( reflection_parameter , getPosition )
{
reflection_object * intern ;
parameter_reference * param ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2006-03-12 17:22:34 +00:00
GET_REFLECTION_OBJECT_PTR ( param ) ;
2014-08-25 17:24:55 +00:00
RETVAL_LONG ( param - > offset ) ;
2006-03-12 17:22:34 +00:00
}
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ proto public bool ReflectionParameter::isOptional()
Returns whether this parameter is an optional parameter */
ZEND_METHOD ( reflection_parameter , isOptional )
{
reflection_object * intern ;
parameter_reference * param ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( param ) ;
RETVAL_BOOL ( param - > offset > = param - > required ) ;
}
/* }}} */
/* {{{ proto public bool ReflectionParameter::isDefaultValueAvailable()
Returns whether the default value of this parameter is available */
ZEND_METHOD ( reflection_parameter , isDefaultValueAvailable )
{
reflection_object * intern ;
parameter_reference * param ;
zend_op * precv ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( param ) ;
if ( param - > fptr - > type ! = ZEND_USER_FUNCTION )
{
RETURN_FALSE ;
}
2012-08-01 12:23:30 +00:00
2005-11-30 21:53:20 +00:00
precv = _get_recv_op ( ( zend_op_array * ) param - > fptr , param - > offset ) ;
2010-04-20 10:57:45 +00:00
if ( ! precv | | precv - > opcode ! = ZEND_RECV_INIT | | precv - > op2_type = = IS_UNUSED ) {
2005-11-30 21:53:20 +00:00
RETURN_FALSE ;
}
RETURN_TRUE ;
}
/* }}} */
/* {{{ proto public bool ReflectionParameter::getDefaultValue()
Returns the default value of this parameter or throws an exception */
ZEND_METHOD ( reflection_parameter , getDefaultValue )
{
2012-05-23 05:50:12 +00:00
parameter_reference * param ;
zend_op * precv ;
2012-04-04 06:06:55 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
2012-05-31 15:31:00 +00:00
param = _reflection_param_get_default_param ( INTERNAL_FUNCTION_PARAM_PASSTHRU ) ;
if ( ! param ) {
2012-05-23 05:50:12 +00:00
return ;
}
2012-05-31 15:31:00 +00:00
precv = _reflection_param_get_default_precv ( INTERNAL_FUNCTION_PARAM_PASSTHRU , param ) ;
if ( ! precv ) {
2005-11-30 21:53:20 +00:00
return ;
}
2014-12-12 07:19:41 +00:00
ZVAL_COPY_VALUE ( return_value , RT_CONSTANT ( & param - > fptr - > op_array , precv - > op2 ) ) ;
2014-04-15 17:56:30 +00:00
if ( Z_CONSTANT_P ( return_value ) ) {
2014-07-23 21:54:21 +00:00
zend_class_entry * old_scope = EG ( scope ) ;
EG ( scope ) = param - > fptr - > common . scope ;
2014-12-13 22:06:14 +00:00
zval_update_constant_ex ( return_value , 0 , NULL ) ;
2014-07-23 21:54:21 +00:00
EG ( scope ) = old_scope ;
2014-04-15 17:56:30 +00:00
} else {
2013-11-01 15:16:58 +00:00
zval_copy_ctor ( return_value ) ;
2008-02-18 14:30:44 +00:00
}
2005-11-30 21:53:20 +00:00
}
/* }}} */
2015-02-10 21:17:43 +00:00
/* {{{ proto public bool ReflectionParameter::isDefaultValueConstant()
Returns whether the default value of this parameter is constant */
ZEND_METHOD ( reflection_parameter , isDefaultValueConstant )
{
zend_op * precv ;
parameter_reference * param ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
param = _reflection_param_get_default_param ( INTERNAL_FUNCTION_PARAM_PASSTHRU ) ;
if ( ! param ) {
RETURN_FALSE ;
}
precv = _reflection_param_get_default_precv ( INTERNAL_FUNCTION_PARAM_PASSTHRU , param ) ;
if ( precv & & Z_TYPE_P ( RT_CONSTANT ( & param - > fptr - > op_array , precv - > op2 ) ) = = IS_CONSTANT ) {
RETURN_TRUE ;
}
RETURN_FALSE ;
}
/* }}} */
/* {{{ proto public mixed ReflectionParameter::getDefaultValueConstantName()
Returns the default value ' s constant name if default value is constant or null */
ZEND_METHOD ( reflection_parameter , getDefaultValueConstantName )
{
zend_op * precv ;
parameter_reference * param ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
param = _reflection_param_get_default_param ( INTERNAL_FUNCTION_PARAM_PASSTHRU ) ;
if ( ! param ) {
return ;
}
precv = _reflection_param_get_default_precv ( INTERNAL_FUNCTION_PARAM_PASSTHRU , param ) ;
if ( precv & & Z_TYPE_P ( RT_CONSTANT ( & param - > fptr - > op_array , precv - > op2 ) ) = = IS_CONSTANT ) {
2015-03-12 13:53:51 +00:00
RETURN_STR_COPY ( Z_STR_P ( RT_CONSTANT ( & param - > fptr - > op_array , precv - > op2 ) ) ) ;
2015-02-10 21:17:43 +00:00
}
}
/* }}} */
2013-09-26 16:39:17 +00:00
/* {{{ proto public bool ReflectionParameter::isVariadic()
Returns whether this parameter is a variadic parameter */
ZEND_METHOD ( reflection_parameter , isVariadic )
{
reflection_object * intern ;
parameter_reference * param ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
GET_REFLECTION_OBJECT_PTR ( param ) ;
RETVAL_BOOL ( param - > arg_info - > is_variadic ) ;
}
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ proto public static mixed ReflectionMethod::export(mixed class, string name [, bool return]) throws ReflectionException
Exports a reflection object . Returns the output if TRUE is specified for return , printing it otherwise . */
ZEND_METHOD ( reflection_method , export )
{
_reflection_export ( INTERNAL_FUNCTION_PARAM_PASSTHRU , reflection_method_ptr , 2 ) ;
}
/* }}} */
2006-03-06 09:50:44 +00:00
/* {{{ proto public void ReflectionMethod::__construct(mixed class_or_method [, string name])
2005-11-30 21:53:20 +00:00
Constructor . Throws an Exception in case the given method does not exist */
ZEND_METHOD ( reflection_method , __construct )
{
2014-02-10 06:04:30 +00:00
zval name , * classname ;
2008-08-11 12:43:21 +00:00
zval * object , * orig_obj ;
2005-11-30 21:53:20 +00:00
reflection_object * intern ;
char * lcname ;
zend_class_entry * ce ;
zend_function * mptr ;
char * name_str , * tmp ;
2014-08-27 13:31:48 +00:00
size_t name_len , tmp_len ;
2005-11-30 21:53:20 +00:00
zval ztmp ;
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters_ex ( ZEND_PARSE_PARAMS_QUIET , ZEND_NUM_ARGS ( ) , " zs " , & classname , & name_str , & name_len ) = = FAILURE ) {
2015-04-02 16:52:32 +00:00
if ( zend_parse_parameters_throw ( ZEND_NUM_ARGS ( ) , " s " , & name_str , & name_len ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
2015-04-02 16:52:32 +00:00
2005-11-30 21:53:20 +00:00
if ( ( tmp = strstr ( name_str , " :: " ) ) = = NULL ) {
2015-04-02 16:52:32 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
" Invalid method name %s " , name_str ) ;
2005-11-30 21:53:20 +00:00
return ;
}
classname = & ztmp ;
tmp_len = tmp - name_str ;
2014-02-10 06:04:30 +00:00
ZVAL_STRINGL ( classname , name_str , tmp_len ) ;
2005-11-30 21:53:20 +00:00
name_len = name_len - ( tmp_len + 2 ) ;
name_str = tmp + 2 ;
2008-08-11 12:43:21 +00:00
orig_obj = NULL ;
} else if ( Z_TYPE_P ( classname ) = = IS_OBJECT ) {
orig_obj = classname ;
} else {
orig_obj = NULL ;
2005-11-30 21:53:20 +00:00
}
object = getThis ( ) ;
2014-03-17 04:15:22 +00:00
intern = Z_REFLECTION_P ( object ) ;
2005-11-30 21:53:20 +00:00
if ( intern = = NULL ) {
return ;
}
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
/* Find the class entry */
switch ( Z_TYPE_P ( classname ) ) {
case IS_STRING :
2014-12-13 22:06:14 +00:00
if ( ( ce = zend_lookup_class ( Z_STR_P ( classname ) ) ) = = NULL ) {
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2011-05-15 00:36:13 +00:00
" Class %s does not exist " , Z_STRVAL_P ( classname ) ) ;
2006-10-11 15:52:56 +00:00
if ( classname = = & ztmp ) {
zval_dtor ( & ztmp ) ;
}
2005-11-30 21:53:20 +00:00
return ;
}
break ;
case IS_OBJECT :
ce = Z_OBJCE_P ( classname ) ;
break ;
default :
2006-10-11 15:52:56 +00:00
if ( classname = = & ztmp ) {
zval_dtor ( & ztmp ) ;
}
2005-11-30 21:53:20 +00:00
_DO_THROW ( " The parameter class is expected to be either a string or an object " ) ;
/* returns out of this function */
}
if ( classname = = & ztmp ) {
zval_dtor ( & ztmp ) ;
}
lcname = zend_str_tolower_dup ( name_str , name_len ) ;
2008-08-11 19:35:00 +00:00
if ( ce = = zend_ce_closure & & orig_obj & & ( name_len = = sizeof ( ZEND_INVOKE_FUNC_NAME ) - 1 )
& & memcmp ( lcname , ZEND_INVOKE_FUNC_NAME , sizeof ( ZEND_INVOKE_FUNC_NAME ) - 1 ) = = 0
2014-12-13 22:06:14 +00:00
& & ( mptr = zend_get_closure_invoke_method ( Z_OBJ_P ( orig_obj ) ) ) ! = NULL )
2008-08-11 19:35:00 +00:00
{
2008-08-11 12:43:21 +00:00
/* do nothing, mptr already set */
2014-02-10 06:04:30 +00:00
} else if ( ( mptr = zend_hash_str_find_ptr ( & ce - > function_table , lcname , name_len ) ) = = NULL ) {
2009-01-26 22:54:34 +00:00
efree ( lcname ) ;
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2014-02-10 06:04:30 +00:00
" Method %s::%s() does not exist " , ce - > name - > val , name_str ) ;
2009-01-26 22:54:34 +00:00
return ;
2005-11-30 21:53:20 +00:00
}
efree ( lcname ) ;
2014-09-19 13:32:50 +00:00
ZVAL_STR_COPY ( & name , mptr - > common . scope - > name ) ;
2014-02-10 06:04:30 +00:00
reflection_update_property ( object , " class " , & name ) ;
2014-09-19 13:32:50 +00:00
ZVAL_STR_COPY ( & name , mptr - > common . function_name ) ;
2014-02-10 06:04:30 +00:00
reflection_update_property ( object , " name " , & name ) ;
2005-11-30 21:53:20 +00:00
intern - > ptr = mptr ;
2008-08-11 12:43:21 +00:00
intern - > ref_type = REF_TYPE_FUNCTION ;
2005-11-30 21:53:20 +00:00
intern - > ce = ce ;
}
/* }}} */
/* {{{ proto public string ReflectionMethod::__toString()
Returns a string representation */
ZEND_METHOD ( reflection_method , __toString )
{
reflection_object * intern ;
zend_function * mptr ;
string str ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( mptr ) ;
string_init ( & str ) ;
2014-12-13 22:06:14 +00:00
_function_string ( & str , mptr , intern - > ce , " " ) ;
2015-03-12 13:53:51 +00:00
RETURN_NEW_STR ( str . buf ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
2010-04-19 19:45:03 +00:00
/* {{{ proto public mixed ReflectionMethod::getClosure([mixed object])
Invokes the function */
ZEND_METHOD ( reflection_method , getClosure )
{
reflection_object * intern ;
zval * obj ;
zend_function * mptr ;
2011-05-15 00:36:13 +00:00
2010-04-19 19:45:03 +00:00
METHOD_NOTSTATIC ( reflection_method_ptr ) ;
GET_REFLECTION_OBJECT_PTR ( mptr ) ;
if ( mptr - > common . fn_flags & ZEND_ACC_STATIC ) {
2015-05-05 19:40:28 +00:00
zend_create_closure ( return_value , mptr , mptr - > common . scope , mptr - > common . scope , NULL ) ;
2010-04-19 19:45:03 +00:00
} else {
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " o " , & obj ) = = FAILURE ) {
2010-04-19 19:45:03 +00:00
return ;
}
2014-12-13 22:06:14 +00:00
if ( ! instanceof_function ( Z_OBJCE_P ( obj ) , mptr - > common . scope ) ) {
2010-04-19 19:45:03 +00:00
_DO_THROW ( " Given object is not an instance of the class this method was declared in " ) ;
/* Returns from this function */
}
/* This is an original closure object and __invoke is to be called. */
2015-04-10 20:01:00 +00:00
if ( Z_OBJCE_P ( obj ) = = zend_ce_closure & &
( mptr - > internal_function . fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE ) )
2010-04-19 19:45:03 +00:00
{
RETURN_ZVAL ( obj , 1 , 0 ) ;
} else {
2015-05-05 19:40:28 +00:00
zend_create_closure ( return_value , mptr , mptr - > common . scope , Z_OBJCE_P ( obj ) , obj ) ;
2010-04-19 19:45:03 +00:00
}
}
}
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ proto public mixed ReflectionMethod::invoke(mixed object, mixed* args)
Invokes the method . */
ZEND_METHOD ( reflection_method , invoke )
{
2014-02-10 06:04:30 +00:00
zval retval ;
zval * params = NULL ;
2014-03-27 22:11:22 +00:00
zend_object * object ;
2005-11-30 21:53:20 +00:00
reflection_object * intern ;
zend_function * mptr ;
2008-06-21 02:41:27 +00:00
int result , num_args = 0 ;
2005-11-30 21:53:20 +00:00
zend_fcall_info fci ;
zend_fcall_info_cache fcc ;
zend_class_entry * obj_ce ;
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
METHOD_NOTSTATIC ( reflection_method_ptr ) ;
GET_REFLECTION_OBJECT_PTR ( mptr ) ;
2009-09-16 17:24:46 +00:00
if ( ( ! ( mptr - > common . fn_flags & ZEND_ACC_PUBLIC )
| | ( mptr - > common . fn_flags & ZEND_ACC_ABSTRACT ) )
& & intern - > ignore_visibility = = 0 )
2008-08-11 19:35:00 +00:00
{
2005-11-30 21:53:20 +00:00
if ( mptr - > common . fn_flags & ZEND_ACC_ABSTRACT ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2011-05-15 00:36:13 +00:00
" Trying to invoke abstract method %s::%s() " ,
2014-02-25 22:02:57 +00:00
mptr - > common . scope - > name - > val , mptr - > common . function_name - > val ) ;
2005-11-30 21:53:20 +00:00
} else {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2011-05-15 00:36:13 +00:00
" Trying to invoke %s method %s::%s() from scope %s " ,
2005-11-30 21:53:20 +00:00
mptr - > common . fn_flags & ZEND_ACC_PROTECTED ? " protected " : " private " ,
2014-02-25 22:02:57 +00:00
mptr - > common . scope - > name - > val , mptr - > common . function_name - > val ,
Z_OBJCE_P ( getThis ( ) ) - > name - > val ) ;
2005-11-30 21:53:20 +00:00
}
return ;
}
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " + " , & params , & num_args ) = = FAILURE ) {
2008-06-21 02:41:27 +00:00
return ;
2005-11-30 21:53:20 +00:00
}
2011-05-15 00:36:13 +00:00
2008-11-27 19:01:23 +00:00
/* In case this is a static method, we should'nt pass an object_ptr
2005-11-30 21:53:20 +00:00
* ( which is used as calling context aka $ this ) . We can thus ignore the
* first parameter .
*
* Else , we verify that the given object is an instance of the class .
*/
if ( mptr - > common . fn_flags & ZEND_ACC_STATIC ) {
2014-03-27 22:11:22 +00:00
object = NULL ;
2008-07-25 09:44:47 +00:00
obj_ce = mptr - > common . scope ;
2005-11-30 21:53:20 +00:00
} else {
2014-02-10 06:04:30 +00:00
if ( Z_TYPE ( params [ 0 ] ) ! = IS_OBJECT ) {
2005-11-30 21:53:20 +00:00
_DO_THROW ( " Non-object passed to Invoke() " ) ;
/* Returns from this function */
}
2008-06-21 02:41:27 +00:00
2014-02-10 06:04:30 +00:00
obj_ce = Z_OBJCE ( params [ 0 ] ) ;
2005-11-30 21:53:20 +00:00
2014-12-13 22:06:14 +00:00
if ( ! instanceof_function ( obj_ce , mptr - > common . scope ) ) {
2005-11-30 21:53:20 +00:00
_DO_THROW ( " Given object is not an instance of the class this method was declared in " ) ;
/* Returns from this function */
}
2011-05-15 00:36:13 +00:00
2014-03-27 22:11:22 +00:00
object = Z_OBJ ( params [ 0 ] ) ;
2005-11-30 21:53:20 +00:00
}
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
fci . size = sizeof ( fci ) ;
fci . function_table = NULL ;
2014-02-10 06:04:30 +00:00
ZVAL_UNDEF ( & fci . function_name ) ;
2005-11-30 21:53:20 +00:00
fci . symbol_table = NULL ;
2014-03-27 22:11:22 +00:00
fci . object = object ;
2014-02-10 06:04:30 +00:00
fci . retval = & retval ;
2008-06-21 02:41:27 +00:00
fci . param_count = num_args - 1 ;
fci . params = params + 1 ;
2005-11-30 21:53:20 +00:00
fci . no_separation = 1 ;
fcc . initialized = 1 ;
fcc . function_handler = mptr ;
fcc . calling_scope = obj_ce ;
2011-11-24 09:16:11 +00:00
fcc . called_scope = intern - > ce ;
2014-03-27 22:11:22 +00:00
fcc . object = object ;
2005-11-30 21:53:20 +00:00
2014-12-13 22:06:14 +00:00
result = zend_call_function ( & fci , & fcc ) ;
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
if ( result = = FAILURE ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2014-02-25 22:02:57 +00:00
" Invocation of method %s::%s() failed " , mptr - > common . scope - > name - > val , mptr - > common . function_name - > val ) ;
2005-11-30 21:53:20 +00:00
return ;
}
2014-02-10 06:04:30 +00:00
if ( Z_TYPE ( retval ) ! = IS_UNDEF ) {
2014-04-15 11:40:40 +00:00
ZVAL_COPY_VALUE ( return_value , & retval ) ;
2005-11-30 21:53:20 +00:00
}
}
/* }}} */
/* {{{ proto public mixed ReflectionMethod::invokeArgs(mixed object, array args)
Invokes the function and pass its arguments as array . */
ZEND_METHOD ( reflection_method , invokeArgs )
{
2014-02-10 06:04:30 +00:00
zval retval ;
2014-05-28 08:34:08 +00:00
zval * params , * val , * object ;
2005-11-30 21:53:20 +00:00
reflection_object * intern ;
zend_function * mptr ;
2014-04-16 13:06:25 +00:00
int i , argc ;
2005-11-30 21:53:20 +00:00
int result ;
zend_fcall_info fci ;
zend_fcall_info_cache fcc ;
zend_class_entry * obj_ce ;
zval * param_array ;
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
METHOD_NOTSTATIC ( reflection_method_ptr ) ;
GET_REFLECTION_OBJECT_PTR ( mptr ) ;
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " o!a " , & object , & param_array ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
2009-09-16 17:24:46 +00:00
if ( ( ! ( mptr - > common . fn_flags & ZEND_ACC_PUBLIC )
| | ( mptr - > common . fn_flags & ZEND_ACC_ABSTRACT ) )
& & intern - > ignore_visibility = = 0 )
2008-08-11 19:35:00 +00:00
{
2005-11-30 21:53:20 +00:00
if ( mptr - > common . fn_flags & ZEND_ACC_ABSTRACT ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2011-05-15 00:36:13 +00:00
" Trying to invoke abstract method %s::%s() " ,
2014-02-25 22:02:57 +00:00
mptr - > common . scope - > name - > val , mptr - > common . function_name - > val ) ;
2005-11-30 21:53:20 +00:00
} else {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2011-05-15 00:36:13 +00:00
" Trying to invoke %s method %s::%s() from scope %s " ,
2005-11-30 21:53:20 +00:00
mptr - > common . fn_flags & ZEND_ACC_PROTECTED ? " protected " : " private " ,
2014-02-25 22:02:57 +00:00
mptr - > common . scope - > name - > val , mptr - > common . function_name - > val ,
Z_OBJCE_P ( getThis ( ) ) - > name - > val ) ;
2005-11-30 21:53:20 +00:00
}
return ;
}
argc = zend_hash_num_elements ( Z_ARRVAL_P ( param_array ) ) ;
2011-05-15 00:36:13 +00:00
2014-02-10 06:04:30 +00:00
params = safe_emalloc ( sizeof ( zval ) , argc , 0 ) ;
2014-05-28 08:34:08 +00:00
argc = 0 ;
ZEND_HASH_FOREACH_VAL ( Z_ARRVAL_P ( param_array ) , val ) {
ZVAL_COPY ( & params [ argc ] , val ) ;
argc + + ;
} ZEND_HASH_FOREACH_END ( ) ;
2011-05-15 00:36:13 +00:00
2008-11-27 19:01:23 +00:00
/* In case this is a static method, we should'nt pass an object_ptr
2005-11-30 21:53:20 +00:00
* ( which is used as calling context aka $ this ) . We can thus ignore the
* first parameter .
*
* Else , we verify that the given object is an instance of the class .
*/
if ( mptr - > common . fn_flags & ZEND_ACC_STATIC ) {
object = NULL ;
2008-07-25 09:44:47 +00:00
obj_ce = mptr - > common . scope ;
2005-11-30 21:53:20 +00:00
} else {
if ( ! object ) {
efree ( params ) ;
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2011-05-15 00:36:13 +00:00
" Trying to invoke non static method %s::%s() without an object " ,
2014-02-25 22:02:57 +00:00
mptr - > common . scope - > name - > val , mptr - > common . function_name - > val ) ;
2005-11-30 21:53:20 +00:00
return ;
}
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
obj_ce = Z_OBJCE_P ( object ) ;
2014-12-13 22:06:14 +00:00
if ( ! instanceof_function ( obj_ce , mptr - > common . scope ) ) {
2005-11-30 21:53:20 +00:00
efree ( params ) ;
_DO_THROW ( " Given object is not an instance of the class this method was declared in " ) ;
/* Returns from this function */
}
}
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
fci . size = sizeof ( fci ) ;
fci . function_table = NULL ;
2014-02-10 06:04:30 +00:00
ZVAL_UNDEF ( & fci . function_name ) ;
2005-11-30 21:53:20 +00:00
fci . symbol_table = NULL ;
2014-03-27 22:11:22 +00:00
fci . object = object ? Z_OBJ_P ( object ) : NULL ;
2014-02-10 06:04:30 +00:00
fci . retval = & retval ;
2005-11-30 21:53:20 +00:00
fci . param_count = argc ;
fci . params = params ;
fci . no_separation = 1 ;
fcc . initialized = 1 ;
fcc . function_handler = mptr ;
fcc . calling_scope = obj_ce ;
2012-03-02 03:36:30 +00:00
fcc . called_scope = intern - > ce ;
2014-03-27 22:11:22 +00:00
fcc . object = ( object ) ? Z_OBJ_P ( object ) : NULL ;
2015-01-03 09:22:58 +00:00
/*
2012-06-23 18:10:47 +00:00
* Copy the zend_function when calling via handler ( e . g . Closure : : __invoke ( ) )
2012-06-22 15:05:29 +00:00
*/
2015-04-10 20:01:00 +00:00
if ( ( mptr - > internal_function . fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE ) ) {
2014-12-13 22:06:14 +00:00
fcc . function_handler = _copy_function ( mptr ) ;
2012-06-22 15:05:29 +00:00
}
2005-11-30 21:53:20 +00:00
2014-12-13 22:06:14 +00:00
result = zend_call_function ( & fci , & fcc ) ;
2011-05-15 00:36:13 +00:00
2014-04-16 13:06:25 +00:00
for ( i = 0 ; i < argc ; i + + ) {
zval_ptr_dtor ( & params [ i ] ) ;
}
2005-11-30 21:53:20 +00:00
efree ( params ) ;
if ( result = = FAILURE ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2014-02-25 22:02:57 +00:00
" Invocation of method %s::%s() failed " , mptr - > common . scope - > name - > val , mptr - > common . function_name - > val ) ;
2005-11-30 21:53:20 +00:00
return ;
}
2014-02-10 06:04:30 +00:00
if ( Z_TYPE ( retval ) ! = IS_UNDEF ) {
2014-04-15 11:40:40 +00:00
ZVAL_COPY_VALUE ( return_value , & retval ) ;
2005-11-30 21:53:20 +00:00
}
}
/* }}} */
/* {{{ proto public bool ReflectionMethod::isFinal()
Returns whether this method is final */
ZEND_METHOD ( reflection_method , isFinal )
{
_function_check_flag ( INTERNAL_FUNCTION_PARAM_PASSTHRU , ZEND_ACC_FINAL ) ;
}
/* }}} */
/* {{{ proto public bool ReflectionMethod::isAbstract()
Returns whether this method is abstract */
ZEND_METHOD ( reflection_method , isAbstract )
{
_function_check_flag ( INTERNAL_FUNCTION_PARAM_PASSTHRU , ZEND_ACC_ABSTRACT ) ;
}
/* }}} */
/* {{{ proto public bool ReflectionMethod::isPublic()
Returns whether this method is public */
ZEND_METHOD ( reflection_method , isPublic )
{
_function_check_flag ( INTERNAL_FUNCTION_PARAM_PASSTHRU , ZEND_ACC_PUBLIC ) ;
}
/* }}} */
/* {{{ proto public bool ReflectionMethod::isPrivate()
Returns whether this method is private */
ZEND_METHOD ( reflection_method , isPrivate )
{
_function_check_flag ( INTERNAL_FUNCTION_PARAM_PASSTHRU , ZEND_ACC_PRIVATE ) ;
}
/* }}} */
/* {{{ proto public bool ReflectionMethod::isProtected()
Returns whether this method is protected */
ZEND_METHOD ( reflection_method , isProtected )
{
_function_check_flag ( INTERNAL_FUNCTION_PARAM_PASSTHRU , ZEND_ACC_PROTECTED ) ;
}
/* }}} */
/* {{{ proto public bool ReflectionMethod::isStatic()
Returns whether this method is static */
ZEND_METHOD ( reflection_method , isStatic )
{
_function_check_flag ( INTERNAL_FUNCTION_PARAM_PASSTHRU , ZEND_ACC_STATIC ) ;
}
/* }}} */
2006-02-25 18:25:45 +00:00
/* {{{ proto public bool ReflectionFunction::isDeprecated()
Returns whether this function is deprecated */
ZEND_METHOD ( reflection_function , isDeprecated )
{
_function_check_flag ( INTERNAL_FUNCTION_PARAM_PASSTHRU , ZEND_ACC_DEPRECATED ) ;
}
/* }}} */
2012-09-02 15:29:56 +00:00
/* {{{ proto public bool ReflectionFunction::isGenerator()
Returns whether this function is a generator */
ZEND_METHOD ( reflection_function , isGenerator )
{
_function_check_flag ( INTERNAL_FUNCTION_PARAM_PASSTHRU , ZEND_ACC_GENERATOR ) ;
}
/* }}} */
2013-09-26 16:39:17 +00:00
/* {{{ proto public bool ReflectionFunction::isVariadic()
Returns whether this function is variadic */
ZEND_METHOD ( reflection_function , isVariadic )
{
_function_check_flag ( INTERNAL_FUNCTION_PARAM_PASSTHRU , ZEND_ACC_VARIADIC ) ;
}
/* }}} */
2008-06-25 12:33:46 +00:00
/* {{{ proto public bool ReflectionFunction::inNamespace()
Returns whether this function is defined in namespace */
ZEND_METHOD ( reflection_function , inNamespace )
{
2014-02-10 06:04:30 +00:00
zval * name ;
2010-11-19 15:48:11 +00:00
const char * backslash ;
2008-06-25 12:33:46 +00:00
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2014-12-13 22:06:14 +00:00
if ( ( name = _default_load_entry ( getThis ( ) , " name " , sizeof ( " name " ) - 1 ) ) = = NULL ) {
2008-06-25 12:33:46 +00:00
RETURN_FALSE ;
}
2014-02-10 06:04:30 +00:00
if ( Z_TYPE_P ( name ) = = IS_STRING
2014-08-25 17:24:55 +00:00
& & ( backslash = zend_memrchr ( Z_STRVAL_P ( name ) , ' \\ ' , Z_STRLEN_P ( name ) ) )
2014-02-10 06:04:30 +00:00
& & backslash > Z_STRVAL_P ( name ) )
2008-08-11 19:35:00 +00:00
{
2008-06-25 12:33:46 +00:00
RETURN_TRUE ;
2008-06-27 06:43:21 +00:00
}
2008-06-25 12:33:46 +00:00
RETURN_FALSE ;
}
/* }}} */
/* {{{ proto public string ReflectionFunction::getNamespaceName()
Returns the name of namespace where this function is defined */
ZEND_METHOD ( reflection_function , getNamespaceName )
{
2014-02-10 06:04:30 +00:00
zval * name ;
2010-11-19 15:48:11 +00:00
const char * backslash ;
2008-06-25 12:33:46 +00:00
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2014-12-13 22:06:14 +00:00
if ( ( name = _default_load_entry ( getThis ( ) , " name " , sizeof ( " name " ) - 1 ) ) = = NULL ) {
2008-06-25 12:33:46 +00:00
RETURN_FALSE ;
}
2014-02-10 06:04:30 +00:00
if ( Z_TYPE_P ( name ) = = IS_STRING
2014-08-25 17:24:55 +00:00
& & ( backslash = zend_memrchr ( Z_STRVAL_P ( name ) , ' \\ ' , Z_STRLEN_P ( name ) ) )
2014-02-10 06:04:30 +00:00
& & backslash > Z_STRVAL_P ( name ) )
2008-08-11 19:35:00 +00:00
{
2014-02-10 06:04:30 +00:00
RETURN_STRINGL ( Z_STRVAL_P ( name ) , backslash - Z_STRVAL_P ( name ) ) ;
2008-06-27 06:43:21 +00:00
}
2008-06-25 12:33:46 +00:00
RETURN_EMPTY_STRING ( ) ;
}
/* }}} */
/* {{{ proto public string ReflectionFunction::getShortName()
Returns the short name of the function ( without namespace part ) */
ZEND_METHOD ( reflection_function , getShortName )
{
2014-02-10 06:04:30 +00:00
zval * name ;
2010-11-19 15:48:11 +00:00
const char * backslash ;
2008-06-25 12:33:46 +00:00
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2014-12-13 22:06:14 +00:00
if ( ( name = _default_load_entry ( getThis ( ) , " name " , sizeof ( " name " ) - 1 ) ) = = NULL ) {
2008-06-25 12:33:46 +00:00
RETURN_FALSE ;
}
2014-02-10 06:04:30 +00:00
if ( Z_TYPE_P ( name ) = = IS_STRING
2014-08-25 17:24:55 +00:00
& & ( backslash = zend_memrchr ( Z_STRVAL_P ( name ) , ' \\ ' , Z_STRLEN_P ( name ) ) )
2014-02-10 06:04:30 +00:00
& & backslash > Z_STRVAL_P ( name ) )
2008-08-11 19:35:00 +00:00
{
2014-08-25 17:24:55 +00:00
RETURN_STRINGL ( backslash + 1 , Z_STRLEN_P ( name ) - ( backslash - Z_STRVAL_P ( name ) + 1 ) ) ;
2008-06-27 06:43:21 +00:00
}
2014-02-10 06:04:30 +00:00
RETURN_ZVAL ( name , 1 , 0 ) ;
2008-06-25 12:33:46 +00:00
}
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ proto public bool ReflectionMethod::isConstructor()
Returns whether this method is the constructor */
ZEND_METHOD ( reflection_method , isConstructor )
{
reflection_object * intern ;
zend_function * mptr ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( mptr ) ;
2011-05-15 00:36:13 +00:00
/* we need to check if the ctor is the ctor of the class level we we
2005-11-30 21:53:20 +00:00
* looking at since we might be looking at an inherited old style ctor
* defined in base class . */
RETURN_BOOL ( mptr - > common . fn_flags & ZEND_ACC_CTOR & & intern - > ce - > constructor & & intern - > ce - > constructor - > common . scope = = mptr - > common . scope ) ;
}
/* }}} */
/* {{{ proto public bool ReflectionMethod::isDestructor()
Returns whether this method is static */
ZEND_METHOD ( reflection_method , isDestructor )
{
reflection_object * intern ;
zend_function * mptr ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( mptr ) ;
RETURN_BOOL ( mptr - > common . fn_flags & ZEND_ACC_DTOR ) ;
}
/* }}} */
/* {{{ proto public int ReflectionMethod::getModifiers()
Returns a bitfield of the access modifiers for this method */
ZEND_METHOD ( reflection_method , getModifiers )
{
reflection_object * intern ;
zend_function * mptr ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( mptr ) ;
2014-08-25 17:24:55 +00:00
RETURN_LONG ( mptr - > common . fn_flags ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public ReflectionClass ReflectionMethod::getDeclaringClass()
Get the declaring class */
ZEND_METHOD ( reflection_method , getDeclaringClass )
{
reflection_object * intern ;
zend_function * mptr ;
METHOD_NOTSTATIC ( reflection_method_ptr ) ;
GET_REFLECTION_OBJECT_PTR ( mptr ) ;
2011-05-15 00:36:13 +00:00
2010-08-21 16:09:18 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
2014-12-13 22:06:14 +00:00
zend_reflection_class_factory ( mptr - > common . scope , return_value ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public ReflectionClass ReflectionMethod::getPrototype()
Get the prototype */
ZEND_METHOD ( reflection_method , getPrototype )
{
reflection_object * intern ;
zend_function * mptr ;
METHOD_NOTSTATIC ( reflection_method_ptr ) ;
GET_REFLECTION_OBJECT_PTR ( mptr ) ;
2011-05-15 00:36:13 +00:00
2010-08-21 16:09:18 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
if ( ! mptr - > common . prototype ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2014-02-25 22:02:57 +00:00
" Method %s::%s does not have a prototype " , intern - > ce - > name - > val , mptr - > common . function_name - > val ) ;
2005-11-30 21:53:20 +00:00
return ;
}
2014-12-13 22:06:14 +00:00
reflection_method_factory ( mptr - > common . prototype - > common . scope , mptr - > common . prototype , NULL , return_value ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
2009-10-03 20:45:29 +00:00
/* {{{ proto public void ReflectionMethod::setAccessible(bool visible)
2009-09-16 17:24:46 +00:00
Sets whether non - public methods can be invoked */
ZEND_METHOD ( reflection_method , setAccessible )
{
reflection_object * intern ;
zend_bool visible ;
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " b " , & visible ) = = FAILURE ) {
2009-09-16 17:24:46 +00:00
return ;
}
2014-03-17 04:15:22 +00:00
intern = Z_REFLECTION_P ( getThis ( ) ) ;
2009-09-16 17:24:46 +00:00
if ( intern = = NULL ) {
return ;
}
intern - > ignore_visibility = visible ;
}
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ proto public static mixed ReflectionClass::export(mixed argument [, bool return]) throws ReflectionException
Exports a reflection object . Returns the output if TRUE is specified for return , printing it otherwise . */
ZEND_METHOD ( reflection_class , export )
{
_reflection_export ( INTERNAL_FUNCTION_PARAM_PASSTHRU , reflection_class_ptr , 1 ) ;
}
/* }}} */
/* {{{ reflection_class_object_ctor */
static void reflection_class_object_ctor ( INTERNAL_FUNCTION_PARAMETERS , int is_object )
{
zval * argument ;
zval * object ;
2014-02-10 06:04:30 +00:00
zval classname ;
2005-11-30 21:53:20 +00:00
reflection_object * intern ;
2014-02-10 06:04:30 +00:00
zend_class_entry * ce ;
2005-11-30 21:53:20 +00:00
if ( is_object ) {
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " o " , & argument ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
} else {
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " z/ " , & argument ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
}
object = getThis ( ) ;
2014-03-17 04:15:22 +00:00
intern = Z_REFLECTION_P ( object ) ;
2005-11-30 21:53:20 +00:00
if ( intern = = NULL ) {
return ;
}
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
if ( Z_TYPE_P ( argument ) = = IS_OBJECT ) {
2014-09-19 13:32:50 +00:00
ZVAL_STR_COPY ( & classname , Z_OBJCE_P ( argument ) - > name ) ;
2014-02-10 06:04:30 +00:00
reflection_update_property ( object , " name " , & classname ) ;
2005-11-30 21:53:20 +00:00
intern - > ptr = Z_OBJCE_P ( argument ) ;
if ( is_object ) {
2014-02-10 06:04:30 +00:00
ZVAL_COPY_VALUE ( & intern - > obj , argument ) ;
zval_add_ref ( argument ) ;
2005-11-30 21:53:20 +00:00
}
2011-05-15 00:36:13 +00:00
} else {
2014-02-10 06:04:30 +00:00
convert_to_string_ex ( argument ) ;
2014-12-13 22:06:14 +00:00
if ( ( ce = zend_lookup_class ( Z_STR_P ( argument ) ) ) = = NULL ) {
2005-11-30 21:53:20 +00:00
if ( ! EG ( exception ) ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , - 1 , " Class %s does not exist " , Z_STRVAL_P ( argument ) ) ;
2005-11-30 21:53:20 +00:00
}
return ;
}
2014-09-19 13:32:50 +00:00
ZVAL_STR_COPY ( & classname , ce - > name ) ;
2014-02-10 06:04:30 +00:00
reflection_update_property ( object , " name " , & classname ) ;
2005-11-30 21:53:20 +00:00
2014-02-10 06:04:30 +00:00
intern - > ptr = ce ;
2005-11-30 21:53:20 +00:00
}
2008-08-11 12:43:21 +00:00
intern - > ref_type = REF_TYPE_OTHER ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
2006-03-06 09:50:44 +00:00
/* {{{ proto public void ReflectionClass::__construct(mixed argument) throws ReflectionException
2005-11-30 21:53:20 +00:00
Constructor . Takes a string or an instance as an argument */
ZEND_METHOD ( reflection_class , __construct )
{
reflection_class_object_ctor ( INTERNAL_FUNCTION_PARAM_PASSTHRU , 0 ) ;
}
/* }}} */
2010-05-24 14:11:39 +00:00
/* {{{ add_class_vars */
2014-12-13 22:06:14 +00:00
static void add_class_vars ( zend_class_entry * ce , int statics , zval * return_value )
2010-05-24 14:11:39 +00:00
{
zend_property_info * prop_info ;
2014-02-10 06:04:30 +00:00
zval * prop , prop_copy ;
zend_string * key ;
2010-05-24 14:11:39 +00:00
2014-12-03 13:56:09 +00:00
ZEND_HASH_FOREACH_STR_KEY_PTR ( & ce - > properties_info , key , prop_info ) {
2010-05-24 14:11:39 +00:00
if ( ( ( prop_info - > flags & ZEND_ACC_SHADOW ) & &
prop_info - > ce ! = ce ) | |
( ( prop_info - > flags & ZEND_ACC_PROTECTED ) & &
! zend_check_protected ( prop_info - > ce , ce ) ) | |
( ( prop_info - > flags & ZEND_ACC_PRIVATE ) & &
prop_info - > ce ! = ce ) ) {
continue ;
}
prop = NULL ;
2014-11-14 08:46:06 +00:00
if ( statics & & ( prop_info - > flags & ZEND_ACC_STATIC ) ! = 0 ) {
prop = & ce - > default_static_members_table [ prop_info - > offset ] ;
} else if ( ! statics & & ( prop_info - > flags & ZEND_ACC_STATIC ) = = 0 ) {
prop = & ce - > default_properties_table [ OBJ_PROP_TO_NUM ( prop_info - > offset ) ] ;
2010-05-24 14:11:39 +00:00
}
if ( ! prop ) {
continue ;
}
/* copy: enforce read only access */
2014-07-31 04:55:53 +00:00
ZVAL_DEREF ( prop ) ;
2014-02-10 06:04:30 +00:00
ZVAL_DUP ( & prop_copy , prop ) ;
2010-05-24 14:11:39 +00:00
2011-05-15 00:36:13 +00:00
/* this is necessary to make it able to work with default array
2010-05-24 14:11:39 +00:00
* properties , returned to user */
2014-04-03 23:55:27 +00:00
if ( Z_CONSTANT ( prop_copy ) ) {
2015-04-01 23:05:25 +00:00
if ( UNEXPECTED ( zval_update_constant_ex ( & prop_copy , 1 , NULL ) ! = SUCCESS ) ) {
return ;
}
2010-05-24 14:11:39 +00:00
}
2014-04-01 18:36:17 +00:00
zend_hash_update ( Z_ARRVAL_P ( return_value ) , key , & prop_copy ) ;
2014-07-31 04:55:53 +00:00
} ZEND_HASH_FOREACH_END ( ) ;
2010-05-24 14:11:39 +00:00
}
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ proto public array ReflectionClass::getStaticProperties()
Returns an associative array containing all static property values of the class */
ZEND_METHOD ( reflection_class , getStaticProperties )
{
reflection_object * intern ;
zend_class_entry * ce ;
2006-07-25 14:06:52 +00:00
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( ce ) ;
2015-04-01 23:05:25 +00:00
if ( UNEXPECTED ( zend_update_class_constants ( ce ) ! = SUCCESS ) ) {
return ;
}
2005-11-30 21:53:20 +00:00
array_init ( return_value ) ;
2014-12-13 22:06:14 +00:00
add_class_vars ( ce , 1 , return_value ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public mixed ReflectionClass::getStaticPropertyValue(string name [, mixed default])
2007-08-20 17:01:22 +00:00
Returns the value of a static property */
2005-11-30 21:53:20 +00:00
ZEND_METHOD ( reflection_class , getStaticPropertyValue )
{
reflection_object * intern ;
zend_class_entry * ce ;
2014-02-10 06:04:30 +00:00
zend_string * name ;
zval * prop , * def_value = NULL ;
2011-05-15 00:36:13 +00:00
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " S|z " , & name , & def_value ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
GET_REFLECTION_OBJECT_PTR ( ce ) ;
2015-04-01 23:05:25 +00:00
if ( UNEXPECTED ( zend_update_class_constants ( ce ) ! = SUCCESS ) ) {
return ;
}
2015-01-13 06:33:15 +00:00
prop = zend_std_get_static_property ( ce , name , 1 ) ;
2005-11-30 21:53:20 +00:00
if ( ! prop ) {
if ( def_value ) {
RETURN_ZVAL ( def_value , 1 , 0 ) ;
} else {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2014-03-02 08:02:32 +00:00
" Class %s does not have a property named %s " , ce - > name - > val , name - > val ) ;
2005-11-30 21:53:20 +00:00
}
return ;
} else {
2014-02-10 06:04:30 +00:00
RETURN_ZVAL ( prop , 1 , 0 ) ;
2005-11-30 21:53:20 +00:00
}
}
/* }}} */
/* {{{ proto public void ReflectionClass::setStaticPropertyValue($name, $value)
Sets the value of a static property */
ZEND_METHOD ( reflection_class , setStaticPropertyValue )
{
reflection_object * intern ;
zend_class_entry * ce ;
2014-02-10 06:04:30 +00:00
zend_string * name ;
zval * variable_ptr , * value ;
2011-05-15 00:36:13 +00:00
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " Sz " , & name , & value ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
GET_REFLECTION_OBJECT_PTR ( ce ) ;
2015-04-01 23:05:25 +00:00
if ( UNEXPECTED ( zend_update_class_constants ( ce ) ! = SUCCESS ) ) {
return ;
}
2015-01-13 06:33:15 +00:00
variable_ptr = zend_std_get_static_property ( ce , name , 1 ) ;
2005-11-30 21:53:20 +00:00
if ( ! variable_ptr ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2014-03-02 13:42:21 +00:00
" Class %s does not have a property named %s " , ce - > name - > val , name - > val ) ;
2005-11-30 21:53:20 +00:00
return ;
2011-05-15 00:36:13 +00:00
}
2014-08-13 08:36:10 +00:00
zval_ptr_dtor ( variable_ptr ) ;
ZVAL_COPY ( variable_ptr , value ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public array ReflectionClass::getDefaultProperties()
Returns an associative array containing copies of all default property values of the class */
ZEND_METHOD ( reflection_class , getDefaultProperties )
{
reflection_object * intern ;
zend_class_entry * ce ;
2011-05-15 00:36:13 +00:00
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( ce ) ;
array_init ( return_value ) ;
2015-04-01 23:05:25 +00:00
if ( UNEXPECTED ( zend_update_class_constants ( ce ) ! = SUCCESS ) ) {
return ;
}
2014-12-13 22:06:14 +00:00
add_class_vars ( ce , 1 , return_value ) ;
add_class_vars ( ce , 0 , return_value ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public string ReflectionClass::__toString()
Returns a string representation */
ZEND_METHOD ( reflection_class , __toString )
{
reflection_object * intern ;
zend_class_entry * ce ;
string str ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( ce ) ;
string_init ( & str ) ;
2014-12-13 22:06:14 +00:00
_class_string ( & str , ce , & intern - > obj , " " ) ;
2015-03-12 13:53:51 +00:00
RETURN_NEW_STR ( str . buf ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public string ReflectionClass::getName()
Returns the class ' name */
ZEND_METHOD ( reflection_class , getName )
{
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2014-12-13 22:06:14 +00:00
_default_get_entry ( getThis ( ) , " name " , sizeof ( " name " ) - 1 , return_value ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public bool ReflectionClass::isInternal()
Returns whether this class is an internal class */
ZEND_METHOD ( reflection_class , isInternal )
{
reflection_object * intern ;
zend_class_entry * ce ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( ce ) ;
RETURN_BOOL ( ce - > type = = ZEND_INTERNAL_CLASS ) ;
}
/* }}} */
/* {{{ proto public bool ReflectionClass::isUserDefined()
Returns whether this class is user - defined */
ZEND_METHOD ( reflection_class , isUserDefined )
{
reflection_object * intern ;
zend_class_entry * ce ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( ce ) ;
RETURN_BOOL ( ce - > type = = ZEND_USER_CLASS ) ;
}
/* }}} */
2015-04-26 13:02:57 +00:00
/* {{{ proto public bool ReflectionClass::isAnonymous()
Returns whether this class is anonymous */
ZEND_METHOD ( reflection_class , isAnonymous )
{
reflection_object * intern ;
zend_class_entry * ce ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
GET_REFLECTION_OBJECT_PTR ( ce ) ;
RETURN_BOOL ( ce - > ce_flags & ZEND_ACC_ANON_CLASS ) ;
}
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ proto public string ReflectionClass::getFileName()
Returns the filename of the file this class was declared in */
ZEND_METHOD ( reflection_class , getFileName )
{
reflection_object * intern ;
zend_class_entry * ce ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( ce ) ;
if ( ce - > type = = ZEND_USER_CLASS ) {
2015-03-12 13:53:51 +00:00
RETURN_STR_COPY ( ce - > info . user . filename ) ;
2005-11-30 21:53:20 +00:00
}
RETURN_FALSE ;
}
/* }}} */
/* {{{ proto public int ReflectionClass::getStartLine()
Returns the line this class ' declaration starts at */
ZEND_METHOD ( reflection_class , getStartLine )
{
reflection_object * intern ;
zend_class_entry * ce ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( ce ) ;
if ( ce - > type = = ZEND_USER_FUNCTION ) {
2014-08-25 17:24:55 +00:00
RETURN_LONG ( ce - > info . user . line_start ) ;
2005-11-30 21:53:20 +00:00
}
RETURN_FALSE ;
}
/* }}} */
/* {{{ proto public int ReflectionClass::getEndLine()
Returns the line this class ' declaration ends at */
ZEND_METHOD ( reflection_class , getEndLine )
{
reflection_object * intern ;
zend_class_entry * ce ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( ce ) ;
if ( ce - > type = = ZEND_USER_CLASS ) {
2014-08-25 17:24:55 +00:00
RETURN_LONG ( ce - > info . user . line_end ) ;
2005-11-30 21:53:20 +00:00
}
RETURN_FALSE ;
}
/* }}} */
/* {{{ proto public string ReflectionClass::getDocComment()
Returns the doc comment for this class */
ZEND_METHOD ( reflection_class , getDocComment )
{
reflection_object * intern ;
zend_class_entry * ce ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( ce ) ;
2010-09-15 07:38:52 +00:00
if ( ce - > type = = ZEND_USER_CLASS & & ce - > info . user . doc_comment ) {
2015-03-12 13:53:51 +00:00
RETURN_STR_COPY ( ce - > info . user . doc_comment ) ;
2005-11-30 21:53:20 +00:00
}
RETURN_FALSE ;
}
/* }}} */
/* {{{ proto public ReflectionMethod ReflectionClass::getConstructor()
Returns the class ' constructor if there is one , NULL otherwise */
ZEND_METHOD ( reflection_class , getConstructor )
{
reflection_object * intern ;
zend_class_entry * ce ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( ce ) ;
if ( ce - > constructor ) {
2014-12-13 22:06:14 +00:00
reflection_method_factory ( ce , ce - > constructor , NULL , return_value ) ;
2005-11-30 21:53:20 +00:00
} else {
RETURN_NULL ( ) ;
}
}
/* }}} */
/* {{{ proto public bool ReflectionClass::hasMethod(string name)
2005-12-18 21:17:07 +00:00
Returns whether a method exists or not */
2005-11-30 21:53:20 +00:00
ZEND_METHOD ( reflection_class , hasMethod )
{
reflection_object * intern ;
zend_class_entry * ce ;
2011-05-15 00:36:13 +00:00
char * name , * lc_name ;
2014-08-27 15:31:24 +00:00
size_t name_len ;
2005-11-30 21:53:20 +00:00
METHOD_NOTSTATIC ( reflection_class_ptr ) ;
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " s " , & name , & name_len ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
GET_REFLECTION_OBJECT_PTR ( ce ) ;
lc_name = zend_str_tolower_dup ( name , name_len ) ;
2010-06-11 23:37:55 +00:00
if ( ( ce = = zend_ce_closure & & ( name_len = = sizeof ( ZEND_INVOKE_FUNC_NAME ) - 1 )
& & memcmp ( lc_name , ZEND_INVOKE_FUNC_NAME , sizeof ( ZEND_INVOKE_FUNC_NAME ) - 1 ) = = 0 )
2014-02-10 06:04:30 +00:00
| | zend_hash_str_exists ( & ce - > function_table , lc_name , name_len ) ) {
2005-11-30 21:53:20 +00:00
efree ( lc_name ) ;
RETURN_TRUE ;
} else {
efree ( lc_name ) ;
RETURN_FALSE ;
}
}
/* }}} */
/* {{{ proto public ReflectionMethod ReflectionClass::getMethod(string name) throws ReflectionException
Returns the class ' method specified by its name */
ZEND_METHOD ( reflection_class , getMethod )
{
reflection_object * intern ;
zend_class_entry * ce ;
zend_function * mptr ;
2010-06-11 23:37:55 +00:00
zval obj_tmp ;
2011-05-15 00:36:13 +00:00
char * name , * lc_name ;
2014-08-27 15:31:24 +00:00
size_t name_len ;
2005-11-30 21:53:20 +00:00
METHOD_NOTSTATIC ( reflection_class_ptr ) ;
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " s " , & name , & name_len ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
GET_REFLECTION_OBJECT_PTR ( ce ) ;
lc_name = zend_str_tolower_dup ( name , name_len ) ;
2014-05-03 08:06:27 +00:00
if ( ce = = zend_ce_closure & & ! Z_ISUNDEF ( intern - > obj ) & & ( name_len = = sizeof ( ZEND_INVOKE_FUNC_NAME ) - 1 )
2008-08-11 19:35:00 +00:00
& & memcmp ( lc_name , ZEND_INVOKE_FUNC_NAME , sizeof ( ZEND_INVOKE_FUNC_NAME ) - 1 ) = = 0
2014-12-13 22:06:14 +00:00
& & ( mptr = zend_get_closure_invoke_method ( Z_OBJ ( intern - > obj ) ) ) ! = NULL )
2008-08-11 19:35:00 +00:00
{
2009-01-26 22:54:34 +00:00
/* don't assign closure_object since we only reflect the invoke handler
method and not the closure definition itself */
2014-12-13 22:06:14 +00:00
reflection_method_factory ( ce , mptr , NULL , return_value ) ;
2008-08-11 12:43:21 +00:00
efree ( lc_name ) ;
2014-05-03 08:06:27 +00:00
} else if ( ce = = zend_ce_closure & & Z_ISUNDEF ( intern - > obj ) & & ( name_len = = sizeof ( ZEND_INVOKE_FUNC_NAME ) - 1 )
2010-06-11 23:37:55 +00:00
& & memcmp ( lc_name , ZEND_INVOKE_FUNC_NAME , sizeof ( ZEND_INVOKE_FUNC_NAME ) - 1 ) = = 0
2014-12-13 22:06:14 +00:00
& & object_init_ex ( & obj_tmp , ce ) = = SUCCESS & & ( mptr = zend_get_closure_invoke_method ( Z_OBJ ( obj_tmp ) ) ) ! = NULL ) {
2010-06-11 23:37:55 +00:00
/* don't assign closure_object since we only reflect the invoke handler
method and not the closure definition itself */
2014-12-13 22:06:14 +00:00
reflection_method_factory ( ce , mptr , NULL , return_value ) ;
2010-06-11 23:37:55 +00:00
zval_dtor ( & obj_tmp ) ;
efree ( lc_name ) ;
2014-02-10 06:04:30 +00:00
} else if ( ( mptr = zend_hash_str_find_ptr ( & ce - > function_table , lc_name , name_len ) ) ! = NULL ) {
2014-12-13 22:06:14 +00:00
reflection_method_factory ( ce , mptr , NULL , return_value ) ;
2005-11-30 21:53:20 +00:00
efree ( lc_name ) ;
} else {
efree ( lc_name ) ;
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2005-11-30 21:53:20 +00:00
" Method %s does not exist " , name ) ;
return ;
}
}
/* }}} */
/* {{{ _addmethod */
2014-12-13 22:06:14 +00:00
static void _addmethod ( zend_function * mptr , zend_class_entry * ce , zval * retval , zend_long filter , zval * obj )
2005-11-30 21:53:20 +00:00
{
2014-02-10 06:04:30 +00:00
zval method ;
2014-10-29 13:28:16 +00:00
size_t len = mptr - > common . function_name - > len ;
2008-08-11 12:43:21 +00:00
zend_function * closure ;
2005-11-30 21:53:20 +00:00
if ( mptr - > common . fn_flags & filter ) {
2008-08-11 19:35:00 +00:00
if ( ce = = zend_ce_closure & & obj & & ( len = = sizeof ( ZEND_INVOKE_FUNC_NAME ) - 1 )
2014-02-10 06:04:30 +00:00
& & memcmp ( mptr - > common . function_name - > val , ZEND_INVOKE_FUNC_NAME , sizeof ( ZEND_INVOKE_FUNC_NAME ) - 1 ) = = 0
2014-12-13 22:06:14 +00:00
& & ( closure = zend_get_closure_invoke_method ( Z_OBJ_P ( obj ) ) ) ! = NULL )
2008-08-11 19:35:00 +00:00
{
2008-08-11 12:43:21 +00:00
mptr = closure ;
}
2009-01-26 22:54:34 +00:00
/* don't assign closure_object since we only reflect the invoke handler
method and not the closure definition itself , even if we have a
closure */
2014-12-13 22:06:14 +00:00
reflection_method_factory ( ce , mptr , NULL , & method ) ;
2014-02-10 06:04:30 +00:00
add_next_index_zval ( retval , & method ) ;
2005-11-30 21:53:20 +00:00
}
2008-08-11 12:43:21 +00:00
}
/* }}} */
/* {{{ _addmethod */
2014-12-13 22:06:14 +00:00
static int _addmethod_va ( zval * el , int num_args , va_list args , zend_hash_key * hash_key )
2008-08-11 12:43:21 +00:00
{
2014-03-02 07:14:00 +00:00
zend_function * mptr = ( zend_function * ) Z_PTR_P ( el ) ;
2008-08-11 12:43:21 +00:00
zend_class_entry * ce = * va_arg ( args , zend_class_entry * * ) ;
zval * retval = va_arg ( args , zval * ) ;
long filter = va_arg ( args , long ) ;
zval * obj = va_arg ( args , zval * ) ;
2011-05-15 00:36:13 +00:00
2014-12-13 22:06:14 +00:00
_addmethod ( mptr , ce , retval , filter , obj ) ;
2008-08-11 12:43:21 +00:00
return ZEND_HASH_APPLY_KEEP ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
2006-07-04 15:33:57 +00:00
/* {{{ proto public ReflectionMethod[] ReflectionClass::getMethods([long $filter])
2005-11-30 21:53:20 +00:00
Returns an array of this class ' methods */
ZEND_METHOD ( reflection_class , getMethods )
{
reflection_object * intern ;
zend_class_entry * ce ;
2014-08-25 17:24:55 +00:00
zend_long filter = 0 ;
2005-11-30 21:53:20 +00:00
int argc = ZEND_NUM_ARGS ( ) ;
METHOD_NOTSTATIC ( reflection_class_ptr ) ;
if ( argc ) {
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( argc , " |l " , & filter ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
} else {
/* No parameters given, default to "return all" */
filter = ZEND_ACC_PPP_MASK | ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL | ZEND_ACC_STATIC ;
}
GET_REFLECTION_OBJECT_PTR ( ce ) ;
array_init ( return_value ) ;
2014-12-13 22:06:14 +00:00
zend_hash_apply_with_arguments ( & ce - > function_table , ( apply_func_args_t ) _addmethod_va , 4 , & ce , return_value , filter , intern - > obj ) ;
if ( Z_TYPE ( intern - > obj ) ! = IS_UNDEF & & instanceof_function ( ce , zend_ce_closure ) ) {
zend_function * closure = zend_get_closure_invoke_method ( Z_OBJ ( intern - > obj ) ) ;
2008-08-11 12:43:21 +00:00
if ( closure ) {
2014-12-13 22:06:14 +00:00
_addmethod ( closure , ce , return_value , filter , & intern - > obj ) ;
_free_function ( closure ) ;
2008-08-11 12:43:21 +00:00
}
}
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public bool ReflectionClass::hasProperty(string name)
2005-12-18 21:17:07 +00:00
Returns whether a property exists or not */
2005-11-30 21:53:20 +00:00
ZEND_METHOD ( reflection_class , hasProperty )
{
reflection_object * intern ;
2009-11-01 15:12:34 +00:00
zend_property_info * property_info ;
2005-11-30 21:53:20 +00:00
zend_class_entry * ce ;
2014-02-10 06:04:30 +00:00
zend_string * name ;
zval property ;
2005-11-30 21:53:20 +00:00
METHOD_NOTSTATIC ( reflection_class_ptr ) ;
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " S " , & name ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
GET_REFLECTION_OBJECT_PTR ( ce ) ;
2014-02-10 06:04:30 +00:00
if ( ( property_info = zend_hash_find_ptr ( & ce - > properties_info , name ) ) ! = NULL ) {
2009-11-01 15:12:34 +00:00
if ( property_info - > flags & ZEND_ACC_SHADOW ) {
RETURN_FALSE ;
}
2005-11-30 21:53:20 +00:00
RETURN_TRUE ;
} else {
2014-02-10 06:04:30 +00:00
if ( Z_TYPE ( intern - > obj ) ! = IS_UNDEF & & Z_OBJ_HANDLER ( intern - > obj , has_property ) ) {
2014-09-19 13:32:50 +00:00
ZVAL_STR_COPY ( & property , name ) ;
2014-12-13 22:06:14 +00:00
if ( Z_OBJ_HANDLER ( intern - > obj , has_property ) ( & intern - > obj , & property , 2 , NULL ) ) {
2005-11-30 21:53:20 +00:00
zval_ptr_dtor ( & property ) ;
RETURN_TRUE ;
}
zval_ptr_dtor ( & property ) ;
}
RETURN_FALSE ;
}
}
/* }}} */
/* {{{ proto public ReflectionProperty ReflectionClass::getProperty(string name) throws ReflectionException
Returns the class ' property specified by its name */
ZEND_METHOD ( reflection_class , getProperty )
{
reflection_object * intern ;
2014-02-10 06:04:30 +00:00
zend_class_entry * ce , * ce2 ;
2005-11-30 21:53:20 +00:00
zend_property_info * property_info ;
2014-02-10 06:04:30 +00:00
zend_string * name , * classname ;
char * tmp , * str_name ;
2014-10-29 13:28:16 +00:00
size_t classname_len , str_name_len ;
2005-11-30 21:53:20 +00:00
METHOD_NOTSTATIC ( reflection_class_ptr ) ;
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " S " , & name ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
GET_REFLECTION_OBJECT_PTR ( ce ) ;
2014-02-10 06:04:30 +00:00
if ( ( property_info = zend_hash_find_ptr ( & ce - > properties_info , name ) ) ! = NULL ) {
2008-10-29 12:56:29 +00:00
if ( ( property_info - > flags & ZEND_ACC_SHADOW ) = = 0 ) {
2014-12-13 22:06:14 +00:00
reflection_property_factory ( ce , property_info , return_value ) ;
2008-10-29 12:56:29 +00:00
return ;
}
2014-02-10 06:04:30 +00:00
} else if ( Z_TYPE ( intern - > obj ) ! = IS_UNDEF ) {
2008-10-29 12:56:29 +00:00
/* Check for dynamic properties */
2014-12-13 22:06:14 +00:00
if ( zend_hash_exists ( Z_OBJ_HT ( intern - > obj ) - > get_properties ( & intern - > obj ) , name ) ) {
2008-10-29 12:56:29 +00:00
zend_property_info property_info_tmp ;
property_info_tmp . flags = ZEND_ACC_IMPLICIT_PUBLIC ;
2014-08-25 17:24:55 +00:00
property_info_tmp . name = zend_string_copy ( name ) ;
2008-10-29 12:56:29 +00:00
property_info_tmp . doc_comment = NULL ;
property_info_tmp . ce = ce ;
2014-12-13 22:06:14 +00:00
reflection_property_factory ( ce , & property_info_tmp , return_value ) ;
2014-03-17 04:15:22 +00:00
intern = Z_REFLECTION_P ( return_value ) ;
2010-11-20 22:53:55 +00:00
intern - > ref_type = REF_TYPE_DYNAMIC_PROPERTY ;
2008-10-29 12:56:29 +00:00
return ;
}
2005-11-30 21:53:20 +00:00
}
2014-02-10 06:04:30 +00:00
str_name = name - > val ;
str_name_len = name - > len ;
if ( ( tmp = strstr ( name - > val , " :: " ) ) ! = NULL ) {
classname_len = tmp - name - > val ;
2014-08-25 17:24:55 +00:00
classname = zend_string_alloc ( classname_len , 0 ) ;
2014-02-10 06:04:30 +00:00
zend_str_tolower_copy ( classname - > val , name - > val , classname_len ) ;
classname - > val [ classname_len ] = ' \0 ' ;
str_name_len = name - > len - ( classname_len + 2 ) ;
str_name = tmp + 2 ;
2014-12-13 22:06:14 +00:00
ce2 = zend_lookup_class ( classname ) ;
2014-02-10 06:04:30 +00:00
if ( ! ce2 ) {
2005-11-30 21:53:20 +00:00
if ( ! EG ( exception ) ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , - 1 , " Class %s does not exist " , classname - > val ) ;
2005-11-30 21:53:20 +00:00
}
2014-10-12 17:01:45 +00:00
zend_string_release ( classname ) ;
2005-11-30 21:53:20 +00:00
return ;
}
2014-10-12 17:01:45 +00:00
zend_string_release ( classname ) ;
2005-11-30 21:53:20 +00:00
2014-12-13 22:06:14 +00:00
if ( ! instanceof_function ( ce , ce2 ) ) {
zend_throw_exception_ex ( reflection_exception_ptr , - 1 , " Fully qualified property name %s::%s does not specify a base class of %s " , ce2 - > name - > val , str_name , ce - > name - > val ) ;
2005-11-30 21:53:20 +00:00
return ;
}
2014-02-10 06:04:30 +00:00
ce = ce2 ;
2005-11-30 21:53:20 +00:00
2014-02-10 06:04:30 +00:00
if ( ( property_info = zend_hash_str_find_ptr ( & ce - > properties_info , str_name , str_name_len ) ) ! = NULL & & ( property_info - > flags & ZEND_ACC_SHADOW ) = = 0 ) {
2014-12-13 22:06:14 +00:00
reflection_property_factory ( ce , property_info , return_value ) ;
2005-11-30 21:53:20 +00:00
return ;
2011-05-15 00:36:13 +00:00
}
2005-11-30 21:53:20 +00:00
}
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2014-02-10 06:04:30 +00:00
" Property %s does not exist " , str_name ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ _addproperty */
2014-12-13 22:06:14 +00:00
static int _addproperty ( zval * el , int num_args , va_list args , zend_hash_key * hash_key )
2005-11-30 21:53:20 +00:00
{
2014-02-10 06:04:30 +00:00
zval property ;
2014-03-02 07:14:00 +00:00
zend_property_info * pptr = ( zend_property_info * ) Z_PTR_P ( el ) ;
2005-11-30 21:53:20 +00:00
zend_class_entry * ce = * va_arg ( args , zend_class_entry * * ) ;
zval * retval = va_arg ( args , zval * ) ;
long filter = va_arg ( args , long ) ;
if ( pptr - > flags & ZEND_ACC_SHADOW ) {
return 0 ;
}
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
if ( pptr - > flags & filter ) {
2014-12-13 22:06:14 +00:00
reflection_property_factory ( ce , pptr , & property ) ;
2014-02-10 06:04:30 +00:00
add_next_index_zval ( retval , & property ) ;
2005-11-30 21:53:20 +00:00
}
return 0 ;
}
/* }}} */
2006-06-24 18:55:15 +00:00
/* {{{ _adddynproperty */
2014-12-13 22:06:14 +00:00
static int _adddynproperty ( zval * ptr , int num_args , va_list args , zend_hash_key * hash_key )
2006-06-24 18:55:15 +00:00
{
2014-02-10 06:04:30 +00:00
zval property ;
2006-06-24 18:55:15 +00:00
zend_class_entry * ce = * va_arg ( args , zend_class_entry * * ) ;
2014-09-13 21:14:04 +00:00
zval * retval = va_arg ( args , zval * ) ;
2006-06-24 18:55:15 +00:00
2012-03-18 18:23:27 +00:00
/* under some circumstances, the properties hash table may contain numeric
* properties ( e . g . when casting from array ) . This is a WONT FIX bug , at
* least for the moment . Ignore these */
2014-02-10 06:04:30 +00:00
if ( hash_key - > key = = NULL ) {
2012-03-18 18:23:27 +00:00
return 0 ;
}
2014-02-10 06:04:30 +00:00
if ( hash_key - > key - > val [ 0 ] = = ' \0 ' ) {
2006-06-24 18:55:15 +00:00
return 0 ; /* non public cannot be dynamic */
}
2014-12-13 22:06:14 +00:00
if ( zend_get_property_info ( ce , hash_key - > key , 1 ) = = NULL ) {
2014-10-17 15:10:05 +00:00
zend_property_info property_info ;
2015-01-03 09:22:58 +00:00
2015-01-20 19:14:56 +00:00
property_info . doc_comment = NULL ;
2014-10-17 15:10:05 +00:00
property_info . flags = ZEND_ACC_IMPLICIT_PUBLIC ;
property_info . name = hash_key - > key ;
property_info . ce = ce ;
property_info . offset = - 1 ;
2014-12-13 22:06:14 +00:00
reflection_property_factory ( ce , & property_info , & property ) ;
2014-02-10 06:04:30 +00:00
add_next_index_zval ( retval , & property ) ;
2006-06-24 18:55:15 +00:00
}
return 0 ;
}
/* }}} */
2006-07-04 15:33:57 +00:00
/* {{{ proto public ReflectionProperty[] ReflectionClass::getProperties([long $filter])
2005-11-30 21:53:20 +00:00
Returns an array of this class ' properties */
ZEND_METHOD ( reflection_class , getProperties )
{
reflection_object * intern ;
zend_class_entry * ce ;
2014-08-25 17:24:55 +00:00
zend_long filter = 0 ;
2005-11-30 21:53:20 +00:00
int argc = ZEND_NUM_ARGS ( ) ;
METHOD_NOTSTATIC ( reflection_class_ptr ) ;
if ( argc ) {
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( argc , " |l " , & filter ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
} else {
/* No parameters given, default to "return all" */
filter = ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC ;
}
GET_REFLECTION_OBJECT_PTR ( ce ) ;
array_init ( return_value ) ;
2014-12-13 22:06:14 +00:00
zend_hash_apply_with_arguments ( & ce - > properties_info , ( apply_func_args_t ) _addproperty , 3 , & ce , return_value , filter ) ;
2006-06-24 18:55:15 +00:00
2014-02-10 06:04:30 +00:00
if ( Z_TYPE ( intern - > obj ) ! = IS_UNDEF & & ( filter & ZEND_ACC_PUBLIC ) ! = 0 & & Z_OBJ_HT ( intern - > obj ) - > get_properties ) {
2014-12-13 22:06:14 +00:00
HashTable * properties = Z_OBJ_HT ( intern - > obj ) - > get_properties ( & intern - > obj ) ;
zend_hash_apply_with_arguments ( properties , ( apply_func_args_t ) _adddynproperty , 2 , & ce , return_value ) ;
2006-06-24 18:55:15 +00:00
}
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public bool ReflectionClass::hasConstant(string name)
2005-12-18 21:17:07 +00:00
Returns whether a constant exists or not */
2005-11-30 21:53:20 +00:00
ZEND_METHOD ( reflection_class , hasConstant )
{
reflection_object * intern ;
zend_class_entry * ce ;
2014-02-10 06:04:30 +00:00
zend_string * name ;
2005-11-30 21:53:20 +00:00
METHOD_NOTSTATIC ( reflection_class_ptr ) ;
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " S " , & name ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
GET_REFLECTION_OBJECT_PTR ( ce ) ;
2014-02-10 06:04:30 +00:00
if ( zend_hash_exists ( & ce - > constants_table , name ) ) {
2005-11-30 21:53:20 +00:00
RETURN_TRUE ;
} else {
RETURN_FALSE ;
}
}
/* }}} */
/* {{{ proto public array ReflectionClass::getConstants()
Returns an associative array containing this class ' constants and their values */
ZEND_METHOD ( reflection_class , getConstants )
{
reflection_object * intern ;
zend_class_entry * ce ;
2015-04-01 23:05:25 +00:00
zval * val ;
2005-11-30 21:53:20 +00:00
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( ce ) ;
array_init ( return_value ) ;
2015-04-01 23:05:25 +00:00
ZEND_HASH_FOREACH_VAL ( & ce - > constants_table , val ) {
if ( UNEXPECTED ( zval_update_constant_ex ( val , 1 , ce ) ! = SUCCESS ) ) {
return ;
}
} ZEND_HASH_FOREACH_END ( ) ;
2014-04-14 09:24:43 +00:00
zend_hash_copy ( Z_ARRVAL_P ( return_value ) , & ce - > constants_table , zval_add_ref_unref ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public mixed ReflectionClass::getConstant(string name)
Returns the class ' constant specified by its name */
ZEND_METHOD ( reflection_class , getConstant )
{
reflection_object * intern ;
zend_class_entry * ce ;
2014-02-10 06:04:30 +00:00
zval * value ;
zend_string * name ;
2005-11-30 21:53:20 +00:00
METHOD_NOTSTATIC ( reflection_class_ptr ) ;
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " S " , & name ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
GET_REFLECTION_OBJECT_PTR ( ce ) ;
2015-04-01 23:05:25 +00:00
ZEND_HASH_FOREACH_VAL ( & ce - > constants_table , value ) {
if ( UNEXPECTED ( zval_update_constant_ex ( value , 1 , ce ) ! = SUCCESS ) ) {
return ;
}
} ZEND_HASH_FOREACH_END ( ) ;
2014-02-10 06:04:30 +00:00
if ( ( value = zend_hash_find ( & ce - > constants_table , name ) ) = = NULL ) {
2005-11-30 21:53:20 +00:00
RETURN_FALSE ;
}
2014-02-10 06:04:30 +00:00
ZVAL_DUP ( return_value , value ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ _class_check_flag */
static void _class_check_flag ( INTERNAL_FUNCTION_PARAMETERS , int mask )
{
reflection_object * intern ;
zend_class_entry * ce ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( ce ) ;
RETVAL_BOOL ( ce - > ce_flags & mask ) ;
}
/* }}} */
/* {{{ proto public bool ReflectionClass::isInstantiable()
Returns whether this class is instantiable */
ZEND_METHOD ( reflection_class , isInstantiable )
{
reflection_object * intern ;
zend_class_entry * ce ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( ce ) ;
2015-02-12 22:25:09 +00:00
if ( ce - > ce_flags & ( ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS ) ) {
2005-11-30 21:53:20 +00:00
RETURN_FALSE ;
}
/* Basically, the class is instantiable. Though, if there is a constructor
* and it is not publicly accessible , it isn ' t ! */
if ( ! ce - > constructor ) {
RETURN_TRUE ;
}
RETURN_BOOL ( ce - > constructor - > common . fn_flags & ZEND_ACC_PUBLIC ) ;
}
/* }}} */
2010-06-02 15:29:42 +00:00
/* {{{ proto public bool ReflectionClass::isCloneable()
Returns whether this class is cloneable */
ZEND_METHOD ( reflection_class , isCloneable )
{
reflection_object * intern ;
zend_class_entry * ce ;
zval obj ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
GET_REFLECTION_OBJECT_PTR ( ce ) ;
if ( ce - > ce_flags & ( ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS ) ) {
RETURN_FALSE ;
}
2014-05-03 08:06:27 +00:00
if ( ! Z_ISUNDEF ( intern - > obj ) ) {
2010-06-02 15:29:42 +00:00
if ( ce - > clone ) {
RETURN_BOOL ( ce - > clone - > common . fn_flags & ZEND_ACC_PUBLIC ) ;
} else {
2014-02-10 06:04:30 +00:00
RETURN_BOOL ( Z_OBJ_HANDLER ( intern - > obj , clone_obj ) ! = NULL ) ;
2010-06-02 15:29:42 +00:00
}
} else {
if ( ce - > clone ) {
2010-06-02 17:07:01 +00:00
RETURN_BOOL ( ce - > clone - > common . fn_flags & ZEND_ACC_PUBLIC ) ;
2010-06-02 15:29:42 +00:00
} else {
2015-04-01 23:05:25 +00:00
if ( UNEXPECTED ( object_init_ex ( & obj , ce ) ! = SUCCESS ) ) {
return ;
}
2010-06-02 15:29:42 +00:00
RETVAL_BOOL ( Z_OBJ_HANDLER ( obj , clone_obj ) ! = NULL ) ;
2010-06-02 17:07:01 +00:00
zval_dtor ( & obj ) ;
2011-05-15 00:36:13 +00:00
}
2010-06-02 15:29:42 +00:00
}
}
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ proto public bool ReflectionClass::isInterface()
Returns whether this is an interface or a class */
ZEND_METHOD ( reflection_class , isInterface )
{
_class_check_flag ( INTERNAL_FUNCTION_PARAM_PASSTHRU , ZEND_ACC_INTERFACE ) ;
}
/* }}} */
2010-05-29 20:40:58 +00:00
/* {{{ proto public bool ReflectionClass::isTrait()
Returns whether this is a trait */
ZEND_METHOD ( reflection_class , isTrait )
{
2015-02-12 22:19:14 +00:00
_class_check_flag ( INTERNAL_FUNCTION_PARAM_PASSTHRU , ZEND_ACC_TRAIT ) ;
2010-05-29 20:40:58 +00:00
}
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ proto public bool ReflectionClass::isFinal()
Returns whether this class is final */
ZEND_METHOD ( reflection_class , isFinal )
{
2014-11-22 04:57:55 +00:00
_class_check_flag ( INTERNAL_FUNCTION_PARAM_PASSTHRU , ZEND_ACC_FINAL ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public bool ReflectionClass::isAbstract()
Returns whether this class is abstract */
ZEND_METHOD ( reflection_class , isAbstract )
{
_class_check_flag ( INTERNAL_FUNCTION_PARAM_PASSTHRU , ZEND_ACC_IMPLICIT_ABSTRACT_CLASS | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS ) ;
}
/* }}} */
/* {{{ proto public int ReflectionClass::getModifiers()
Returns a bitfield of the access modifiers for this class */
ZEND_METHOD ( reflection_class , getModifiers )
{
reflection_object * intern ;
zend_class_entry * ce ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( ce ) ;
2015-02-04 12:24:13 +00:00
RETURN_LONG ( ce - > ce_flags & ~ ( ZEND_ACC_CONSTANTS_UPDATED | ZEND_ACC_USE_GUARDS ) ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public bool ReflectionClass::isInstance(stdclass object)
Returns whether the given object is an instance of this class */
ZEND_METHOD ( reflection_class , isInstance )
{
reflection_object * intern ;
zend_class_entry * ce ;
zval * object ;
METHOD_NOTSTATIC ( reflection_class_ptr ) ;
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " o " , & object ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
2011-05-15 00:36:13 +00:00
GET_REFLECTION_OBJECT_PTR ( ce ) ;
2014-12-13 22:06:14 +00:00
RETURN_BOOL ( instanceof_function ( Z_OBJCE_P ( object ) , ce ) ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public stdclass ReflectionClass::newInstance(mixed* args, ...)
Returns an instance of this class */
ZEND_METHOD ( reflection_class , newInstance )
{
2014-02-28 08:06:47 +00:00
zval retval ;
2005-11-30 21:53:20 +00:00
reflection_object * intern ;
2013-01-19 09:01:57 +00:00
zend_class_entry * ce , * old_scope ;
zend_function * constructor ;
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
METHOD_NOTSTATIC ( reflection_class_ptr ) ;
GET_REFLECTION_OBJECT_PTR ( ce ) ;
2015-04-01 23:05:25 +00:00
if ( UNEXPECTED ( object_init_ex ( return_value , ce ) ! = SUCCESS ) ) {
return ;
}
2013-01-19 09:01:57 +00:00
old_scope = EG ( scope ) ;
EG ( scope ) = ce ;
2014-12-13 22:06:14 +00:00
constructor = Z_OBJ_HT_P ( return_value ) - > get_constructor ( Z_OBJ_P ( return_value ) ) ;
2013-01-19 09:01:57 +00:00
EG ( scope ) = old_scope ;
2005-11-30 21:53:20 +00:00
/* Run the constructor if there is one */
2013-01-19 09:01:57 +00:00
if ( constructor ) {
2014-02-10 06:04:30 +00:00
zval * params = NULL ;
2014-04-16 13:06:25 +00:00
int ret , i , num_args = 0 ;
2005-11-30 21:53:20 +00:00
zend_fcall_info fci ;
zend_fcall_info_cache fcc ;
2013-01-22 08:58:40 +00:00
if ( ! ( constructor - > common . fn_flags & ZEND_ACC_PUBLIC ) ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 , " Access to non-public constructor of class %s " , ce - > name - > val ) ;
2013-01-19 09:01:57 +00:00
zval_dtor ( return_value ) ;
RETURN_NULL ( ) ;
2005-11-30 21:53:20 +00:00
}
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " * " , & params , & num_args ) = = FAILURE ) {
2013-01-19 09:01:57 +00:00
zval_dtor ( return_value ) ;
2005-11-30 21:53:20 +00:00
RETURN_FALSE ;
}
2014-04-16 13:06:25 +00:00
for ( i = 0 ; i < num_args ; i + + ) {
if ( Z_REFCOUNTED ( params [ i ] ) ) Z_ADDREF ( params [ i ] ) ;
}
2005-11-30 21:53:20 +00:00
fci . size = sizeof ( fci ) ;
fci . function_table = EG ( function_table ) ;
2014-02-10 06:04:30 +00:00
ZVAL_UNDEF ( & fci . function_name ) ;
2005-11-30 21:53:20 +00:00
fci . symbol_table = NULL ;
2014-03-27 22:11:22 +00:00
fci . object = Z_OBJ_P ( return_value ) ;
2014-02-28 08:06:47 +00:00
fci . retval = & retval ;
2008-06-21 02:41:27 +00:00
fci . param_count = num_args ;
2005-11-30 21:53:20 +00:00
fci . params = params ;
fci . no_separation = 1 ;
fcc . initialized = 1 ;
2013-01-22 08:58:40 +00:00
fcc . function_handler = constructor ;
2005-11-30 21:53:20 +00:00
fcc . calling_scope = EG ( scope ) ;
2008-07-25 08:23:07 +00:00
fcc . called_scope = Z_OBJCE_P ( return_value ) ;
2014-03-27 22:11:22 +00:00
fcc . object = Z_OBJ_P ( return_value ) ;
2005-11-30 21:53:20 +00:00
2014-12-13 22:06:14 +00:00
ret = zend_call_function ( & fci , & fcc ) ;
2014-04-16 13:06:25 +00:00
zval_ptr_dtor ( & retval ) ;
for ( i = 0 ; i < num_args ; i + + ) {
zval_ptr_dtor ( & params [ i ] ) ;
}
if ( ret = = FAILURE ) {
2014-12-13 22:06:14 +00:00
php_error_docref ( NULL , E_WARNING , " Invocation of %s's constructor failed " , ce - > name - > val ) ;
2013-01-19 09:01:57 +00:00
zval_dtor ( return_value ) ;
2005-11-30 21:53:20 +00:00
RETURN_NULL ( ) ;
}
2013-01-19 09:01:57 +00:00
} else if ( ZEND_NUM_ARGS ( ) ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 , " Class %s does not have a constructor, so you cannot pass any constructor arguments " , ce - > name - > val ) ;
2006-01-25 22:03:54 +00:00
}
}
/* }}} */
2011-08-26 07:40:31 +00:00
/* {{{ proto public stdclass ReflectionClass::newInstanceWithoutConstructor()
Returns an instance of this class without invoking its constructor */
ZEND_METHOD ( reflection_class , newInstanceWithoutConstructor )
{
reflection_object * intern ;
zend_class_entry * ce ;
METHOD_NOTSTATIC ( reflection_class_ptr ) ;
GET_REFLECTION_OBJECT_PTR ( ce ) ;
2014-11-22 04:57:55 +00:00
if ( ce - > create_object ! = NULL & & ce - > ce_flags & ZEND_ACC_FINAL ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 , " Class %s is an internal class marked as final that cannot be instantiated without invoking its constructor " , ce - > name - > val ) ;
2015-04-14 15:45:41 +00:00
return ;
2011-08-26 07:40:31 +00:00
}
object_init_ex ( return_value , ce ) ;
}
/* }}} */
2006-07-04 15:33:57 +00:00
/* {{{ proto public stdclass ReflectionClass::newInstanceArgs([array args])
2006-01-25 22:03:54 +00:00
Returns an instance of this class */
ZEND_METHOD ( reflection_class , newInstanceArgs )
{
2014-05-28 08:34:08 +00:00
zval retval , * val ;
2006-01-25 22:03:54 +00:00
reflection_object * intern ;
2013-01-22 08:58:40 +00:00
zend_class_entry * ce , * old_scope ;
2014-04-16 13:06:25 +00:00
int ret , i , argc = 0 ;
2006-01-25 22:03:54 +00:00
HashTable * args ;
2013-01-22 08:58:40 +00:00
zend_function * constructor ;
2011-05-15 00:36:13 +00:00
2006-01-25 22:03:54 +00:00
METHOD_NOTSTATIC ( reflection_class_ptr ) ;
GET_REFLECTION_OBJECT_PTR ( ce ) ;
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " |h " , & args ) = = FAILURE ) {
2006-01-25 22:03:54 +00:00
return ;
}
2013-01-22 08:58:40 +00:00
2006-07-26 08:03:48 +00:00
if ( ZEND_NUM_ARGS ( ) > 0 ) {
argc = args - > nNumOfElements ;
}
2011-05-15 00:36:13 +00:00
2015-04-01 23:05:25 +00:00
if ( UNEXPECTED ( object_init_ex ( return_value , ce ) ! = SUCCESS ) ) {
return ;
}
2013-01-22 08:58:40 +00:00
old_scope = EG ( scope ) ;
EG ( scope ) = ce ;
2014-12-13 22:06:14 +00:00
constructor = Z_OBJ_HT_P ( return_value ) - > get_constructor ( Z_OBJ_P ( return_value ) ) ;
2013-01-22 08:58:40 +00:00
EG ( scope ) = old_scope ;
2006-01-25 22:03:54 +00:00
/* Run the constructor if there is one */
2013-01-22 08:58:40 +00:00
if ( constructor ) {
2014-02-10 06:04:30 +00:00
zval * params = NULL ;
2006-01-25 22:03:54 +00:00
zend_fcall_info fci ;
zend_fcall_info_cache fcc ;
2013-01-22 08:58:40 +00:00
if ( ! ( constructor - > common . fn_flags & ZEND_ACC_PUBLIC ) ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 , " Access to non-public constructor of class %s " , ce - > name - > val ) ;
2013-01-22 08:58:40 +00:00
zval_dtor ( return_value ) ;
RETURN_NULL ( ) ;
2006-01-25 22:03:54 +00:00
}
2011-05-15 00:36:13 +00:00
2006-07-26 08:03:48 +00:00
if ( argc ) {
2014-02-10 06:04:30 +00:00
params = safe_emalloc ( sizeof ( zval ) , argc , 0 ) ;
2014-05-28 08:34:08 +00:00
argc = 0 ;
ZEND_HASH_FOREACH_VAL ( args , val ) {
ZVAL_COPY ( & params [ argc ] , val ) ;
argc + + ;
} ZEND_HASH_FOREACH_END ( ) ;
2006-07-26 08:03:48 +00:00
}
2006-01-25 22:03:54 +00:00
fci . size = sizeof ( fci ) ;
fci . function_table = EG ( function_table ) ;
2014-02-10 06:04:30 +00:00
ZVAL_UNDEF ( & fci . function_name ) ;
2006-01-25 22:03:54 +00:00
fci . symbol_table = NULL ;
2014-03-27 22:11:22 +00:00
fci . object = Z_OBJ_P ( return_value ) ;
2014-03-02 07:14:00 +00:00
fci . retval = & retval ;
2006-01-25 22:03:54 +00:00
fci . param_count = argc ;
fci . params = params ;
fci . no_separation = 1 ;
fcc . initialized = 1 ;
2013-01-22 08:58:40 +00:00
fcc . function_handler = constructor ;
2006-01-25 22:03:54 +00:00
fcc . calling_scope = EG ( scope ) ;
2008-07-25 08:23:07 +00:00
fcc . called_scope = Z_OBJCE_P ( return_value ) ;
2014-03-27 22:11:22 +00:00
fcc . object = Z_OBJ_P ( return_value ) ;
2006-01-25 22:03:54 +00:00
2014-12-13 22:06:14 +00:00
ret = zend_call_function ( & fci , & fcc ) ;
2014-04-16 13:06:25 +00:00
zval_ptr_dtor ( & retval ) ;
if ( params ) {
for ( i = 0 ; i < argc ; i + + ) {
zval_ptr_dtor ( & params [ i ] ) ;
2006-07-26 08:03:48 +00:00
}
2014-04-16 13:06:25 +00:00
efree ( params ) ;
}
if ( ret = = FAILURE ) {
2014-03-02 07:14:00 +00:00
zval_ptr_dtor ( & retval ) ;
2014-12-13 22:06:14 +00:00
php_error_docref ( NULL , E_WARNING , " Invocation of %s's constructor failed " , ce - > name - > val ) ;
2013-01-22 08:58:40 +00:00
zval_dtor ( return_value ) ;
2006-01-25 22:03:54 +00:00
RETURN_NULL ( ) ;
}
2013-01-22 08:58:40 +00:00
} else if ( argc ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 , " Class %s does not have a constructor, so you cannot pass any constructor arguments " , ce - > name - > val ) ;
2005-11-30 21:53:20 +00:00
}
}
/* }}} */
/* {{{ proto public ReflectionClass[] ReflectionClass::getInterfaces()
Returns an array of interfaces this class implements */
ZEND_METHOD ( reflection_class , getInterfaces )
{
reflection_object * intern ;
zend_class_entry * ce ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( ce ) ;
/* Return an empty array if this class implements no interfaces */
array_init ( return_value ) ;
if ( ce - > num_interfaces ) {
2014-08-25 17:28:33 +00:00
uint32_t i ;
2005-11-30 21:53:20 +00:00
2008-08-11 19:35:00 +00:00
for ( i = 0 ; i < ce - > num_interfaces ; i + + ) {
2014-02-10 06:04:30 +00:00
zval interface ;
2014-12-13 22:06:14 +00:00
zend_reflection_class_factory ( ce - > interfaces [ i ] , & interface ) ;
2014-04-01 18:36:17 +00:00
zend_hash_update ( Z_ARRVAL_P ( return_value ) , ce - > interfaces [ i ] - > name , & interface ) ;
2005-11-30 21:53:20 +00:00
}
}
}
/* }}} */
2006-06-07 09:26:11 +00:00
/* {{{ proto public String[] ReflectionClass::getInterfaceNames()
Returns an array of names of interfaces this class implements */
ZEND_METHOD ( reflection_class , getInterfaceNames )
{
reflection_object * intern ;
zend_class_entry * ce ;
2014-08-25 17:28:33 +00:00
uint32_t i ;
2006-06-07 09:26:11 +00:00
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2006-06-07 09:26:11 +00:00
GET_REFLECTION_OBJECT_PTR ( ce ) ;
/* Return an empty array if this class implements no interfaces */
array_init ( return_value ) ;
2008-08-11 19:35:00 +00:00
for ( i = 0 ; i < ce - > num_interfaces ; i + + ) {
2014-08-25 17:24:55 +00:00
add_next_index_str ( return_value , zend_string_copy ( ce - > interfaces [ i ] - > name ) ) ;
2006-06-07 09:26:11 +00:00
}
}
/* }}} */
2010-05-30 01:00:45 +00:00
/* {{{ proto public ReflectionClass[] ReflectionClass::getTraits()
Returns an array of traits used by this class */
ZEND_METHOD ( reflection_class , getTraits )
{
reflection_object * intern ;
zend_class_entry * ce ;
2014-08-25 17:28:33 +00:00
uint32_t i ;
2010-05-30 01:00:45 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
GET_REFLECTION_OBJECT_PTR ( ce ) ;
array_init ( return_value ) ;
for ( i = 0 ; i < ce - > num_traits ; i + + ) {
2014-02-10 06:04:30 +00:00
zval trait ;
2014-12-13 22:06:14 +00:00
zend_reflection_class_factory ( ce - > traits [ i ] , & trait ) ;
2014-04-01 18:36:17 +00:00
zend_hash_update ( Z_ARRVAL_P ( return_value ) , ce - > traits [ i ] - > name , & trait ) ;
2010-05-30 01:00:45 +00:00
}
}
/* }}} */
/* {{{ proto public String[] ReflectionClass::getTraitNames()
Returns an array of names of traits used by this class */
ZEND_METHOD ( reflection_class , getTraitNames )
{
reflection_object * intern ;
zend_class_entry * ce ;
2014-08-25 17:28:33 +00:00
uint32_t i ;
2010-05-30 01:00:45 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
GET_REFLECTION_OBJECT_PTR ( ce ) ;
array_init ( return_value ) ;
for ( i = 0 ; i < ce - > num_traits ; i + + ) {
2014-08-25 17:24:55 +00:00
add_next_index_str ( return_value , zend_string_copy ( ce - > traits [ i ] - > name ) ) ;
2010-05-30 01:00:45 +00:00
}
}
/* }}} */
/* {{{ proto public arra ReflectionClass::getTraitaliases()
Returns an array of trait aliases */
ZEND_METHOD ( reflection_class , getTraitAliases )
{
reflection_object * intern ;
zend_class_entry * ce ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
GET_REFLECTION_OBJECT_PTR ( ce ) ;
array_init ( return_value ) ;
if ( ce - > trait_aliases ) {
2014-08-25 17:28:33 +00:00
uint32_t i = 0 ;
2010-05-30 01:00:45 +00:00
while ( ce - > trait_aliases [ i ] ) {
2014-03-02 13:54:46 +00:00
zend_string * mname ;
2010-05-30 01:00:45 +00:00
zend_trait_method_reference * cur_ref = ce - > trait_aliases [ i ] - > trait_method ;
2012-08-22 13:50:50 +00:00
if ( ce - > trait_aliases [ i ] - > alias ) {
2014-03-02 13:54:46 +00:00
2014-08-25 17:24:55 +00:00
mname = zend_string_alloc ( cur_ref - > ce - > name - > len + cur_ref - > method_name - > len + 2 , 0 ) ;
2014-03-02 13:54:46 +00:00
snprintf ( mname - > val , mname - > len + 1 , " %s::%s " , cur_ref - > ce - > name - > val , cur_ref - > method_name - > val ) ;
add_assoc_str_ex ( return_value , ce - > trait_aliases [ i ] - > alias - > val , ce - > trait_aliases [ i ] - > alias - > len , mname ) ;
2012-08-22 13:50:50 +00:00
}
2010-05-30 01:00:45 +00:00
i + + ;
}
}
}
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ proto public ReflectionClass ReflectionClass::getParentClass()
Returns the class ' parent class , or , if none exists , FALSE */
ZEND_METHOD ( reflection_class , getParentClass )
{
reflection_object * intern ;
zend_class_entry * ce ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( ce ) ;
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
if ( ce - > parent ) {
2014-12-13 22:06:14 +00:00
zend_reflection_class_factory ( ce - > parent , return_value ) ;
2005-11-30 21:53:20 +00:00
} else {
RETURN_FALSE ;
}
}
/* }}} */
/* {{{ proto public bool ReflectionClass::isSubclassOf(string|ReflectionClass class)
Returns whether this class is a subclass of another class */
ZEND_METHOD ( reflection_class , isSubclassOf )
{
reflection_object * intern , * argument ;
2014-02-10 06:04:30 +00:00
zend_class_entry * ce , * class_ce ;
2005-11-30 21:53:20 +00:00
zval * class_name ;
METHOD_NOTSTATIC ( reflection_class_ptr ) ;
GET_REFLECTION_OBJECT_PTR ( ce ) ;
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " z " , & class_name ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
2011-05-15 00:36:13 +00:00
2014-04-02 10:34:44 +00:00
switch ( Z_TYPE_P ( class_name ) ) {
2005-11-30 21:53:20 +00:00
case IS_STRING :
2014-12-13 22:06:14 +00:00
if ( ( class_ce = zend_lookup_class ( Z_STR_P ( class_name ) ) ) = = NULL ) {
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2007-07-11 13:27:49 +00:00
" Class %s does not exist " , Z_STRVAL_P ( class_name ) ) ;
2005-11-30 21:53:20 +00:00
return ;
}
2011-05-15 00:36:13 +00:00
break ;
2005-11-30 21:53:20 +00:00
case IS_OBJECT :
2014-12-13 22:06:14 +00:00
if ( instanceof_function ( Z_OBJCE_P ( class_name ) , reflection_class_ptr ) ) {
2014-03-17 04:15:22 +00:00
argument = Z_REFLECTION_P ( class_name ) ;
2005-11-30 21:53:20 +00:00
if ( argument = = NULL | | argument - > ptr = = NULL ) {
2014-12-13 22:06:14 +00:00
php_error_docref ( NULL , E_ERROR , " Internal error: Failed to retrieve the argument's reflection object " ) ;
2005-11-30 21:53:20 +00:00
/* Bails out */
}
class_ce = argument - > ptr ;
break ;
}
/* no break */
default :
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2005-11-30 21:53:20 +00:00
" Parameter one must either be a string or a ReflectionClass object " ) ;
return ;
}
2014-12-13 22:06:14 +00:00
RETURN_BOOL ( ( ce ! = class_ce & & instanceof_function ( ce , class_ce ) ) ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public bool ReflectionClass::implementsInterface(string|ReflectionClass interface_name)
Returns whether this class is a subclass of another class */
ZEND_METHOD ( reflection_class , implementsInterface )
{
reflection_object * intern , * argument ;
2014-02-10 06:04:30 +00:00
zend_class_entry * ce , * interface_ce ;
2005-11-30 21:53:20 +00:00
zval * interface ;
METHOD_NOTSTATIC ( reflection_class_ptr ) ;
GET_REFLECTION_OBJECT_PTR ( ce ) ;
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " z " , & interface ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
2011-05-15 00:36:13 +00:00
2014-04-02 10:34:44 +00:00
switch ( Z_TYPE_P ( interface ) ) {
2005-11-30 21:53:20 +00:00
case IS_STRING :
2014-12-13 22:06:14 +00:00
if ( ( interface_ce = zend_lookup_class ( Z_STR_P ( interface ) ) ) = = NULL ) {
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2005-11-30 21:53:20 +00:00
" Interface %s does not exist " , Z_STRVAL_P ( interface ) ) ;
return ;
}
2011-05-15 00:36:13 +00:00
break ;
2005-11-30 21:53:20 +00:00
case IS_OBJECT :
2014-12-13 22:06:14 +00:00
if ( instanceof_function ( Z_OBJCE_P ( interface ) , reflection_class_ptr ) ) {
2014-03-17 04:15:22 +00:00
argument = Z_REFLECTION_P ( interface ) ;
2005-11-30 21:53:20 +00:00
if ( argument = = NULL | | argument - > ptr = = NULL ) {
2014-12-13 22:06:14 +00:00
php_error_docref ( NULL , E_ERROR , " Internal error: Failed to retrieve the argument's reflection object " ) ;
2005-11-30 21:53:20 +00:00
/* Bails out */
}
interface_ce = argument - > ptr ;
break ;
}
/* no break */
default :
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2005-11-30 21:53:20 +00:00
" Parameter one must either be a string or a ReflectionClass object " ) ;
return ;
}
if ( ! ( interface_ce - > ce_flags & ZEND_ACC_INTERFACE ) ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2014-02-25 22:02:57 +00:00
" Interface %s is a Class " , interface_ce - > name - > val ) ;
2005-11-30 21:53:20 +00:00
return ;
}
2014-12-13 22:06:14 +00:00
RETURN_BOOL ( instanceof_function ( ce , interface_ce ) ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public bool ReflectionClass::isIterateable()
Returns whether this class is iterateable ( can be used inside foreach ) */
ZEND_METHOD ( reflection_class , isIterateable )
{
reflection_object * intern ;
zend_class_entry * ce ;
2011-05-15 00:36:13 +00:00
2010-08-21 16:09:18 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
METHOD_NOTSTATIC ( reflection_class_ptr ) ;
GET_REFLECTION_OBJECT_PTR ( ce ) ;
RETURN_BOOL ( ce - > get_iterator ! = NULL ) ;
}
/* }}} */
/* {{{ proto public ReflectionExtension|NULL ReflectionClass::getExtension()
Returns NULL or the extension the class belongs to */
ZEND_METHOD ( reflection_class , getExtension )
{
reflection_object * intern ;
zend_class_entry * ce ;
2011-05-15 00:36:13 +00:00
2010-08-21 16:09:18 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
METHOD_NOTSTATIC ( reflection_class_ptr ) ;
GET_REFLECTION_OBJECT_PTR ( ce ) ;
2010-09-15 07:38:52 +00:00
if ( ( ce - > type = = ZEND_INTERNAL_CLASS ) & & ce - > info . internal . module ) {
2014-12-13 22:06:14 +00:00
reflection_extension_factory ( return_value , ce - > info . internal . module - > name ) ;
2005-11-30 21:53:20 +00:00
}
}
/* }}} */
/* {{{ proto public string|false ReflectionClass::getExtensionName()
Returns false or the name of the extension the class belongs to */
ZEND_METHOD ( reflection_class , getExtensionName )
{
reflection_object * intern ;
zend_class_entry * ce ;
2011-05-15 00:36:13 +00:00
2010-08-21 16:09:18 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
METHOD_NOTSTATIC ( reflection_class_ptr ) ;
GET_REFLECTION_OBJECT_PTR ( ce ) ;
2010-09-15 07:38:52 +00:00
if ( ( ce - > type = = ZEND_INTERNAL_CLASS ) & & ce - > info . internal . module ) {
2014-02-10 06:04:30 +00:00
RETURN_STRING ( ce - > info . internal . module - > name ) ;
2005-11-30 21:53:20 +00:00
} else {
RETURN_FALSE ;
}
}
/* }}} */
2008-06-25 12:33:46 +00:00
/* {{{ proto public bool ReflectionClass::inNamespace()
Returns whether this class is defined in namespace */
ZEND_METHOD ( reflection_class , inNamespace )
{
2014-02-10 06:04:30 +00:00
zval * name ;
2010-11-19 15:48:11 +00:00
const char * backslash ;
2008-06-25 12:33:46 +00:00
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2014-12-13 22:06:14 +00:00
if ( ( name = _default_load_entry ( getThis ( ) , " name " , sizeof ( " name " ) - 1 ) ) = = NULL ) {
2008-06-25 12:33:46 +00:00
RETURN_FALSE ;
}
2014-02-10 06:04:30 +00:00
if ( Z_TYPE_P ( name ) = = IS_STRING
2014-08-25 17:24:55 +00:00
& & ( backslash = zend_memrchr ( Z_STRVAL_P ( name ) , ' \\ ' , Z_STRLEN_P ( name ) ) )
2014-02-10 06:04:30 +00:00
& & backslash > Z_STRVAL_P ( name ) )
2008-08-11 19:35:00 +00:00
{
2008-06-25 12:33:46 +00:00
RETURN_TRUE ;
2008-08-11 19:35:00 +00:00
}
2008-06-25 12:33:46 +00:00
RETURN_FALSE ;
}
/* }}} */
/* {{{ proto public string ReflectionClass::getNamespaceName()
Returns the name of namespace where this class is defined */
ZEND_METHOD ( reflection_class , getNamespaceName )
{
2014-02-10 06:04:30 +00:00
zval * name ;
2010-11-19 15:48:11 +00:00
const char * backslash ;
2008-06-25 12:33:46 +00:00
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2014-12-13 22:06:14 +00:00
if ( ( name = _default_load_entry ( getThis ( ) , " name " , sizeof ( " name " ) - 1 ) ) = = NULL ) {
2008-06-25 12:33:46 +00:00
RETURN_FALSE ;
}
2014-02-10 06:04:30 +00:00
if ( Z_TYPE_P ( name ) = = IS_STRING
2014-08-25 17:24:55 +00:00
& & ( backslash = zend_memrchr ( Z_STRVAL_P ( name ) , ' \\ ' , Z_STRLEN_P ( name ) ) )
2014-02-10 06:04:30 +00:00
& & backslash > Z_STRVAL_P ( name ) )
2008-08-11 19:35:00 +00:00
{
2014-02-10 06:04:30 +00:00
RETURN_STRINGL ( Z_STRVAL_P ( name ) , backslash - Z_STRVAL_P ( name ) ) ;
2008-08-11 19:35:00 +00:00
}
2008-06-25 12:33:46 +00:00
RETURN_EMPTY_STRING ( ) ;
}
/* }}} */
/* {{{ proto public string ReflectionClass::getShortName()
Returns the short name of the class ( without namespace part ) */
ZEND_METHOD ( reflection_class , getShortName )
{
2014-02-10 06:04:30 +00:00
zval * name ;
2010-11-19 15:48:11 +00:00
const char * backslash ;
2008-06-25 12:33:46 +00:00
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2014-12-13 22:06:14 +00:00
if ( ( name = _default_load_entry ( getThis ( ) , " name " , sizeof ( " name " ) - 1 ) ) = = NULL ) {
2008-06-25 12:33:46 +00:00
RETURN_FALSE ;
}
2014-02-10 06:04:30 +00:00
if ( Z_TYPE_P ( name ) = = IS_STRING
2014-08-25 17:24:55 +00:00
& & ( backslash = zend_memrchr ( Z_STRVAL_P ( name ) , ' \\ ' , Z_STRLEN_P ( name ) ) )
2014-02-10 06:04:30 +00:00
& & backslash > Z_STRVAL_P ( name ) )
2008-08-11 19:35:00 +00:00
{
2014-08-25 17:24:55 +00:00
RETURN_STRINGL ( backslash + 1 , Z_STRLEN_P ( name ) - ( backslash - Z_STRVAL_P ( name ) + 1 ) ) ;
2008-08-11 19:35:00 +00:00
}
2014-02-10 06:04:30 +00:00
RETURN_ZVAL ( name , 1 , 0 ) ;
2008-06-25 12:33:46 +00:00
}
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ proto public static mixed ReflectionObject::export(mixed argument [, bool return]) throws ReflectionException
Exports a reflection object . Returns the output if TRUE is specified for return , printing it otherwise . */
ZEND_METHOD ( reflection_object , export )
{
_reflection_export ( INTERNAL_FUNCTION_PARAM_PASSTHRU , reflection_object_ptr , 1 ) ;
}
/* }}} */
2006-03-06 09:50:44 +00:00
/* {{{ proto public void ReflectionObject::__construct(mixed argument) throws ReflectionException
2005-11-30 21:53:20 +00:00
Constructor . Takes an instance as an argument */
ZEND_METHOD ( reflection_object , __construct )
{
reflection_class_object_ctor ( INTERNAL_FUNCTION_PARAM_PASSTHRU , 1 ) ;
}
/* }}} */
/* {{{ proto public static mixed ReflectionProperty::export(mixed class, string name [, bool return]) throws ReflectionException
Exports a reflection object . Returns the output if TRUE is specified for return , printing it otherwise . */
ZEND_METHOD ( reflection_property , export )
{
_reflection_export ( INTERNAL_FUNCTION_PARAM_PASSTHRU , reflection_property_ptr , 2 ) ;
}
/* }}} */
2006-03-06 09:50:44 +00:00
/* {{{ proto public void ReflectionProperty::__construct(mixed class, string name)
2005-11-30 21:53:20 +00:00
Constructor . Throws an Exception in case the given property does not exist */
ZEND_METHOD ( reflection_property , __construct )
{
2014-02-10 06:04:30 +00:00
zval propname , cname , * classname ;
2011-09-13 13:29:35 +00:00
char * name_str ;
2014-08-27 15:31:24 +00:00
size_t name_len ;
int dynam_prop = 0 ;
2005-11-30 21:53:20 +00:00
zval * object ;
reflection_object * intern ;
zend_class_entry * ce ;
2008-10-29 12:56:29 +00:00
zend_property_info * property_info = NULL ;
2005-11-30 21:53:20 +00:00
property_reference * reference ;
2015-04-02 16:52:32 +00:00
if ( zend_parse_parameters_throw ( ZEND_NUM_ARGS ( ) , " zs " , & classname , & name_str , & name_len ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
object = getThis ( ) ;
2014-03-17 04:15:22 +00:00
intern = Z_REFLECTION_P ( object ) ;
2005-11-30 21:53:20 +00:00
if ( intern = = NULL ) {
return ;
}
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
/* Find the class entry */
switch ( Z_TYPE_P ( classname ) ) {
case IS_STRING :
2014-12-13 22:06:14 +00:00
if ( ( ce = zend_lookup_class ( Z_STR_P ( classname ) ) ) = = NULL ) {
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2011-05-15 00:36:13 +00:00
" Class %s does not exist " , Z_STRVAL_P ( classname ) ) ;
2005-11-30 21:53:20 +00:00
return ;
}
break ;
case IS_OBJECT :
ce = Z_OBJCE_P ( classname ) ;
break ;
2011-05-15 00:36:13 +00:00
2005-11-30 21:53:20 +00:00
default :
_DO_THROW ( " The parameter class is expected to be either a string or an object " ) ;
/* returns out of this function */
}
2014-02-10 06:04:30 +00:00
if ( ( property_info = zend_hash_str_find_ptr ( & ce - > properties_info , name_str , name_len ) ) = = NULL | | ( property_info - > flags & ZEND_ACC_SHADOW ) ) {
2008-10-29 12:56:29 +00:00
/* Check for dynamic properties */
if ( property_info = = NULL & & Z_TYPE_P ( classname ) = = IS_OBJECT & & Z_OBJ_HT_P ( classname ) - > get_properties ) {
2014-12-13 22:06:14 +00:00
if ( zend_hash_str_exists ( Z_OBJ_HT_P ( classname ) - > get_properties ( classname ) , name_str , name_len ) ) {
2008-10-29 12:56:29 +00:00
dynam_prop = 1 ;
}
}
if ( dynam_prop = = 0 ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 , " Property %s::$%s does not exist " , ce - > name - > val , name_str ) ;
2008-10-29 12:56:29 +00:00
return ;
}
2005-11-30 21:53:20 +00:00
}
2011-05-15 00:36:13 +00:00
2008-10-29 12:56:29 +00:00
if ( dynam_prop = = 0 & & ( property_info - > flags & ZEND_ACC_PRIVATE ) = = 0 ) {
2006-09-10 13:25:47 +00:00
/* we have to search the class hierarchy for this (implicit) public or protected property */
2006-02-13 14:49:26 +00:00
zend_class_entry * tmp_ce = ce ;
2005-11-30 21:53:20 +00:00
zend_property_info * tmp_info ;
2011-05-15 00:36:13 +00:00
2014-02-10 06:04:30 +00:00
while ( tmp_ce & & ( tmp_info = zend_hash_str_find_ptr ( & tmp_ce - > properties_info , name_str , name_len ) ) = = NULL ) {
2005-11-30 21:53:20 +00:00
ce = tmp_ce ;
property_info = tmp_info ;
tmp_ce = tmp_ce - > parent ;
}
}
2008-10-29 12:56:29 +00:00
if ( dynam_prop = = 0 ) {
2014-09-15 22:23:58 +00:00
const char * class_name , * prop_name ;
size_t prop_name_len ;
zend_unmangle_property_name_ex ( property_info - > name , & class_name , & prop_name , & prop_name_len ) ;
2014-09-19 13:32:50 +00:00
ZVAL_STR_COPY ( & cname , property_info - > ce - > name ) ;
2014-09-15 22:23:58 +00:00
ZVAL_STRINGL ( & propname , prop_name , prop_name_len ) ;
2008-10-29 12:56:29 +00:00
} else {
2014-09-19 13:32:50 +00:00
ZVAL_STR_COPY ( & cname , ce - > name ) ;
2014-02-10 06:04:30 +00:00
ZVAL_STRINGL ( & propname , name_str , name_len ) ;
2008-10-29 12:56:29 +00:00
}
2014-02-10 06:04:30 +00:00
reflection_update_property ( object , " class " , & cname ) ;
reflection_update_property ( object , " name " , & propname ) ;
2005-11-30 21:53:20 +00:00
reference = ( property_reference * ) emalloc ( sizeof ( property_reference ) ) ;
2008-10-29 12:56:29 +00:00
if ( dynam_prop ) {
reference - > prop . flags = ZEND_ACC_IMPLICIT_PUBLIC ;
2014-02-10 06:04:30 +00:00
reference - > prop . name = Z_STR ( propname ) ;
2008-10-29 12:56:29 +00:00
reference - > prop . doc_comment = NULL ;
reference - > prop . ce = ce ;
} else {
reference - > prop = * property_info ;
}
2005-11-30 21:53:20 +00:00
reference - > ce = ce ;
intern - > ptr = reference ;
2008-08-11 12:43:21 +00:00
intern - > ref_type = REF_TYPE_PROPERTY ;
2005-11-30 21:53:20 +00:00
intern - > ce = ce ;
2009-09-16 17:24:46 +00:00
intern - > ignore_visibility = 0 ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public string ReflectionProperty::__toString()
Returns a string representation */
ZEND_METHOD ( reflection_property , __toString )
{
reflection_object * intern ;
property_reference * ref ;
string str ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( ref ) ;
string_init ( & str ) ;
2014-12-13 22:06:14 +00:00
_property_string ( & str , & ref - > prop , NULL , " " ) ;
2015-03-12 13:53:51 +00:00
RETURN_NEW_STR ( str . buf ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public string ReflectionProperty::getName()
Returns the class ' name */
ZEND_METHOD ( reflection_property , getName )
{
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2014-12-13 22:06:14 +00:00
_default_get_entry ( getThis ( ) , " name " , sizeof ( " name " ) - 1 , return_value ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
2010-05-29 21:28:24 +00:00
static void _property_check_flag ( INTERNAL_FUNCTION_PARAMETERS , int mask ) /* { { { */
2005-11-30 21:53:20 +00:00
{
reflection_object * intern ;
property_reference * ref ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( ref ) ;
2007-03-17 23:00:49 +00:00
RETURN_BOOL ( ref - > prop . flags & mask ) ;
2005-11-30 21:53:20 +00:00
}
2010-05-29 21:28:24 +00:00
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ proto public bool ReflectionProperty::isPublic()
Returns whether this property is public */
ZEND_METHOD ( reflection_property , isPublic )
{
2008-10-29 12:56:29 +00:00
_property_check_flag ( INTERNAL_FUNCTION_PARAM_PASSTHRU , ZEND_ACC_PUBLIC | ZEND_ACC_IMPLICIT_PUBLIC ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public bool ReflectionProperty::isPrivate()
Returns whether this property is private */
ZEND_METHOD ( reflection_property , isPrivate )
{
_property_check_flag ( INTERNAL_FUNCTION_PARAM_PASSTHRU , ZEND_ACC_PRIVATE ) ;
}
/* }}} */
/* {{{ proto public bool ReflectionProperty::isProtected()
Returns whether this property is protected */
ZEND_METHOD ( reflection_property , isProtected )
{
_property_check_flag ( INTERNAL_FUNCTION_PARAM_PASSTHRU , ZEND_ACC_PROTECTED ) ;
}
/* }}} */
/* {{{ proto public bool ReflectionProperty::isStatic()
Returns whether this property is static */
ZEND_METHOD ( reflection_property , isStatic )
{
_property_check_flag ( INTERNAL_FUNCTION_PARAM_PASSTHRU , ZEND_ACC_STATIC ) ;
}
/* }}} */
/* {{{ proto public bool ReflectionProperty::isDefault()
Returns whether this property is default ( declared at compilation time ) . */
ZEND_METHOD ( reflection_property , isDefault )
{
_property_check_flag ( INTERNAL_FUNCTION_PARAM_PASSTHRU , ~ ZEND_ACC_IMPLICIT_PUBLIC ) ;
}
/* }}} */
/* {{{ proto public int ReflectionProperty::getModifiers()
Returns a bitfield of the access modifiers for this property */
ZEND_METHOD ( reflection_property , getModifiers )
{
reflection_object * intern ;
property_reference * ref ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( ref ) ;
2014-08-25 17:24:55 +00:00
RETURN_LONG ( ref - > prop . flags ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public mixed ReflectionProperty::getValue([stdclass object])
Returns this property ' s value */
ZEND_METHOD ( reflection_property , getValue )
{
reflection_object * intern ;
property_reference * ref ;
2014-03-26 14:07:31 +00:00
zval * object , * name ;
2010-05-24 14:11:39 +00:00
zval * member_p = NULL ;
2005-11-30 21:53:20 +00:00
METHOD_NOTSTATIC ( reflection_property_ptr ) ;
GET_REFLECTION_OBJECT_PTR ( ref ) ;
2009-09-16 17:24:46 +00:00
if ( ! ( ref - > prop . flags & ( ZEND_ACC_PUBLIC | ZEND_ACC_IMPLICIT_PUBLIC ) ) & & intern - > ignore_visibility = = 0 ) {
2014-12-13 22:06:14 +00:00
name = _default_load_entry ( getThis ( ) , " name " , sizeof ( " name " ) - 1 ) ;
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2014-03-26 14:07:31 +00:00
" Cannot access non-public member %s::%s " , intern - > ce - > name - > val , Z_STRVAL_P ( name ) ) ;
2006-07-10 00:18:53 +00:00
return ;
2005-11-30 21:53:20 +00:00
}
2007-03-17 23:00:49 +00:00
if ( ( ref - > prop . flags & ZEND_ACC_STATIC ) ) {
2015-04-01 23:05:25 +00:00
if ( UNEXPECTED ( zend_update_class_constants ( intern - > ce ) ! = SUCCESS ) ) {
return ;
}
2014-02-10 06:04:30 +00:00
if ( Z_TYPE ( CE_STATIC_MEMBERS ( intern - > ce ) [ ref - > prop . offset ] ) = = IS_UNDEF ) {
2014-12-13 22:06:14 +00:00
php_error_docref ( NULL , E_ERROR , " Internal error: Could not find the property %s::%s " , intern - > ce - > name - > val , ref - > prop . name - > val ) ;
2005-11-30 21:53:20 +00:00
/* Bails out */
}
2014-02-10 06:04:30 +00:00
ZVAL_DUP ( return_value , & CE_STATIC_MEMBERS ( intern - > ce ) [ ref - > prop . offset ] ) ;
2005-11-30 21:53:20 +00:00
} else {
2011-09-13 13:29:35 +00:00
const char * class_name , * prop_name ;
2014-09-15 22:23:58 +00:00
size_t prop_name_len ;
2015-01-22 08:50:42 +00:00
zval rv ;
2011-05-15 00:36:13 +00:00
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " o " , & object ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
2014-09-15 22:23:58 +00:00
zend_unmangle_property_name_ex ( ref - > prop . name , & class_name , & prop_name , & prop_name_len ) ;
2015-01-22 08:50:42 +00:00
member_p = zend_read_property ( ref - > ce , object , prop_name , prop_name_len , 1 , & rv ) ;
2014-02-10 06:04:30 +00:00
ZVAL_DUP ( return_value , member_p ) ;
2005-11-30 21:53:20 +00:00
}
}
/* }}} */
/* {{{ proto public void ReflectionProperty::setValue([stdclass object,] mixed value)
Sets this property ' s value */
ZEND_METHOD ( reflection_property , setValue )
{
reflection_object * intern ;
property_reference * ref ;
2014-02-10 06:04:30 +00:00
zval * variable_ptr ;
2014-03-26 14:07:31 +00:00
zval * object , * name ;
2005-11-30 21:53:20 +00:00
zval * value ;
zval * tmp ;
METHOD_NOTSTATIC ( reflection_property_ptr ) ;
GET_REFLECTION_OBJECT_PTR ( ref ) ;
2009-09-16 17:24:46 +00:00
if ( ! ( ref - > prop . flags & ZEND_ACC_PUBLIC ) & & intern - > ignore_visibility = = 0 ) {
2014-12-13 22:06:14 +00:00
name = _default_load_entry ( getThis ( ) , " name " , sizeof ( " name " ) - 1 ) ;
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2014-03-26 14:07:31 +00:00
" Cannot access non-public member %s::%s " , intern - > ce - > name - > val , Z_STRVAL_P ( name ) ) ;
2006-07-10 00:18:53 +00:00
return ;
2005-11-30 21:53:20 +00:00
}
2007-03-17 23:00:49 +00:00
if ( ( ref - > prop . flags & ZEND_ACC_STATIC ) ) {
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters_ex ( ZEND_PARSE_PARAMS_QUIET , ZEND_NUM_ARGS ( ) , " z " , & value ) = = FAILURE ) {
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " zz " , & tmp , & value ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
}
2015-04-01 23:05:25 +00:00
if ( UNEXPECTED ( zend_update_class_constants ( intern - > ce ) ! = SUCCESS ) ) {
return ;
}
2005-11-30 21:53:20 +00:00
2014-02-10 06:04:30 +00:00
if ( Z_TYPE ( CE_STATIC_MEMBERS ( intern - > ce ) [ ref - > prop . offset ] ) = = IS_UNDEF ) {
2014-12-13 22:06:14 +00:00
php_error_docref ( NULL , E_ERROR , " Internal error: Could not find the property %s::%s " , intern - > ce - > name - > val , ref - > prop . name - > val ) ;
2006-08-31 16:15:24 +00:00
/* Bails out */
}
2010-05-24 14:11:39 +00:00
variable_ptr = & CE_STATIC_MEMBERS ( intern - > ce ) [ ref - > prop . offset ] ;
2014-02-10 06:04:30 +00:00
if ( variable_ptr ! = value ) {
if ( Z_ISREF_P ( variable_ptr ) ) {
zval garbage ;
2015-01-03 09:22:58 +00:00
2014-02-10 06:04:30 +00:00
ZVAL_COPY_VALUE ( & garbage , variable_ptr ) ; /* old value should be destroyed */
2010-05-24 14:11:39 +00:00
/* To check: can't *variable_ptr be some system variable like error_zval here? */
2014-02-10 06:04:30 +00:00
ZVAL_COPY_VALUE ( variable_ptr , value ) ;
2014-03-17 04:16:46 +00:00
if ( Z_REFCOUNTED_P ( value ) & & Z_REFCOUNT_P ( value ) > 0 ) {
2014-02-10 06:04:30 +00:00
zval_copy_ctor ( variable_ptr ) ;
2006-08-31 16:15:24 +00:00
}
2010-05-24 14:11:39 +00:00
zval_dtor ( & garbage ) ;
} else {
2014-02-10 06:04:30 +00:00
zval garbage ;
2015-01-03 09:22:58 +00:00
2014-02-10 06:04:30 +00:00
ZVAL_COPY_VALUE ( & garbage , variable_ptr ) ;
2010-05-24 14:11:39 +00:00
/* if we assign referenced variable, we should separate it */
2014-03-02 07:15:51 +00:00
if ( Z_REFCOUNTED_P ( value ) ) {
Z_ADDREF_P ( value ) ;
}
2014-02-10 06:04:30 +00:00
if ( Z_ISREF_P ( value ) ) {
SEPARATE_ZVAL ( value ) ;
2010-05-24 14:11:39 +00:00
}
2014-02-10 06:04:30 +00:00
ZVAL_COPY_VALUE ( variable_ptr , value ) ;
2010-05-24 14:11:39 +00:00
zval_ptr_dtor ( & garbage ) ;
2006-08-31 16:15:24 +00:00
}
}
} else {
2011-09-13 13:29:35 +00:00
const char * class_name , * prop_name ;
2014-09-15 22:23:58 +00:00
size_t prop_name_len ;
2008-11-29 15:58:54 +00:00
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " oz " , & object , & value ) = = FAILURE ) {
2006-08-31 16:15:24 +00:00
return ;
2005-11-30 21:53:20 +00:00
}
2014-09-15 22:23:58 +00:00
zend_unmangle_property_name_ex ( ref - > prop . name , & class_name , & prop_name , & prop_name_len ) ;
2014-12-13 22:06:14 +00:00
zend_update_property ( ref - > ce , object , prop_name , prop_name_len , value ) ;
2005-11-30 21:53:20 +00:00
}
}
/* }}} */
/* {{{ proto public ReflectionClass ReflectionProperty::getDeclaringClass()
Get the declaring class */
ZEND_METHOD ( reflection_property , getDeclaringClass )
{
reflection_object * intern ;
property_reference * ref ;
2006-02-20 15:27:45 +00:00
zend_class_entry * tmp_ce , * ce ;
zend_property_info * tmp_info ;
2011-09-13 13:29:35 +00:00
const char * prop_name , * class_name ;
2014-09-15 22:23:58 +00:00
size_t prop_name_len ;
2005-11-30 21:53:20 +00:00
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( ref ) ;
2014-09-15 22:23:58 +00:00
if ( zend_unmangle_property_name_ex ( ref - > prop . name , & class_name , & prop_name , & prop_name_len ) ! = SUCCESS ) {
2006-10-02 12:16:35 +00:00
RETURN_FALSE ;
}
2006-02-20 15:27:45 +00:00
ce = tmp_ce = ref - > ce ;
2014-02-10 06:04:30 +00:00
while ( tmp_ce & & ( tmp_info = zend_hash_str_find_ptr ( & tmp_ce - > properties_info , prop_name , prop_name_len ) ) ! = NULL ) {
2008-06-01 03:11:38 +00:00
if ( tmp_info - > flags & ZEND_ACC_PRIVATE | | tmp_info - > flags & ZEND_ACC_SHADOW ) {
2006-10-06 17:35:32 +00:00
/* it's a private property, so it can't be inherited */
break ;
}
2006-10-06 18:03:19 +00:00
ce = tmp_ce ;
2009-05-21 16:01:37 +00:00
if ( tmp_ce = = tmp_info - > ce ) {
/* declared in this class, done */
break ;
}
2006-10-06 18:03:19 +00:00
tmp_ce = tmp_ce - > parent ;
2006-02-20 15:27:45 +00:00
}
2014-12-13 22:06:14 +00:00
zend_reflection_class_factory ( ce , return_value ) ;
2005-11-30 21:53:20 +00:00
}
2006-06-07 22:39:22 +00:00
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ proto public string ReflectionProperty::getDocComment()
Returns the doc comment for this property */
ZEND_METHOD ( reflection_property , getDocComment )
{
reflection_object * intern ;
property_reference * ref ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( ref ) ;
2007-03-17 23:00:49 +00:00
if ( ref - > prop . doc_comment ) {
2015-03-12 13:53:51 +00:00
RETURN_STR_COPY ( ref - > prop . doc_comment ) ;
2005-11-30 21:53:20 +00:00
}
RETURN_FALSE ;
}
/* }}} */
2006-06-07 22:39:22 +00:00
2009-10-03 20:45:29 +00:00
/* {{{ proto public int ReflectionProperty::setAccessible(bool visible)
2008-02-15 12:38:53 +00:00
Sets whether non - public properties can be requested */
2008-02-15 12:48:13 +00:00
ZEND_METHOD ( reflection_property , setAccessible )
2008-02-15 12:38:53 +00:00
{
reflection_object * intern ;
zend_bool visible ;
2014-12-13 22:06:14 +00:00
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , " b " , & visible ) = = FAILURE ) {
2008-02-15 12:38:53 +00:00
return ;
}
2009-09-16 17:24:46 +00:00
2014-03-17 04:15:22 +00:00
intern = Z_REFLECTION_P ( getThis ( ) ) ;
2009-09-16 17:24:46 +00:00
if ( intern = = NULL ) {
return ;
}
intern - > ignore_visibility = visible ;
2008-02-15 12:38:53 +00:00
}
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ proto public static mixed ReflectionExtension::export(string name [, bool return]) throws ReflectionException
Exports a reflection object . Returns the output if TRUE is specified for return , printing it otherwise . */
ZEND_METHOD ( reflection_extension , export )
{
_reflection_export ( INTERNAL_FUNCTION_PARAM_PASSTHRU , reflection_extension_ptr , 1 ) ;
}
/* }}} */
2006-03-06 09:50:44 +00:00
/* {{{ proto public void ReflectionExtension::__construct(string name)
2005-11-30 21:53:20 +00:00
Constructor . Throws an Exception in case the given extension does not exist */
ZEND_METHOD ( reflection_extension , __construct )
{
2014-02-10 06:04:30 +00:00
zval name ;
2005-11-30 21:53:20 +00:00
zval * object ;
char * lcname ;
reflection_object * intern ;
zend_module_entry * module ;
char * name_str ;
2014-08-27 15:31:24 +00:00
size_t name_len ;
2007-11-22 13:27:13 +00:00
ALLOCA_FLAG ( use_heap )
2005-11-30 21:53:20 +00:00
2015-04-02 16:52:32 +00:00
if ( zend_parse_parameters_throw ( ZEND_NUM_ARGS ( ) , " s " , & name_str , & name_len ) = = FAILURE ) {
2005-11-30 21:53:20 +00:00
return ;
}
object = getThis ( ) ;
2014-03-17 04:15:22 +00:00
intern = Z_REFLECTION_P ( object ) ;
2005-11-30 21:53:20 +00:00
if ( intern = = NULL ) {
return ;
}
2007-11-22 13:27:13 +00:00
lcname = do_alloca ( name_len + 1 , use_heap ) ;
2005-11-30 21:53:20 +00:00
zend_str_tolower_copy ( lcname , name_str , name_len ) ;
2014-02-10 06:04:30 +00:00
if ( ( module = zend_hash_str_find_ptr ( & module_registry , lcname , name_len ) ) = = NULL ) {
2007-11-22 13:27:13 +00:00
free_alloca ( lcname , use_heap ) ;
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2005-11-30 21:53:20 +00:00
" Extension %s does not exist " , name_str ) ;
return ;
}
2007-11-22 13:27:13 +00:00
free_alloca ( lcname , use_heap ) ;
2014-02-10 06:04:30 +00:00
ZVAL_STRING ( & name , module - > name ) ;
reflection_update_property ( object , " name " , & name ) ;
2005-11-30 21:53:20 +00:00
intern - > ptr = module ;
2008-08-11 12:43:21 +00:00
intern - > ref_type = REF_TYPE_OTHER ;
2005-11-30 21:53:20 +00:00
intern - > ce = NULL ;
}
/* }}} */
/* {{{ proto public string ReflectionExtension::__toString()
Returns a string representation */
ZEND_METHOD ( reflection_extension , __toString )
{
reflection_object * intern ;
zend_module_entry * module ;
string str ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( module ) ;
string_init ( & str ) ;
2014-12-13 22:06:14 +00:00
_extension_string ( & str , module , " " ) ;
2015-03-12 13:53:51 +00:00
RETURN_NEW_STR ( str . buf ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public string ReflectionExtension::getName()
Returns this extension ' s name */
ZEND_METHOD ( reflection_extension , getName )
{
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2014-12-13 22:06:14 +00:00
_default_get_entry ( getThis ( ) , " name " , sizeof ( " name " ) - 1 , return_value ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public string ReflectionExtension::getVersion()
Returns this extension ' s version */
ZEND_METHOD ( reflection_extension , getVersion )
{
reflection_object * intern ;
zend_module_entry * module ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( module ) ;
/* An extension does not necessarily have a version number */
if ( module - > version = = NO_VERSION_YET ) {
RETURN_NULL ( ) ;
} else {
2014-02-10 06:04:30 +00:00
RETURN_STRING ( module - > version ) ;
2005-11-30 21:53:20 +00:00
}
}
/* }}} */
/* {{{ proto public ReflectionFunction[] ReflectionExtension::getFunctions()
2013-07-23 23:55:43 +00:00
Returns an array of this extension ' s functions */
2005-11-30 21:53:20 +00:00
ZEND_METHOD ( reflection_extension , getFunctions )
{
reflection_object * intern ;
zend_module_entry * module ;
2014-02-10 06:04:30 +00:00
zval function ;
2013-12-10 15:07:16 +00:00
zend_function * fptr ;
2005-11-30 21:53:20 +00:00
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( module ) ;
array_init ( return_value ) ;
2015-02-10 12:43:12 +00:00
ZEND_HASH_FOREACH_PTR ( CG ( function_table ) , fptr ) {
2013-12-10 15:07:16 +00:00
if ( fptr - > common . type = = ZEND_INTERNAL_FUNCTION
& & fptr - > internal_function . module = = module ) {
2014-12-13 22:06:14 +00:00
reflection_function_factory ( fptr , NULL , & function ) ;
2014-04-01 18:36:17 +00:00
zend_hash_update ( Z_ARRVAL_P ( return_value ) , fptr - > common . function_name , & function ) ;
2005-11-30 21:53:20 +00:00
}
2015-02-10 12:43:12 +00:00
} ZEND_HASH_FOREACH_END ( ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
2014-12-13 22:06:14 +00:00
static int _addconstant ( zval * el , int num_args , va_list args , zend_hash_key * hash_key ) /* { { { */
2005-11-30 21:53:20 +00:00
{
2014-02-10 06:04:30 +00:00
zval const_val ;
2014-03-02 07:14:00 +00:00
zend_constant * constant = ( zend_constant * ) Z_PTR_P ( el ) ;
2005-11-30 21:53:20 +00:00
zval * retval = va_arg ( args , zval * ) ;
int number = va_arg ( args , int ) ;
if ( number = = constant - > module_number ) {
2014-02-10 06:04:30 +00:00
ZVAL_DUP ( & const_val , & constant - > value ) ;
2014-04-01 18:36:17 +00:00
zend_hash_update ( Z_ARRVAL_P ( retval ) , constant - > name , & const_val ) ;
2005-11-30 21:53:20 +00:00
}
return 0 ;
}
2010-05-29 21:28:24 +00:00
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ proto public array ReflectionExtension::getConstants()
Returns an associative array containing this extension ' s constants and their values */
ZEND_METHOD ( reflection_extension , getConstants )
{
reflection_object * intern ;
zend_module_entry * module ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( module ) ;
array_init ( return_value ) ;
2014-12-13 22:06:14 +00:00
zend_hash_apply_with_arguments ( EG ( zend_constants ) , ( apply_func_args_t ) _addconstant , 2 , return_value , module - > module_number ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ _addinientry */
2014-12-13 22:06:14 +00:00
static int _addinientry ( zval * el , int num_args , va_list args , zend_hash_key * hash_key )
2005-11-30 21:53:20 +00:00
{
2014-03-02 07:14:00 +00:00
zend_ini_entry * ini_entry = ( zend_ini_entry * ) Z_PTR_P ( el ) ;
2005-11-30 21:53:20 +00:00
zval * retval = va_arg ( args , zval * ) ;
int number = va_arg ( args , int ) ;
if ( number = = ini_entry - > module_number ) {
if ( ini_entry - > value ) {
2014-09-01 16:57:33 +00:00
zval zv ;
2014-09-19 13:32:50 +00:00
ZVAL_STR_COPY ( & zv , ini_entry - > value ) ;
2014-09-01 16:57:33 +00:00
zend_symtable_update ( Z_ARRVAL_P ( retval ) , ini_entry - > name , & zv ) ;
2005-11-30 21:53:20 +00:00
} else {
2014-09-01 16:57:33 +00:00
zend_symtable_update ( Z_ARRVAL_P ( retval ) , ini_entry - > name , & EG ( uninitialized_zval ) ) ;
2005-11-30 21:53:20 +00:00
}
}
return ZEND_HASH_APPLY_KEEP ;
}
/* }}} */
/* {{{ proto public array ReflectionExtension::getINIEntries()
Returns an associative array containing this extension ' s INI entries and their values */
ZEND_METHOD ( reflection_extension , getINIEntries )
{
reflection_object * intern ;
zend_module_entry * module ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( module ) ;
array_init ( return_value ) ;
2014-12-13 22:06:14 +00:00
zend_hash_apply_with_arguments ( EG ( ini_directives ) , ( apply_func_args_t ) _addinientry , 2 , return_value , module - > module_number ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ add_extension_class */
2014-12-13 22:06:14 +00:00
static int add_extension_class ( zval * zv , int num_args , va_list args , zend_hash_key * hash_key )
2005-11-30 21:53:20 +00:00
{
2014-04-01 18:36:17 +00:00
zend_class_entry * ce = Z_PTR_P ( zv ) ;
2014-02-10 06:04:30 +00:00
zval * class_array = va_arg ( args , zval * ) , zclass ;
2005-11-30 21:53:20 +00:00
struct _zend_module_entry * module = va_arg ( args , struct _zend_module_entry * ) ;
int add_reflection_class = va_arg ( args , int ) ;
2014-04-01 18:36:17 +00:00
if ( ( ce - > type = = ZEND_INTERNAL_CLASS ) & & ce - > info . internal . module & & ! strcasecmp ( ce - > info . internal . module - > name , module - > name ) ) {
2014-09-26 07:28:02 +00:00
zend_string * name ;
2014-09-26 06:56:42 +00:00
2014-09-26 07:28:02 +00:00
if ( zend_binary_strcasecmp ( ce - > name - > val , ce - > name - > len , hash_key - > key - > val , hash_key - > key - > len ) ) {
2014-09-26 06:56:42 +00:00
/* This is an class alias, use alias name */
2014-09-26 07:28:02 +00:00
name = hash_key - > key ;
2014-09-26 06:56:42 +00:00
} else {
/* Use class name */
2014-09-26 07:28:02 +00:00
name = ce - > name ;
2014-09-26 06:56:42 +00:00
}
2005-11-30 21:53:20 +00:00
if ( add_reflection_class ) {
2014-12-13 22:06:14 +00:00
zend_reflection_class_factory ( ce , & zclass ) ;
2014-09-26 07:28:02 +00:00
zend_hash_update ( Z_ARRVAL_P ( class_array ) , name , & zclass ) ;
2005-11-30 21:53:20 +00:00
} else {
2014-09-26 07:28:02 +00:00
add_next_index_str ( class_array , zend_string_copy ( name ) ) ;
2005-11-30 21:53:20 +00:00
}
}
return ZEND_HASH_APPLY_KEEP ;
}
/* }}} */
/* {{{ proto public ReflectionClass[] ReflectionExtension::getClasses()
Returns an array containing ReflectionClass objects for all classes of this extension */
ZEND_METHOD ( reflection_extension , getClasses )
{
reflection_object * intern ;
zend_module_entry * module ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( module ) ;
array_init ( return_value ) ;
2014-12-13 22:06:14 +00:00
zend_hash_apply_with_arguments ( EG ( class_table ) , ( apply_func_args_t ) add_extension_class , 3 , return_value , module , 1 ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
/* {{{ proto public array ReflectionExtension::getClassNames()
Returns an array containing all names of all classes of this extension */
ZEND_METHOD ( reflection_extension , getClassNames )
{
reflection_object * intern ;
zend_module_entry * module ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2005-11-30 21:53:20 +00:00
GET_REFLECTION_OBJECT_PTR ( module ) ;
array_init ( return_value ) ;
2014-12-13 22:06:14 +00:00
zend_hash_apply_with_arguments ( EG ( class_table ) , ( apply_func_args_t ) add_extension_class , 3 , return_value , module , 0 ) ;
2005-11-30 21:53:20 +00:00
}
/* }}} */
2006-02-25 21:17:18 +00:00
/* {{{ proto public array ReflectionExtension::getDependencies()
Returns an array containing all names of all extensions this extension depends on */
ZEND_METHOD ( reflection_extension , getDependencies )
{
reflection_object * intern ;
zend_module_entry * module ;
2007-09-27 18:00:48 +00:00
const zend_module_dep * dep ;
2006-02-25 21:17:18 +00:00
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2006-02-25 21:17:18 +00:00
GET_REFLECTION_OBJECT_PTR ( module ) ;
2011-05-15 00:36:13 +00:00
2006-02-25 21:17:18 +00:00
array_init ( return_value ) ;
dep = module - > deps ;
2011-05-15 00:36:13 +00:00
2006-02-25 21:17:18 +00:00
if ( ! dep )
{
return ;
}
while ( dep - > name ) {
2014-03-02 13:54:46 +00:00
zend_string * relation ;
2006-02-25 21:17:18 +00:00
char * rel_type ;
2014-10-29 13:28:16 +00:00
size_t len = 0 ;
2011-05-15 00:36:13 +00:00
2006-02-25 21:17:18 +00:00
switch ( dep - > type ) {
2014-03-02 13:54:46 +00:00
case MODULE_DEP_REQUIRED :
rel_type = " Required " ;
len + = sizeof ( " Required " ) - 1 ;
break ;
case MODULE_DEP_CONFLICTS :
rel_type = " Conflicts " ;
len + = sizeof ( " Conflicts " ) - 1 ;
break ;
case MODULE_DEP_OPTIONAL :
rel_type = " Optional " ;
len + = sizeof ( " Optional " ) - 1 ;
break ;
default :
rel_type = " Error " ; /* shouldn't happen */
len + = sizeof ( " Error " ) - 1 ;
break ;
}
if ( dep - > rel ) {
len + = strlen ( dep - > rel ) + 1 ;
}
if ( dep - > version ) {
len + = strlen ( dep - > version ) + 1 ;
2006-02-25 21:17:18 +00:00
}
2014-08-25 17:24:55 +00:00
relation = zend_string_alloc ( len , 0 ) ;
2014-03-02 13:54:46 +00:00
snprintf ( relation - > val , relation - > len + 1 , " %s%s%s%s%s " ,
2006-02-25 21:17:18 +00:00
rel_type ,
dep - > rel ? " " : " " ,
2011-05-15 00:36:13 +00:00
dep - > rel ? dep - > rel : " " ,
2006-02-25 21:17:18 +00:00
dep - > version ? " " : " " ,
dep - > version ? dep - > version : " " ) ;
2014-03-02 13:54:46 +00:00
add_assoc_str ( return_value , dep - > name , relation ) ;
2006-02-25 21:17:18 +00:00
dep + + ;
}
}
/* }}} */
2010-05-20 19:18:35 +00:00
/* {{{ proto public void ReflectionExtension::info()
2007-07-24 23:15:58 +00:00
Prints phpinfo block for the extension */
ZEND_METHOD ( reflection_extension , info )
{
reflection_object * intern ;
zend_module_entry * module ;
2009-01-07 22:40:17 +00:00
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
2007-07-24 23:15:58 +00:00
GET_REFLECTION_OBJECT_PTR ( module ) ;
2014-12-13 22:06:14 +00:00
php_info_print_module ( module ) ;
2007-07-24 23:15:58 +00:00
}
/* }}} */
2010-03-30 22:36:17 +00:00
/* {{{ proto public bool ReflectionExtension::isPersistent()
2010-03-30 20:50:42 +00:00
Returns whether this extension is persistent */
ZEND_METHOD ( reflection_extension , isPersistent )
{
reflection_object * intern ;
zend_module_entry * module ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
GET_REFLECTION_OBJECT_PTR ( module ) ;
RETURN_BOOL ( module - > type = = MODULE_PERSISTENT ) ;
}
/* }}} */
2010-03-30 22:36:17 +00:00
/* {{{ proto public bool ReflectionExtension::isTemporary()
2010-03-30 20:50:42 +00:00
Returns whether this extension is temporary */
ZEND_METHOD ( reflection_extension , isTemporary )
{
reflection_object * intern ;
zend_module_entry * module ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
GET_REFLECTION_OBJECT_PTR ( module ) ;
RETURN_BOOL ( module - > type = = MODULE_TEMPORARY ) ;
}
2010-03-30 21:04:28 +00:00
/* }}} */
2010-03-30 20:50:42 +00:00
2010-03-30 22:35:23 +00:00
/* {{{ proto public static mixed ReflectionZendExtension::export(string name [, bool return]) throws ReflectionException
* Exports a reflection object . Returns the output if TRUE is specified for return , printing it otherwise . */
ZEND_METHOD ( reflection_zend_extension , export )
{
_reflection_export ( INTERNAL_FUNCTION_PARAM_PASSTHRU , reflection_zend_extension_ptr , 1 ) ;
}
/* }}} */
/* {{{ proto public void ReflectionZendExtension::__construct(string name)
Constructor . Throws an Exception in case the given Zend extension does not exist */
ZEND_METHOD ( reflection_zend_extension , __construct )
{
2014-02-10 06:04:30 +00:00
zval name ;
2010-03-30 22:35:23 +00:00
zval * object ;
reflection_object * intern ;
zend_extension * extension ;
char * name_str ;
2014-08-27 15:31:24 +00:00
size_t name_len ;
2010-03-30 22:35:23 +00:00
2015-04-02 16:52:32 +00:00
if ( zend_parse_parameters_throw ( ZEND_NUM_ARGS ( ) , " s " , & name_str , & name_len ) = = FAILURE ) {
2010-03-30 22:35:23 +00:00
return ;
}
object = getThis ( ) ;
2014-03-17 04:15:22 +00:00
intern = Z_REFLECTION_P ( object ) ;
2010-03-30 22:35:23 +00:00
if ( intern = = NULL ) {
return ;
}
extension = zend_get_extension ( name_str ) ;
if ( ! extension ) {
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2010-03-30 22:35:23 +00:00
" Zend Extension %s does not exist " , name_str ) ;
return ;
}
2014-02-10 06:04:30 +00:00
ZVAL_STRING ( & name , extension - > name ) ;
reflection_update_property ( object , " name " , & name ) ;
2010-03-30 22:35:23 +00:00
intern - > ptr = extension ;
intern - > ref_type = REF_TYPE_OTHER ;
intern - > ce = NULL ;
}
/* }}} */
/* {{{ proto public string ReflectionZendExtension::__toString()
Returns a string representation */
ZEND_METHOD ( reflection_zend_extension , __toString )
{
reflection_object * intern ;
zend_extension * extension ;
string str ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
GET_REFLECTION_OBJECT_PTR ( extension ) ;
string_init ( & str ) ;
2014-12-13 22:06:14 +00:00
_zend_extension_string ( & str , extension , " " ) ;
2015-03-12 13:53:51 +00:00
RETURN_NEW_STR ( str . buf ) ;
2011-05-15 00:36:13 +00:00
}
2010-03-30 22:35:23 +00:00
/* }}} */
/* {{{ proto public string ReflectionZendExtension::getName()
Returns the name of this Zend extension */
ZEND_METHOD ( reflection_zend_extension , getName )
{
reflection_object * intern ;
zend_extension * extension ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
GET_REFLECTION_OBJECT_PTR ( extension ) ;
2014-02-10 06:04:30 +00:00
RETURN_STRING ( extension - > name ) ;
2010-03-30 22:35:23 +00:00
}
/* }}} */
/* {{{ proto public string ReflectionZendExtension::getVersion()
Returns the version information of this Zend extension */
ZEND_METHOD ( reflection_zend_extension , getVersion )
{
reflection_object * intern ;
zend_extension * extension ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
GET_REFLECTION_OBJECT_PTR ( extension ) ;
2014-02-10 06:04:30 +00:00
if ( extension - > version ) {
RETURN_STRING ( extension - > version ) ;
} else {
RETURN_EMPTY_STRING ( ) ;
}
2010-03-30 22:35:23 +00:00
}
/* }}} */
/* {{{ proto public void ReflectionZendExtension::getAuthor()
* Returns the name of this Zend extension ' s author */
ZEND_METHOD ( reflection_zend_extension , getAuthor )
{
reflection_object * intern ;
zend_extension * extension ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
GET_REFLECTION_OBJECT_PTR ( extension ) ;
2014-02-10 06:04:30 +00:00
if ( extension - > author ) {
RETURN_STRING ( extension - > author ) ;
} else {
RETURN_EMPTY_STRING ( ) ;
}
2010-03-30 22:35:23 +00:00
}
/* }}} */
/* {{{ proto public void ReflectionZendExtension::getURL()
Returns this Zend extension ' s URL */
ZEND_METHOD ( reflection_zend_extension , getURL )
{
reflection_object * intern ;
zend_extension * extension ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
GET_REFLECTION_OBJECT_PTR ( extension ) ;
2014-02-10 06:04:30 +00:00
if ( extension - > URL ) {
RETURN_STRING ( extension - > URL ) ;
} else {
RETURN_EMPTY_STRING ( ) ;
}
2010-03-30 22:35:23 +00:00
}
/* }}} */
/* {{{ proto public void ReflectionZendExtension::getCopyright()
Returns this Zend extension ' s copyright information */
ZEND_METHOD ( reflection_zend_extension , getCopyright )
{
reflection_object * intern ;
zend_extension * extension ;
if ( zend_parse_parameters_none ( ) = = FAILURE ) {
return ;
}
GET_REFLECTION_OBJECT_PTR ( extension ) ;
2014-02-10 06:04:30 +00:00
if ( extension - > copyright ) {
RETURN_STRING ( extension - > copyright ) ;
} else {
RETURN_EMPTY_STRING ( ) ;
}
2010-03-30 22:35:23 +00:00
}
/* }}} */
2005-11-30 21:53:20 +00:00
/* {{{ method tables */
2007-09-27 18:00:48 +00:00
static const zend_function_entry reflection_exception_functions [ ] = {
2011-07-25 11:35:02 +00:00
PHP_FE_END
2005-11-30 21:53:20 +00:00
} ;
2014-10-04 18:06:02 +00:00
ZEND_BEGIN_ARG_INFO ( arginfo_reflection__void , 0 )
2009-10-03 20:45:29 +00:00
ZEND_END_ARG_INFO ( )
2006-06-07 22:39:22 +00:00
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_getModifierNames , 0 )
ZEND_ARG_INFO ( 0 , modifiers )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO_EX ( arginfo_reflection_export , 0 , 0 , 1 )
ZEND_ARG_OBJ_INFO ( 0 , reflector , Reflector , 0 )
ZEND_ARG_INFO ( 0 , return )
ZEND_END_ARG_INFO ( )
2007-09-27 18:00:48 +00:00
static const zend_function_entry reflection_functions [ ] = {
2006-06-07 22:39:22 +00:00
ZEND_ME ( reflection , getModifierNames , arginfo_reflection_getModifierNames , ZEND_ACC_PUBLIC | ZEND_ACC_STATIC )
ZEND_ME ( reflection , export , arginfo_reflection_export , ZEND_ACC_PUBLIC | ZEND_ACC_STATIC )
2011-07-25 11:35:02 +00:00
PHP_FE_END
2005-11-30 21:53:20 +00:00
} ;
2007-09-27 18:00:48 +00:00
static const zend_function_entry reflector_functions [ ] = {
2005-11-30 21:53:20 +00:00
ZEND_FENTRY ( export , NULL , NULL , ZEND_ACC_STATIC | ZEND_ACC_ABSTRACT | ZEND_ACC_PUBLIC )
2009-10-03 20:45:29 +00:00
ZEND_ABSTRACT_ME ( reflector , __toString , arginfo_reflection__void )
2011-07-25 11:35:02 +00:00
PHP_FE_END
2005-11-30 21:53:20 +00:00
} ;
2006-06-07 22:39:22 +00:00
ZEND_BEGIN_ARG_INFO_EX ( arginfo_reflection_function_export , 0 , 0 , 1 )
ZEND_ARG_INFO ( 0 , name )
ZEND_ARG_INFO ( 0 , return )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_function___construct , 0 )
ZEND_ARG_INFO ( 0 , name )
ZEND_END_ARG_INFO ( )
2009-07-01 17:38:03 +00:00
ZEND_BEGIN_ARG_INFO_EX ( arginfo_reflection_function_invoke , 0 , 0 , 0 )
2006-06-07 22:39:22 +00:00
ZEND_ARG_INFO ( 0 , args )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_function_invokeArgs , 0 )
ZEND_ARG_ARRAY_INFO ( 0 , args , 0 )
ZEND_END_ARG_INFO ( )
2007-09-27 18:00:48 +00:00
static const zend_function_entry reflection_function_abstract_functions [ ] = {
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection , __clone , arginfo_reflection__void , ZEND_ACC_PRIVATE | ZEND_ACC_FINAL )
ZEND_ME ( reflection_function , inNamespace , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_function , isClosure , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_function , isDeprecated , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_function , isInternal , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_function , isUserDefined , arginfo_reflection__void , 0 )
2012-09-02 15:29:56 +00:00
ZEND_ME ( reflection_function , isGenerator , arginfo_reflection__void , 0 )
2013-09-26 16:39:17 +00:00
ZEND_ME ( reflection_function , isVariadic , arginfo_reflection__void , 0 )
2010-04-19 19:45:03 +00:00
ZEND_ME ( reflection_function , getClosureThis , arginfo_reflection__void , 0 )
2011-09-07 06:46:27 +00:00
ZEND_ME ( reflection_function , getClosureScopeClass , arginfo_reflection__void , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_function , getDocComment , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_function , getEndLine , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_function , getExtension , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_function , getExtensionName , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_function , getFileName , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_function , getName , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_function , getNamespaceName , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_function , getNumberOfParameters , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_function , getNumberOfRequiredParameters , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_function , getParameters , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_function , getShortName , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_function , getStartLine , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_function , getStaticVariables , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_function , returnsReference , arginfo_reflection__void , 0 )
2011-07-25 11:35:02 +00:00
PHP_FE_END
2005-11-30 21:53:20 +00:00
} ;
2007-09-27 18:00:48 +00:00
static const zend_function_entry reflection_function_functions [ ] = {
2006-09-10 13:25:47 +00:00
ZEND_ME ( reflection_function , __construct , arginfo_reflection_function___construct , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_function , __toString , arginfo_reflection__void , 0 )
2006-06-10 00:40:57 +00:00
ZEND_ME ( reflection_function , export , arginfo_reflection_function_export , ZEND_ACC_STATIC | ZEND_ACC_PUBLIC )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_function , isDisabled , arginfo_reflection__void , 0 )
2006-06-10 00:40:57 +00:00
ZEND_ME ( reflection_function , invoke , arginfo_reflection_function_invoke , 0 )
ZEND_ME ( reflection_function , invokeArgs , arginfo_reflection_function_invokeArgs , 0 )
2010-04-19 19:45:03 +00:00
ZEND_ME ( reflection_function , getClosure , arginfo_reflection__void , 0 )
2011-07-25 11:35:02 +00:00
PHP_FE_END
2006-06-10 00:40:57 +00:00
} ;
2015-05-14 18:10:35 +00:00
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_generator___construct , 0 )
ZEND_ARG_INFO ( 0 , generator )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO_EX ( arginfo_reflection_generator_trace , 0 , 0 , 0 )
ZEND_ARG_INFO ( 0 , options )
ZEND_END_ARG_INFO ( )
static const zend_function_entry reflection_generator_functions [ ] = {
ZEND_ME ( reflection_generator , __construct , arginfo_reflection_generator___construct , 0 )
ZEND_ME ( reflection_generator , getExecutingLine , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_generator , getExecutingFile , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_generator , getTrace , arginfo_reflection_generator_trace , 0 )
ZEND_ME ( reflection_generator , getFunction , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_generator , getThis , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_generator , getExecutingGenerator , arginfo_reflection__void , 0 )
PHP_FE_END
} ;
2006-06-07 22:39:22 +00:00
ZEND_BEGIN_ARG_INFO_EX ( arginfo_reflection_method_export , 0 , 0 , 2 )
ZEND_ARG_INFO ( 0 , class )
ZEND_ARG_INFO ( 0 , name )
ZEND_ARG_INFO ( 0 , return )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO_EX ( arginfo_reflection_method___construct , 0 , 0 , 1 )
ZEND_ARG_INFO ( 0 , class_or_method )
ZEND_ARG_INFO ( 0 , name )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_method_invoke , 0 )
ZEND_ARG_INFO ( 0 , object )
ZEND_ARG_INFO ( 0 , args )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_method_invokeArgs , 0 )
ZEND_ARG_INFO ( 0 , object )
ZEND_ARG_ARRAY_INFO ( 0 , args , 0 )
ZEND_END_ARG_INFO ( )
2009-09-16 17:24:46 +00:00
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_method_setAccessible , 0 )
ZEND_ARG_INFO ( 0 , value )
ZEND_END_ARG_INFO ( )
2010-04-19 19:45:03 +00:00
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_method_getClosure , 0 )
ZEND_ARG_INFO ( 0 , object )
ZEND_END_ARG_INFO ( )
2007-09-27 18:00:48 +00:00
static const zend_function_entry reflection_method_functions [ ] = {
2006-06-07 22:39:22 +00:00
ZEND_ME ( reflection_method , export , arginfo_reflection_method_export , ZEND_ACC_STATIC | ZEND_ACC_PUBLIC )
ZEND_ME ( reflection_method , __construct , arginfo_reflection_method___construct , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_method , __toString , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_method , isPublic , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_method , isPrivate , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_method , isProtected , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_method , isAbstract , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_method , isFinal , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_method , isStatic , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_method , isConstructor , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_method , isDestructor , arginfo_reflection__void , 0 )
2010-04-19 19:45:03 +00:00
ZEND_ME ( reflection_method , getClosure , arginfo_reflection_method_getClosure , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_method , getModifiers , arginfo_reflection__void , 0 )
2006-06-07 22:39:22 +00:00
ZEND_ME ( reflection_method , invoke , arginfo_reflection_method_invoke , 0 )
ZEND_ME ( reflection_method , invokeArgs , arginfo_reflection_method_invokeArgs , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_method , getDeclaringClass , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_method , getPrototype , arginfo_reflection__void , 0 )
2009-09-16 17:24:46 +00:00
ZEND_ME ( reflection_property , setAccessible , arginfo_reflection_method_setAccessible , 0 )
2011-07-25 11:35:02 +00:00
PHP_FE_END
2005-11-30 21:53:20 +00:00
} ;
2006-06-07 22:39:22 +00:00
ZEND_BEGIN_ARG_INFO_EX ( arginfo_reflection_class_export , 0 , 0 , 1 )
ZEND_ARG_INFO ( 0 , argument )
ZEND_ARG_INFO ( 0 , return )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_class___construct , 0 )
ZEND_ARG_INFO ( 0 , argument )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO_EX ( arginfo_reflection_class_getStaticPropertyValue , 0 , 0 , 1 )
ZEND_ARG_INFO ( 0 , name )
ZEND_ARG_INFO ( 0 , default )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_class_setStaticPropertyValue , 0 )
ZEND_ARG_INFO ( 0 , name )
ZEND_ARG_INFO ( 0 , value )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_class_hasMethod , 0 )
ZEND_ARG_INFO ( 0 , name )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_class_getMethod , 0 )
ZEND_ARG_INFO ( 0 , name )
ZEND_END_ARG_INFO ( )
2006-07-04 15:33:57 +00:00
ZEND_BEGIN_ARG_INFO_EX ( arginfo_reflection_class_getMethods , 0 , 0 , 0 )
2006-09-10 13:25:47 +00:00
ZEND_ARG_INFO ( 0 , filter )
2006-07-04 15:33:57 +00:00
ZEND_END_ARG_INFO ( )
2006-06-07 22:39:22 +00:00
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_class_hasProperty , 0 )
ZEND_ARG_INFO ( 0 , name )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_class_getProperty , 0 )
ZEND_ARG_INFO ( 0 , name )
ZEND_END_ARG_INFO ( )
2006-07-04 15:37:34 +00:00
ZEND_BEGIN_ARG_INFO_EX ( arginfo_reflection_class_getProperties , 0 , 0 , 0 )
2006-07-04 15:33:57 +00:00
ZEND_ARG_INFO ( 0 , filter )
ZEND_END_ARG_INFO ( )
2006-06-07 22:39:22 +00:00
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_class_hasConstant , 0 )
ZEND_ARG_INFO ( 0 , name )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_class_getConstant , 0 )
ZEND_ARG_INFO ( 0 , name )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_class_isInstance , 0 )
2006-06-10 00:40:57 +00:00
ZEND_ARG_INFO ( 0 , object )
2006-06-07 22:39:22 +00:00
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_class_newInstance , 0 )
ZEND_ARG_INFO ( 0 , args )
ZEND_END_ARG_INFO ( )
2011-08-26 07:40:31 +00:00
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_class_newInstanceWithoutConstructor , 0 )
ZEND_END_ARG_INFO ( )
2006-07-04 15:33:57 +00:00
ZEND_BEGIN_ARG_INFO_EX ( arginfo_reflection_class_newInstanceArgs , 0 , 0 , 0 )
2006-06-07 22:39:22 +00:00
ZEND_ARG_ARRAY_INFO ( 0 , args , 0 )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_class_isSubclassOf , 0 )
ZEND_ARG_INFO ( 0 , class )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_class_implementsInterface , 0 )
ZEND_ARG_INFO ( 0 , interface )
ZEND_END_ARG_INFO ( )
2007-09-27 18:00:48 +00:00
static const zend_function_entry reflection_class_functions [ ] = {
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection , __clone , arginfo_reflection__void , ZEND_ACC_PRIVATE | ZEND_ACC_FINAL )
2006-06-07 22:39:22 +00:00
ZEND_ME ( reflection_class , export , arginfo_reflection_class_export , ZEND_ACC_STATIC | ZEND_ACC_PUBLIC )
ZEND_ME ( reflection_class , __construct , arginfo_reflection_class___construct , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_class , __toString , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_class , getName , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_class , isInternal , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_class , isUserDefined , arginfo_reflection__void , 0 )
2015-04-26 13:02:57 +00:00
ZEND_ME ( reflection_class , isAnonymous , arginfo_reflection__void , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_class , isInstantiable , arginfo_reflection__void , 0 )
2010-06-02 15:29:42 +00:00
ZEND_ME ( reflection_class , isCloneable , arginfo_reflection__void , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_class , getFileName , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_class , getStartLine , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_class , getEndLine , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_class , getDocComment , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_class , getConstructor , arginfo_reflection__void , 0 )
2006-06-07 22:39:22 +00:00
ZEND_ME ( reflection_class , hasMethod , arginfo_reflection_class_hasMethod , 0 )
ZEND_ME ( reflection_class , getMethod , arginfo_reflection_class_getMethod , 0 )
2006-07-04 15:33:57 +00:00
ZEND_ME ( reflection_class , getMethods , arginfo_reflection_class_getMethods , 0 )
2006-06-07 22:39:22 +00:00
ZEND_ME ( reflection_class , hasProperty , arginfo_reflection_class_hasProperty , 0 )
ZEND_ME ( reflection_class , getProperty , arginfo_reflection_class_getProperty , 0 )
2006-07-04 15:33:57 +00:00
ZEND_ME ( reflection_class , getProperties , arginfo_reflection_class_getProperties , 0 )
2006-06-07 22:39:22 +00:00
ZEND_ME ( reflection_class , hasConstant , arginfo_reflection_class_hasConstant , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_class , getConstants , arginfo_reflection__void , 0 )
2006-06-07 22:39:22 +00:00
ZEND_ME ( reflection_class , getConstant , arginfo_reflection_class_getConstant , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_class , getInterfaces , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_class , getInterfaceNames , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_class , isInterface , arginfo_reflection__void , 0 )
2010-05-30 01:00:45 +00:00
ZEND_ME ( reflection_class , getTraits , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_class , getTraitNames , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_class , getTraitAliases , arginfo_reflection__void , 0 )
2010-05-29 20:40:58 +00:00
ZEND_ME ( reflection_class , isTrait , arginfo_reflection__void , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_class , isAbstract , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_class , isFinal , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_class , getModifiers , arginfo_reflection__void , 0 )
2006-06-07 22:39:22 +00:00
ZEND_ME ( reflection_class , isInstance , arginfo_reflection_class_isInstance , 0 )
ZEND_ME ( reflection_class , newInstance , arginfo_reflection_class_newInstance , 0 )
2011-08-26 07:40:31 +00:00
ZEND_ME ( reflection_class , newInstanceWithoutConstructor , arginfo_reflection_class_newInstanceWithoutConstructor , 0 )
2006-06-07 22:39:22 +00:00
ZEND_ME ( reflection_class , newInstanceArgs , arginfo_reflection_class_newInstanceArgs , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_class , getParentClass , arginfo_reflection__void , 0 )
2006-06-07 22:39:22 +00:00
ZEND_ME ( reflection_class , isSubclassOf , arginfo_reflection_class_isSubclassOf , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_class , getStaticProperties , arginfo_reflection__void , 0 )
2006-06-07 22:39:22 +00:00
ZEND_ME ( reflection_class , getStaticPropertyValue , arginfo_reflection_class_getStaticPropertyValue , 0 )
ZEND_ME ( reflection_class , setStaticPropertyValue , arginfo_reflection_class_setStaticPropertyValue , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_class , getDefaultProperties , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_class , isIterateable , arginfo_reflection__void , 0 )
2006-06-07 22:39:22 +00:00
ZEND_ME ( reflection_class , implementsInterface , arginfo_reflection_class_implementsInterface , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_class , getExtension , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_class , getExtensionName , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_class , inNamespace , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_class , getNamespaceName , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_class , getShortName , arginfo_reflection__void , 0 )
2011-07-25 11:35:02 +00:00
PHP_FE_END
2005-11-30 21:53:20 +00:00
} ;
2006-06-07 22:39:22 +00:00
ZEND_BEGIN_ARG_INFO_EX ( arginfo_reflection_object_export , 0 , 0 , 1 )
ZEND_ARG_INFO ( 0 , argument )
ZEND_ARG_INFO ( 0 , return )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_object___construct , 0 )
ZEND_ARG_INFO ( 0 , argument )
ZEND_END_ARG_INFO ( )
2007-09-27 18:00:48 +00:00
static const zend_function_entry reflection_object_functions [ ] = {
2006-06-07 22:39:22 +00:00
ZEND_ME ( reflection_object , export , arginfo_reflection_object_export , ZEND_ACC_STATIC | ZEND_ACC_PUBLIC )
ZEND_ME ( reflection_object , __construct , arginfo_reflection_object___construct , 0 )
2011-07-25 11:35:02 +00:00
PHP_FE_END
2005-11-30 21:53:20 +00:00
} ;
2006-06-07 22:39:22 +00:00
2009-10-03 20:45:29 +00:00
ZEND_BEGIN_ARG_INFO_EX ( arginfo_reflection_property_export , 0 , 0 , 2 )
ZEND_ARG_INFO ( 0 , class )
ZEND_ARG_INFO ( 0 , name )
2006-06-07 22:39:22 +00:00
ZEND_ARG_INFO ( 0 , return )
ZEND_END_ARG_INFO ( )
2010-03-02 22:16:24 +00:00
ZEND_BEGIN_ARG_INFO_EX ( arginfo_reflection_property___construct , 0 , 0 , 2 )
2009-10-03 20:45:29 +00:00
ZEND_ARG_INFO ( 0 , class )
ZEND_ARG_INFO ( 0 , name )
2006-06-07 22:39:22 +00:00
ZEND_END_ARG_INFO ( )
2007-08-17 14:21:32 +00:00
ZEND_BEGIN_ARG_INFO_EX ( arginfo_reflection_property_getValue , 0 , 0 , 0 )
2006-06-10 00:40:57 +00:00
ZEND_ARG_INFO ( 0 , object )
2006-06-07 22:39:22 +00:00
ZEND_END_ARG_INFO ( )
2009-10-03 20:45:29 +00:00
ZEND_BEGIN_ARG_INFO_EX ( arginfo_reflection_property_setValue , 0 , 0 , 1 )
2006-06-10 00:40:57 +00:00
ZEND_ARG_INFO ( 0 , object )
2006-06-07 22:39:22 +00:00
ZEND_ARG_INFO ( 0 , value )
ZEND_END_ARG_INFO ( )
2008-02-15 12:48:13 +00:00
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_property_setAccessible , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ARG_INFO ( 0 , visible )
2008-02-15 12:38:53 +00:00
ZEND_END_ARG_INFO ( )
2007-09-27 18:00:48 +00:00
static const zend_function_entry reflection_property_functions [ ] = {
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection , __clone , arginfo_reflection__void , ZEND_ACC_PRIVATE | ZEND_ACC_FINAL )
2006-06-07 22:39:22 +00:00
ZEND_ME ( reflection_property , export , arginfo_reflection_property_export , ZEND_ACC_STATIC | ZEND_ACC_PUBLIC )
ZEND_ME ( reflection_property , __construct , arginfo_reflection_property___construct , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_property , __toString , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_property , getName , arginfo_reflection__void , 0 )
2006-06-07 22:39:22 +00:00
ZEND_ME ( reflection_property , getValue , arginfo_reflection_property_getValue , 0 )
ZEND_ME ( reflection_property , setValue , arginfo_reflection_property_setValue , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_property , isPublic , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_property , isPrivate , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_property , isProtected , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_property , isStatic , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_property , isDefault , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_property , getModifiers , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_property , getDeclaringClass , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_property , getDocComment , arginfo_reflection__void , 0 )
2008-02-15 12:48:13 +00:00
ZEND_ME ( reflection_property , setAccessible , arginfo_reflection_property_setAccessible , 0 )
2011-07-25 11:35:02 +00:00
PHP_FE_END
2005-11-30 21:53:20 +00:00
} ;
2006-06-07 22:39:22 +00:00
ZEND_BEGIN_ARG_INFO_EX ( arginfo_reflection_parameter_export , 0 , 0 , 2 )
ZEND_ARG_INFO ( 0 , function )
ZEND_ARG_INFO ( 0 , parameter )
ZEND_ARG_INFO ( 0 , return )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_parameter___construct , 0 )
ZEND_ARG_INFO ( 0 , function )
ZEND_ARG_INFO ( 0 , parameter )
ZEND_END_ARG_INFO ( )
2007-09-27 18:00:48 +00:00
static const zend_function_entry reflection_parameter_functions [ ] = {
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection , __clone , arginfo_reflection__void , ZEND_ACC_PRIVATE | ZEND_ACC_FINAL )
2006-06-07 22:39:22 +00:00
ZEND_ME ( reflection_parameter , export , arginfo_reflection_parameter_export , ZEND_ACC_STATIC | ZEND_ACC_PUBLIC )
ZEND_ME ( reflection_parameter , __construct , arginfo_reflection_parameter___construct , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_parameter , __toString , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_parameter , getName , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_parameter , isPassedByReference , arginfo_reflection__void , 0 )
2010-10-26 15:01:36 +00:00
ZEND_ME ( reflection_parameter , canBePassedByValue , arginfo_reflection__void , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_parameter , getDeclaringFunction , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_parameter , getDeclaringClass , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_parameter , getClass , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_parameter , isArray , arginfo_reflection__void , 0 )
2011-08-16 10:44:47 +00:00
ZEND_ME ( reflection_parameter , isCallable , arginfo_reflection__void , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_parameter , allowsNull , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_parameter , getPosition , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_parameter , isOptional , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_parameter , isDefaultValueAvailable , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_parameter , getDefaultValue , arginfo_reflection__void , 0 )
2015-02-10 21:17:43 +00:00
ZEND_ME ( reflection_parameter , isDefaultValueConstant , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_parameter , getDefaultValueConstantName , arginfo_reflection__void , 0 )
2013-09-26 16:39:17 +00:00
ZEND_ME ( reflection_parameter , isVariadic , arginfo_reflection__void , 0 )
2011-07-25 11:35:02 +00:00
PHP_FE_END
2005-11-30 21:53:20 +00:00
} ;
2006-06-07 22:39:22 +00:00
ZEND_BEGIN_ARG_INFO_EX ( arginfo_reflection_extension_export , 0 , 0 , 1 )
ZEND_ARG_INFO ( 0 , name )
ZEND_ARG_INFO ( 0 , return )
ZEND_END_ARG_INFO ( )
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_extension___construct , 0 )
ZEND_ARG_INFO ( 0 , name )
ZEND_END_ARG_INFO ( )
2007-09-27 18:00:48 +00:00
static const zend_function_entry reflection_extension_functions [ ] = {
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection , __clone , arginfo_reflection__void , ZEND_ACC_PRIVATE | ZEND_ACC_FINAL )
2006-06-07 22:39:22 +00:00
ZEND_ME ( reflection_extension , export , arginfo_reflection_extension_export , ZEND_ACC_STATIC | ZEND_ACC_PUBLIC )
ZEND_ME ( reflection_extension , __construct , arginfo_reflection_extension___construct , 0 )
2009-10-03 20:45:29 +00:00
ZEND_ME ( reflection_extension , __toString , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_extension , getName , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_extension , getVersion , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_extension , getFunctions , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_extension , getConstants , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_extension , getINIEntries , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_extension , getClasses , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_extension , getClassNames , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_extension , getDependencies , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_extension , info , arginfo_reflection__void , 0 )
2010-03-30 20:50:42 +00:00
ZEND_ME ( reflection_extension , isPersistent , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_extension , isTemporary , arginfo_reflection__void , 0 )
2011-07-25 11:35:02 +00:00
PHP_FE_END
2005-11-30 21:53:20 +00:00
} ;
2010-03-30 22:35:23 +00:00
ZEND_BEGIN_ARG_INFO ( arginfo_reflection_zend_extension___construct , 0 )
ZEND_ARG_INFO ( 0 , name )
ZEND_END_ARG_INFO ( )
static const zend_function_entry reflection_zend_extension_functions [ ] = {
ZEND_ME ( reflection , __clone , arginfo_reflection__void , ZEND_ACC_PRIVATE | ZEND_ACC_FINAL )
ZEND_ME ( reflection_zend_extension , export , arginfo_reflection_extension_export , ZEND_ACC_STATIC | ZEND_ACC_PUBLIC )
2014-10-04 17:59:21 +00:00
ZEND_ME ( reflection_zend_extension , __construct , arginfo_reflection_zend_extension___construct , 0 )
2010-03-30 22:35:23 +00:00
ZEND_ME ( reflection_zend_extension , __toString , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_zend_extension , getName , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_zend_extension , getVersion , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_zend_extension , getAuthor , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_zend_extension , getURL , arginfo_reflection__void , 0 )
ZEND_ME ( reflection_zend_extension , getCopyright , arginfo_reflection__void , 0 )
2011-07-25 11:35:02 +00:00
PHP_FE_END
2010-03-30 22:35:23 +00:00
} ;
2005-11-30 21:53:20 +00:00
/* }}} */
2007-09-27 18:00:48 +00:00
const zend_function_entry reflection_ext_functions [ ] = { /* {{{ */
2011-07-25 11:35:02 +00:00
PHP_FE_END
2005-11-30 21:53:20 +00:00
} ; /* }}} */
static zend_object_handlers * zend_std_obj_handlers ;
/* {{{ _reflection_write_property */
2014-12-13 22:06:14 +00:00
static void _reflection_write_property ( zval * object , zval * member , zval * value , void * * cache_slot )
2005-11-30 21:53:20 +00:00
{
if ( ( Z_TYPE_P ( member ) = = IS_STRING )
2014-02-10 06:04:30 +00:00
& & zend_hash_exists ( & Z_OBJCE_P ( object ) - > properties_info , Z_STR_P ( member ) )
2014-08-25 17:24:55 +00:00
& & ( ( Z_STRLEN_P ( member ) = = sizeof ( " name " ) - 1 & & ! memcmp ( Z_STRVAL_P ( member ) , " name " , sizeof ( " name " ) ) )
| | ( Z_STRLEN_P ( member ) = = sizeof ( " class " ) - 1 & & ! memcmp ( Z_STRVAL_P ( member ) , " class " , sizeof ( " class " ) ) ) ) )
2005-11-30 21:53:20 +00:00
{
2014-12-13 22:06:14 +00:00
zend_throw_exception_ex ( reflection_exception_ptr , 0 ,
2014-02-25 22:02:57 +00:00
" Cannot set read-only property %s::$%s " , Z_OBJCE_P ( object ) - > name - > val , Z_STRVAL_P ( member ) ) ;
2005-11-30 21:53:20 +00:00
}
else
{
2014-12-13 22:06:14 +00:00
zend_std_obj_handlers - > write_property ( object , member , value , cache_slot ) ;
2005-11-30 21:53:20 +00:00
}
}
/* }}} */
PHP_MINIT_FUNCTION ( reflection ) /* {{{ */
{
zend_class_entry _reflection_entry ;
zend_std_obj_handlers = zend_get_std_object_handlers ( ) ;
memcpy ( & reflection_object_handlers , zend_get_std_object_handlers ( ) , sizeof ( zend_object_handlers ) ) ;
2014-04-08 21:50:15 +00:00
reflection_object_handlers . offset = XtOffsetOf ( reflection_object , zo ) ;
2014-02-10 06:04:30 +00:00
reflection_object_handlers . free_obj = reflection_free_objects_storage ;
2005-11-30 21:53:20 +00:00
reflection_object_handlers . clone_obj = NULL ;
reflection_object_handlers . write_property = _reflection_write_property ;
INIT_CLASS_ENTRY ( _reflection_entry , " ReflectionException " , reflection_exception_functions ) ;
2014-12-13 22:06:14 +00:00
reflection_exception_ptr = zend_register_internal_class_ex ( & _reflection_entry , zend_exception_get_default ( ) ) ;
2005-11-30 21:53:20 +00:00
INIT_CLASS_ENTRY ( _reflection_entry , " Reflection " , reflection_functions ) ;
2014-12-13 22:06:14 +00:00
reflection_ptr = zend_register_internal_class ( & _reflection_entry ) ;
2005-11-30 21:53:20 +00:00
INIT_CLASS_ENTRY ( _reflection_entry , " Reflector " , reflector_functions ) ;
2014-12-13 22:06:14 +00:00
reflector_ptr = zend_register_internal_interface ( & _reflection_entry ) ;
2005-11-30 21:53:20 +00:00
2006-06-10 00:40:57 +00:00
INIT_CLASS_ENTRY ( _reflection_entry , " ReflectionFunctionAbstract " , reflection_function_abstract_functions ) ;
_reflection_entry . create_object = reflection_objects_new ;
2014-12-13 22:06:14 +00:00
reflection_function_abstract_ptr = zend_register_internal_class ( & _reflection_entry ) ;
zend_class_implements ( reflection_function_abstract_ptr , 1 , reflector_ptr ) ;
zend_declare_property_string ( reflection_function_abstract_ptr , " name " , sizeof ( " name " ) - 1 , " " , ZEND_ACC_ABSTRACT ) ;
2008-08-11 19:35:00 +00:00
2005-11-30 21:53:20 +00:00
INIT_CLASS_ENTRY ( _reflection_entry , " ReflectionFunction " , reflection_function_functions ) ;
_reflection_entry . create_object = reflection_objects_new ;
2014-12-13 22:06:14 +00:00
reflection_function_ptr = zend_register_internal_class_ex ( & _reflection_entry , reflection_function_abstract_ptr ) ;
zend_declare_property_string ( reflection_function_ptr , " name " , sizeof ( " name " ) - 1 , " " , ZEND_ACC_PUBLIC ) ;
2005-11-30 21:53:20 +00:00
2014-08-25 17:24:55 +00:00
REGISTER_REFLECTION_CLASS_CONST_LONG ( function , " IS_DEPRECATED " , ZEND_ACC_DEPRECATED ) ;
2006-02-25 18:25:45 +00:00
2015-05-14 18:10:35 +00:00
INIT_CLASS_ENTRY ( _reflection_entry , " ReflectionGenerator " , reflection_generator_functions ) ;
_reflection_entry . create_object = reflection_objects_new ;
reflection_generator_ptr = zend_register_internal_class ( & _reflection_entry ) ;
2005-11-30 21:53:20 +00:00
INIT_CLASS_ENTRY ( _reflection_entry , " ReflectionParameter " , reflection_parameter_functions ) ;
_reflection_entry . create_object = reflection_objects_new ;
2014-12-13 22:06:14 +00:00
reflection_parameter_ptr = zend_register_internal_class ( & _reflection_entry ) ;
zend_class_implements ( reflection_parameter_ptr , 1 , reflector_ptr ) ;
zend_declare_property_string ( reflection_parameter_ptr , " name " , sizeof ( " name " ) - 1 , " " , ZEND_ACC_PUBLIC ) ;
2005-11-30 21:53:20 +00:00
INIT_CLASS_ENTRY ( _reflection_entry , " ReflectionMethod " , reflection_method_functions ) ;
_reflection_entry . create_object = reflection_objects_new ;
2014-12-13 22:06:14 +00:00
reflection_method_ptr = zend_register_internal_class_ex ( & _reflection_entry , reflection_function_abstract_ptr ) ;
zend_declare_property_string ( reflection_method_ptr , " name " , sizeof ( " name " ) - 1 , " " , ZEND_ACC_PUBLIC ) ;
zend_declare_property_string ( reflection_method_ptr , " class " , sizeof ( " class " ) - 1 , " " , ZEND_ACC_PUBLIC ) ;
2005-11-30 21:53:20 +00:00
2014-08-25 17:24:55 +00:00
REGISTER_REFLECTION_CLASS_CONST_LONG ( method , " IS_STATIC " , ZEND_ACC_STATIC ) ;
REGISTER_REFLECTION_CLASS_CONST_LONG ( method , " IS_PUBLIC " , ZEND_ACC_PUBLIC ) ;
REGISTER_REFLECTION_CLASS_CONST_LONG ( method , " IS_PROTECTED " , ZEND_ACC_PROTECTED ) ;
REGISTER_REFLECTION_CLASS_CONST_LONG ( method , " IS_PRIVATE " , ZEND_ACC_PRIVATE ) ;
REGISTER_REFLECTION_CLASS_CONST_LONG ( method , " IS_ABSTRACT " , ZEND_ACC_ABSTRACT ) ;
REGISTER_REFLECTION_CLASS_CONST_LONG ( method , " IS_FINAL " , ZEND_ACC_FINAL ) ;
2005-11-30 21:53:20 +00:00
INIT_CLASS_ENTRY ( _reflection_entry , " ReflectionClass " , reflection_class_functions ) ;
_reflection_entry . create_object = reflection_objects_new ;
2014-12-13 22:06:14 +00:00
reflection_class_ptr = zend_register_internal_class ( & _reflection_entry ) ;
zend_class_implements ( reflection_class_ptr , 1 , reflector_ptr ) ;
zend_declare_property_string ( reflection_class_ptr , " name " , sizeof ( " name " ) - 1 , " " , ZEND_ACC_PUBLIC ) ;
2005-11-30 21:53:20 +00:00
2014-08-25 17:24:55 +00:00
REGISTER_REFLECTION_CLASS_CONST_LONG ( class , " IS_IMPLICIT_ABSTRACT " , ZEND_ACC_IMPLICIT_ABSTRACT_CLASS ) ;
REGISTER_REFLECTION_CLASS_CONST_LONG ( class , " IS_EXPLICIT_ABSTRACT " , ZEND_ACC_EXPLICIT_ABSTRACT_CLASS ) ;
2014-11-22 04:57:55 +00:00
REGISTER_REFLECTION_CLASS_CONST_LONG ( class , " IS_FINAL " , ZEND_ACC_FINAL ) ;
2005-11-30 21:53:20 +00:00
INIT_CLASS_ENTRY ( _reflection_entry , " ReflectionObject " , reflection_object_functions ) ;
_reflection_entry . create_object = reflection_objects_new ;
2014-12-13 22:06:14 +00:00
reflection_object_ptr = zend_register_internal_class_ex ( & _reflection_entry , reflection_class_ptr ) ;
2005-11-30 21:53:20 +00:00
INIT_CLASS_ENTRY ( _reflection_entry , " ReflectionProperty " , reflection_property_functions ) ;
_reflection_entry . create_object = reflection_objects_new ;
2014-12-13 22:06:14 +00:00
reflection_property_ptr = zend_register_internal_class ( & _reflection_entry ) ;
zend_class_implements ( reflection_property_ptr , 1 , reflector_ptr ) ;
zend_declare_property_string ( reflection_property_ptr , " name " , sizeof ( " name " ) - 1 , " " , ZEND_ACC_PUBLIC ) ;
zend_declare_property_string ( reflection_property_ptr , " class " , sizeof ( " class " ) - 1 , " " , ZEND_ACC_PUBLIC ) ;
2005-11-30 21:53:20 +00:00
2014-08-25 17:24:55 +00:00
REGISTER_REFLECTION_CLASS_CONST_LONG ( property , " IS_STATIC " , ZEND_ACC_STATIC ) ;
REGISTER_REFLECTION_CLASS_CONST_LONG ( property , " IS_PUBLIC " , ZEND_ACC_PUBLIC ) ;
REGISTER_REFLECTION_CLASS_CONST_LONG ( property , " IS_PROTECTED " , ZEND_ACC_PROTECTED ) ;
REGISTER_REFLECTION_CLASS_CONST_LONG ( property , " IS_PRIVATE " , ZEND_ACC_PRIVATE ) ;
2005-11-30 21:53:20 +00:00
INIT_CLASS_ENTRY ( _reflection_entry , " ReflectionExtension " , reflection_extension_functions ) ;
_reflection_entry . create_object = reflection_objects_new ;
2014-12-13 22:06:14 +00:00
reflection_extension_ptr = zend_register_internal_class ( & _reflection_entry ) ;
zend_class_implements ( reflection_extension_ptr , 1 , reflector_ptr ) ;
zend_declare_property_string ( reflection_extension_ptr , " name " , sizeof ( " name " ) - 1 , " " , ZEND_ACC_PUBLIC ) ;
2005-11-30 21:53:20 +00:00
2010-03-30 22:35:23 +00:00
INIT_CLASS_ENTRY ( _reflection_entry , " ReflectionZendExtension " , reflection_zend_extension_functions ) ;
_reflection_entry . create_object = reflection_objects_new ;
2014-12-13 22:06:14 +00:00
reflection_zend_extension_ptr = zend_register_internal_class ( & _reflection_entry ) ;
zend_class_implements ( reflection_zend_extension_ptr , 1 , reflector_ptr ) ;
zend_declare_property_string ( reflection_zend_extension_ptr , " name " , sizeof ( " name " ) - 1 , " " , ZEND_ACC_PUBLIC ) ;
2010-03-30 22:35:23 +00:00
2005-11-30 21:53:20 +00:00
return SUCCESS ;
} /* }}} */
PHP_MINFO_FUNCTION ( reflection ) /* {{{ */
{
php_info_print_table_start ( ) ;
php_info_print_table_header ( 2 , " Reflection " , " enabled " ) ;
2012-03-20 16:53:47 +00:00
php_info_print_table_row ( 2 , " Version " , " $Id$ " ) ;
2005-11-30 21:53:20 +00:00
php_info_print_table_end ( ) ;
} /* }}} */
zend_module_entry reflection_module_entry = { /* {{{ */
STANDARD_MODULE_HEADER ,
" Reflection " ,
reflection_ext_functions ,
PHP_MINIT ( reflection ) ,
NULL ,
NULL ,
NULL ,
PHP_MINFO ( reflection ) ,
2015-03-23 20:30:22 +00:00
PHP_REFLECTION_VERSION ,
2005-11-30 21:53:20 +00:00
STANDARD_MODULE_PROPERTIES
} ; /* }}} */
/*
* Local variables :
* tab - width : 4
* c - basic - offset : 4
* indent - tabs - mode : t
* End :
2006-06-10 00:40:57 +00:00
* vim600 : noet sw = 4 ts = 4 fdm = marker
2005-11-30 21:53:20 +00:00
*/