[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c
kalleFri, 19 Nov 2010 15:48:11 + Revision: http://svn.php.net/viewvc?view=revisionrevision=305559 Log: Kill warnings about constness Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-11-19 14:46:56 UTC (rev 305558) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-11-19 15:48:11 UTC (rev 305559) @@ -3065,7 +3065,7 @@ ZEND_METHOD(reflection_function, inNamespace) { zval **name; - char *colon; + const char *backslash; if (zend_parse_parameters_none() == FAILURE) { return; @@ -3074,8 +3074,8 @@ RETURN_FALSE; } if (Z_TYPE_PP(name) == IS_STRING -(colon = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name))) -colon Z_STRVAL_PP(name)) +(backslash = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name))) +backslash Z_STRVAL_PP(name)) { RETURN_TRUE; } @@ -3088,7 +3088,7 @@ ZEND_METHOD(reflection_function, getNamespaceName) { zval **name; - char *backslash; + const char *backslash; if (zend_parse_parameters_none() == FAILURE) { return; @@ -3111,7 +3111,7 @@ ZEND_METHOD(reflection_function, getShortName) { zval **name; - char *backslash; + const char *backslash; if (zend_parse_parameters_none() == FAILURE) { return; @@ -4599,7 +4599,7 @@ ZEND_METHOD(reflection_class, inNamespace) { zval **name; - char *colon; + const char *backslash; if (zend_parse_parameters_none() == FAILURE) { return; @@ -4608,8 +4608,8 @@ RETURN_FALSE; } if (Z_TYPE_PP(name) == IS_STRING -(colon = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name))) -colon Z_STRVAL_PP(name)) +(backslash = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name))) +backslash Z_STRVAL_PP(name)) { RETURN_TRUE; } @@ -4622,7 +4622,7 @@ ZEND_METHOD(reflection_class, getNamespaceName) { zval **name; - char *backslash; + const char *backslash; if (zend_parse_parameters_none() == FAILURE) { return; @@ -4645,7 +4645,7 @@ ZEND_METHOD(reflection_class, getShortName) { zval **name; - char *backslash; + const char *backslash; if (zend_parse_parameters_none() == FAILURE) { return; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c
felipe Mon, 02 Aug 2010 01:35:02 + Revision: http://svn.php.net/viewvc?view=revisionrevision=301776 Log: - Added missing parameter checks for new methods (trunk only) Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-08-02 00:15:55 UTC (rev 301775) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-08-02 01:35:02 UTC (rev 301776) @@ -2378,6 +2378,9 @@ 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_LONG); @@ -2391,6 +2394,9 @@ 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_DOUBLE); @@ -2404,6 +2410,9 @@ 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_BOOL); @@ -2417,6 +2426,9 @@ 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_OBJECT); @@ -2430,6 +2442,9 @@ 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_STRING); @@ -2443,6 +2458,9 @@ 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_RESOURCE); @@ -2456,6 +2474,9 @@ reflection_object *intern; parameter_reference *param; + if (zend_parse_parameters_none() == FAILURE) { + return; + } GET_REFLECTION_OBJECT_PTR(param); if (!param-arg_info-type_hint) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c
felipe Thu, 29 Jul 2010 01:59:40 + Revision: http://svn.php.net/viewvc?view=revisionrevision=301671 Log: - Makes parent and self checking case-insensitive Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-07-28 21:34:02 UTC (rev 301670) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-07-29 01:59:40 UTC (rev 301671) @@ -2324,7 +2324,7 @@ * TODO: Think about moving these checks to the compiler or some sort of * lint-mode. */ - if (0 == strncmp(param-arg_info-class_name, self, sizeof(self)- 1)) { + if (0 == zend_binary_strcasecmp(param-arg_info-class_name, param-arg_info-class_name_len, self, sizeof(self)- 1)) { ce = param-fptr-common.scope; if (!ce) { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, @@ -2332,7 +2332,7 @@ return; } pce= ce; - } else if (0 == strncmp(param-arg_info-class_name, parent, sizeof(parent)- 1)) { + } else if (0 == zend_binary_strcasecmp(param-arg_info-class_name, param-arg_info-class_name_len, parent, sizeof(parent)- 1)) { ce = param-fptr-common.scope; if (!ce) { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c
felipe Wed, 02 Jun 2010 17:07:01 + Revision: http://svn.php.net/viewvc?view=revisionrevision=300098 Log: - Save an object_init_ex() and zval_dtor() calls on ReflectionClass::isCloneable() Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-06-02 16:54:13 UTC (rev 300097) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-06-02 17:07:01 UTC (rev 300098) @@ -4009,13 +4009,13 @@ RETURN_BOOL(Z_OBJ_HANDLER_P(intern-obj, clone_obj) != NULL); } } else { - object_init_ex(obj, ce); if (ce-clone) { - RETVAL_BOOL(ce-clone-common.fn_flags ZEND_ACC_PUBLIC); + RETURN_BOOL(ce-clone-common.fn_flags ZEND_ACC_PUBLIC); } else { + object_init_ex(obj, ce); RETVAL_BOOL(Z_OBJ_HANDLER(obj, clone_obj) != NULL); - } - zval_dtor(obj); + zval_dtor(obj); + } } } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c
felipe Thu, 03 Jun 2010 00:14:35 + Revision: http://svn.php.net/viewvc?view=revisionrevision=300123 Log: - Fix memleak when passing a non string/object parameter Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-06-03 00:13:27 UTC (rev 300122) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-06-03 00:14:35 UTC (rev 300123) @@ -3217,7 +3217,7 @@ return; } } else { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, z, argument) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, z/, argument) == FAILURE) { return; } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c tests/ReflectionClass_toString_001.phpt tests/traits001.phpt
johannes Sat, 29 May 2010 20:40:58 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299938 Log: - Make reflection aware of traits Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c U php/php-src/trunk/ext/reflection/tests/ReflectionClass_toString_001.phpt A php/php-src/trunk/ext/reflection/tests/traits001.phpt Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-29 20:34:25 UTC (rev 299937) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-29 20:40:58 UTC (rev 299938) @@ -355,7 +355,13 @@ if (obj) { string_printf(str, %sObject of class [ , indent); } else { - string_printf(str, %s%s [ , indent, (ce-ce_flags ZEND_ACC_INTERFACE) ? Interface : Class); + char *kind = Class; + if (ce-ce_flags ZEND_ACC_INTERFACE) { + kind = Interface; + } else if (ce-ce_flags ZEND_ACC_TRAIT) { + kind = Trait; + } + string_printf(str, %s%s [ , indent, kind); } string_printf(str, (ce-type == ZEND_USER_CLASS) ? user : internal); if (ce-module) { @@ -367,6 +373,8 @@ } if (ce-ce_flags ZEND_ACC_INTERFACE) { string_printf(str, interface ); + } else if (ce-ce_flags ZEND_ACC_TRAIT) { + string_printf(str, trait ); } else { if (ce-ce_flags (ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) { string_printf(str, abstract ); @@ -3974,6 +3982,14 @@ } /* }}} */ +/* {{{ proto public bool ReflectionClass::isTrait() + Returns whether this is a trait */ +ZEND_METHOD(reflection_class, isTrait) +{ + _class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_TRAIT); +} +/* }}} */ + /* {{{ proto public bool ReflectionClass::isFinal() Returns whether this class is final */ ZEND_METHOD(reflection_class, isFinal) @@ -5605,6 +5621,7 @@ 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) + ZEND_ME(reflection_class, isTrait, arginfo_reflection__void, 0) 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) Modified: php/php-src/trunk/ext/reflection/tests/ReflectionClass_toString_001.phpt === --- php/php-src/trunk/ext/reflection/tests/ReflectionClass_toString_001.phpt 2010-05-29 20:34:25 UTC (rev 299937) +++ php/php-src/trunk/ext/reflection/tests/ReflectionClass_toString_001.phpt 2010-05-29 20:40:58 UTC (rev 299938) @@ -34,7 +34,7 @@ Property [ default public $name ] } - - Methods [43] { + - Methods [44] { Method [ internal:Reflection final private method __clone ] { - Parameters [0] { @@ -188,6 +188,12 @@ } } +Method [ internal:Reflection public method isTrait ] { + + - Parameters [0] { + } +} + Method [ internal:Reflection public method isAbstract ] { - Parameters [0] { Added: php/php-src/trunk/ext/reflection/tests/traits001.phpt === --- php/php-src/trunk/ext/reflection/tests/traits001.phpt (rev 0) +++ php/php-src/trunk/ext/reflection/tests/traits001.phpt 2010-05-29 20:40:58 UTC (rev 299938) @@ -0,0 +1,71 @@ +--TEST-- +ReflectionClass and Traits +--FILE-- +?php +trait Foo { +public function someMethod() { } +} + +class Bar { +use Foo; + +public function someOtherMethod() { } +} + +$rFoo = new ReflectionClass('Foo'); +$rBar = new ReflectionClass('Bar'); + +var_dump($rFoo-isTrait()); +var_dump($rBar-isTrait()); +echo $rFoo; +echo $rBar; +--EXPECTF-- +bool(true) +bool(false) +Trait [ user trait Foo ] { + @@ %straits001.php 2-4 + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [1] { +Method [ user public method someMethod ] { + @@ %straits001.php 3 - 3 +} + } +} +Class [ user class Bar ] { + @@ %straits001.php 6-10 + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [2] { +Method [ user public method someOtherMethod ] { + @@ %straits001.php 9 - 9 +} + + +Method [ user public method someMethod ] { + @@ %straits001.php 3 - 3 +} + } +} Property changes on:
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c
johannes Sat, 29 May 2010 21:28:24 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299939 Log: - Add some folding marks Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-29 20:40:58 UTC (rev 299938) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-29 21:28:24 UTC (rev 299939) @@ -178,6 +178,8 @@ } /* }}} */ +/* {{{ Object structure */ + /* Struct for properties */ typedef struct _property_reference { zend_class_entry *ce; @@ -209,9 +211,11 @@ unsigned int ignore_visibility:1; } reflection_object; +/* }}} */ + static zend_object_handlers reflection_object_handlers; -static void _default_get_entry(zval *object, char *name, int name_len, zval *return_value TSRMLS_DC) +static void _default_get_entry(zval *object, char *name, int name_len, zval *return_value TSRMLS_DC) /* {{{ */ { zval **value; @@ -221,6 +225,7 @@ MAKE_COPY_ZVAL(value, return_value); } +/* }}} */ #ifdef ilia_0 static void _default_lookup_entry(zval *object, char *name, int name_len, zval **return_value TSRMLS_DC) /* {{{ */ @@ -236,13 +241,14 @@ /* }}} */ #endif -static void reflection_register_implement(zend_class_entry *class_entry, zend_class_entry *interface_entry TSRMLS_DC) +static void reflection_register_implement(zend_class_entry *class_entry, zend_class_entry *interface_entry TSRMLS_DC) /* {{{ */ { zend_uint num_interfaces = ++class_entry-num_interfaces; class_entry-interfaces = (zend_class_entry **) realloc(class_entry-interfaces, sizeof(zend_class_entry *) * num_interfaces); class_entry-interfaces[num_interfaces - 1] = interface_entry; } +/* }}} */ static zend_function *_copy_function(zend_function *fptr TSRMLS_DC) /* {{{ */ { @@ -274,7 +280,7 @@ } /* }}} */ -static void reflection_free_objects_storage(void *object TSRMLS_DC) +static void reflection_free_objects_storage(void *object TSRMLS_DC) /* {{{ */ { reflection_object *intern = (reflection_object *) object; parameter_reference *reference; @@ -302,8 +308,9 @@ } zend_objects_free_object_storage(object TSRMLS_CC); } +/* }}} */ -static zend_object_value reflection_objects_new(zend_class_entry *class_type TSRMLS_DC) +static zend_object_value reflection_objects_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ { zend_object_value retval; reflection_object *intern; @@ -317,8 +324,9 @@ retval.handlers = reflection_object_handlers; return retval; } +/* }}} */ -static zval * reflection_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC) +static zval * reflection_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC) /* {{{ */ { if (!object) { ALLOC_ZVAL(object); @@ -329,6 +337,7 @@ Z_SET_ISREF_P(object); return object; } +/* }}} */ static void _const_string(string *str, char *name, zval *value, char *indent TSRMLS_DC); static void _function_string(string *str, zend_function *fptr, zend_class_entry *scope, char* indent TSRMLS_DC); @@ -945,7 +954,7 @@ } /* }}} */ -static int _extension_ini_string(zend_ini_entry *ini_entry TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int _extension_ini_string(zend_ini_entry *ini_entry TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { string *str = va_arg(args, string *); char *indent = va_arg(args, char *); @@ -979,8 +988,9 @@ } return ZEND_HASH_APPLY_KEEP; } +/* }}} */ -static int _extension_class_string(zend_class_entry **pce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int _extension_class_string(zend_class_entry **pce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { string *str = va_arg(args, string *); char *indent = va_arg(args, char *); @@ -994,8 +1004,9 @@ } return ZEND_HASH_APPLY_KEEP; } +/* }}} */ -static int _extension_const_string(zend_constant *constant TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int _extension_const_string(zend_constant *constant TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { string *str = va_arg(args, string *); char *indent = va_arg(args, char *); @@ -1008,6 +1019,7 @@ } return ZEND_HASH_APPLY_KEEP; } +/* }}} */ /* {{{ _extension_string */ static void _extension_string(string *str, zend_module_entry *module, char *indent TSRMLS_DC) @@ -1126,7 +1138,7 @@ } /* }}} */ -static void _zend_extension_string(string *str, zend_extension *extension, char *indent TSRMLS_DC) +static void _zend_extension_string(string *str, zend_extension *extension, char
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c tests/traits002.phpt
felipe Sat, 29 May 2010 21:48:56 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299940 Log: - Fixed wrong abstract class identification (it was identified as a Trait) Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c A php/php-src/trunk/ext/reflection/tests/traits002.phpt Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-29 21:28:24 UTC (rev 299939) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-29 21:48:56 UTC (rev 299940) @@ -367,7 +367,7 @@ char *kind = Class; if (ce-ce_flags ZEND_ACC_INTERFACE) { kind = Interface; - } else if (ce-ce_flags ZEND_ACC_TRAIT) { + } else if ((ce-ce_flags ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) { kind = Trait; } string_printf(str, %s%s [ , indent, kind); Added: php/php-src/trunk/ext/reflection/tests/traits002.phpt === --- php/php-src/trunk/ext/reflection/tests/traits002.phpt (rev 0) +++ php/php-src/trunk/ext/reflection/tests/traits002.phpt 2010-05-29 21:48:56 UTC (rev 299940) @@ -0,0 +1,54 @@ +--TEST-- +ReflectionClass and Traits +--FILE-- +?php + +abstract class foo { +} + +trait bar { + +} + +reflectionclass::export('foo'); +reflectionclass::export('bar'); + +? +--EXPECTF-- +Class [ user trait foo ] { + @@ %s 3-4 + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [0] { + } +} + +Trait [ user trait bar ] { + @@ %s 6-8 + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [0] { + } +} Property changes on: php/php-src/trunk/ext/reflection/tests/traits002.phpt ___ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c tests/traits002.phpt
felipe Sat, 29 May 2010 21:55:19 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299941 Log: - Missing Trait check fix Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c U php/php-src/trunk/ext/reflection/tests/traits002.phpt Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-29 21:48:56 UTC (rev 299940) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-29 21:55:19 UTC (rev 299941) @@ -382,7 +382,7 @@ } if (ce-ce_flags ZEND_ACC_INTERFACE) { string_printf(str, interface ); - } else if (ce-ce_flags ZEND_ACC_TRAIT) { + } else if ((ce-ce_flags ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) { string_printf(str, trait ); } else { if (ce-ce_flags (ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) { Modified: php/php-src/trunk/ext/reflection/tests/traits002.phpt === --- php/php-src/trunk/ext/reflection/tests/traits002.phpt 2010-05-29 21:48:56 UTC (rev 299940) +++ php/php-src/trunk/ext/reflection/tests/traits002.phpt 2010-05-29 21:55:19 UTC (rev 299941) @@ -15,7 +15,7 @@ ? --EXPECTF-- -Class [ user trait foo ] { +Class [ user abstract class foo ] { @@ %s 3-4 - Constants [0] { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c tests/traits003.phpt
felipe Sat, 29 May 2010 22:08:51 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299943 Log: - Fixed ReflectionClass::isTrait() checking (to not identify abstract class as Trait) Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c A php/php-src/trunk/ext/reflection/tests/traits003.phpt Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-29 22:00:43 UTC (rev 299942) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-29 22:08:51 UTC (rev 299943) @@ -3999,7 +3999,7 @@ Returns whether this is a trait */ ZEND_METHOD(reflection_class, isTrait) { - _class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_TRAIT); + _class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_TRAIT ~ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); } /* }}} */ Added: php/php-src/trunk/ext/reflection/tests/traits003.phpt === --- php/php-src/trunk/ext/reflection/tests/traits003.phpt (rev 0) +++ php/php-src/trunk/ext/reflection/tests/traits003.phpt 2010-05-29 22:08:51 UTC (rev 299943) @@ -0,0 +1,30 @@ +--TEST-- +Reflection and Traits +--FILE-- +?php + +abstract class foo { +} + +trait bar { + +} + +final class baz { + +} + +$x = new ReflectionClass('foo'); +var_dump($x-isTrait()); + +$x = new ReflectionClass('bar'); +var_dump($x-isTrait()); + +$x = new ReflectionClass('baz'); +var_dump($x-isTrait()); + +? +--EXPECT-- +bool(false) +bool(true) +bool(false) Property changes on: php/php-src/trunk/ext/reflection/tests/traits003.phpt ___ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c tests/ReflectionClass_toString_001.phpt tests/traits004.phpt tests/traits005.phpt
johannes Sun, 30 May 2010 01:00:45 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299946 Log: - More trait reflection work #- I'm not happy about ReflectionClass::getTraitAliases, yet Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c U php/php-src/trunk/ext/reflection/tests/ReflectionClass_toString_001.phpt A php/php-src/trunk/ext/reflection/tests/traits004.phpt A php/php-src/trunk/ext/reflection/tests/traits005.phpt Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-30 00:51:55 UTC (rev 299945) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-30 01:00:45 UTC (rev 299946) @@ -4254,6 +4254,80 @@ } /* }}} */ +/* {{{ 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; + zend_uint i; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(ce); + + array_init(return_value); + + for (i=0; i ce-num_traits; i++) { + zval *trait; + ALLOC_ZVAL(trait); + zend_reflection_class_factory(ce-traits[i], trait TSRMLS_CC); + add_assoc_zval_ex(return_value, ce-traits[i]-name, ce-traits[i]-name_length + 1, trait); + } +} +/* }}} */ + +/* {{{ 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; + zend_uint i; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(ce); + + array_init(return_value); + + for (i=0; i ce-num_traits; i++) { + add_next_index_stringl(return_value, ce-traits[i]-name, ce-traits[i]-name_length, 1); + } +} +/* }}} */ + +/* {{{ 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) { + zend_uint i = 0; + while (ce-trait_aliases[i]) { + char *method_name; + int method_name_len; + zend_trait_method_reference *cur_ref = ce-trait_aliases[i]-trait_method; + + method_name_len = spprintf(method_name, 0, %s::%s, cur_ref-class_name, cur_ref-method_name); + add_assoc_stringl_ex(return_value, ce-trait_aliases[i]-alias, ce-trait_aliases[i]-alias_len + 1, method_name, method_name_len, 0); + i++; + } + } +} +/* }}} */ + /* {{{ proto public ReflectionClass ReflectionClass::getParentClass() Returns the class' parent class, or, if none exists, FALSE */ ZEND_METHOD(reflection_class, getParentClass) @@ -5636,6 +5710,9 @@ 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) + 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) ZEND_ME(reflection_class, isTrait, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isAbstract, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isFinal, arginfo_reflection__void, 0) Modified: php/php-src/trunk/ext/reflection/tests/ReflectionClass_toString_001.phpt === --- php/php-src/trunk/ext/reflection/tests/ReflectionClass_toString_001.phpt 2010-05-30 00:51:55 UTC (rev 299945) +++ php/php-src/trunk/ext/reflection/tests/ReflectionClass_toString_001.phpt 2010-05-30 01:00:45 UTC (rev 299946) @@ -34,7 +34,7 @@ Property [ default public $name ] } - - Methods [44] { + - Methods [47] { Method [ internal:Reflection final private method __clone ] { - Parameters [0] { @@ -188,6 +188,24 @@ } } +Method [ internal:Reflection public method getTraits ] { + + - Parameters [0] { + } +} + +Method [ internal:Reflection public method getTraitNames ] { + + - Parameters [0] { + } +} + +Method [
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c
kalleThu, 27 May 2010 23:24:06 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299887 Log: Fixed compiler warning (pointer mismatch) Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-27 23:12:44 UTC (rev 299886) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-27 23:24:06 UTC (rev 299887) @@ -3286,7 +3286,7 @@ /* this is necessary to make it able to work with default array * properties, returned to user */ if (Z_TYPE_P(prop_copy) == IS_CONSTANT_ARRAY || (Z_TYPE_P(prop_copy) IS_CONSTANT_TYPE_MASK) == IS_CONSTANT) { - zval_update_constant(prop_copy, 1 TSRMLS_CC); + zval_update_constant(prop_copy, (void *) 1 TSRMLS_CC); } add_assoc_zval(return_value, key, prop_copy); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c
pierrick Wed, 26 May 2010 16:17:15 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299797 Log: Remove unused variable Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-26 15:42:59 UTC (rev 299796) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-26 16:17:15 UTC (rev 299797) @@ -4735,7 +4735,6 @@ zval **variable_ptr; zval *object, name; zval *value; - int setter_done = 0; zval *tmp; METHOD_NOTSTATIC(reflection_property_ptr); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c
johannes Tue, 30 Mar 2010 21:04:28 + Revision: http://svn.php.net/viewvc?view=revisionrevision=297204 Log: Fix folding Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-03-30 21:02:32 UTC (rev 297203) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-03-30 21:04:28 UTC (rev 297204) @@ -5044,8 +5044,8 @@ RETURN_BOOL(module-type == MODULE_TEMPORARY); } +/* }}} */ - /* {{{ method tables */ static const zend_function_entry reflection_exception_functions[] = { {NULL, NULL, NULL} -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c
johannes Tue, 30 Mar 2010 22:36:17 + Revision: http://svn.php.net/viewvc?view=revisionrevision=297207 Log: Fix protos Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-03-30 22:35:23 UTC (rev 297206) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-03-30 22:36:17 UTC (rev 297207) @@ -5037,7 +5037,7 @@ } /* }}} */ -/* {{{ proto public void ReflectionExtension::isPersistent() +/* {{{ proto public bool ReflectionExtension::isPersistent() Returns whether this extension is persistent */ ZEND_METHOD(reflection_extension, isPersistent) { @@ -5053,7 +5053,7 @@ } /* }}} */ -/* {{{ proto public void ReflectionExtension::isTemporary() +/* {{{ proto public bool ReflectionExtension::isTemporary() Returns whether this extension is temporary */ ZEND_METHOD(reflection_extension, isTemporary) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c
sebastianThu, 10 Sep 2009 05:15:24 + Revision: http://svn.php.net/viewvc?view=revisionrevision=288220 Log: Use getThis() correctly. Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2009-09-10 05:07:22 UTC (rev 288219) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2009-09-10 05:15:24 UTC (rev 288220) @@ -3122,8 +3122,7 @@ return; } - intern = getThis(); - intern = (reflection_object *) zend_object_store_get_object(intern TSRMLS_CC); + intern = (reflection_object *) zend_object_store_get_object(getThis() TSRMLS_CC); if (intern == NULL) { return; @@ -4934,8 +4933,7 @@ return; } - intern = getThis(); - intern = (reflection_object *) zend_object_store_get_object(intern TSRMLS_CC); + intern = (reflection_object *) zend_object_store_get_object(getThis() TSRMLS_CC); if (intern == NULL) { return; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php