[PHP-CVS] svn: /php/php-src/trunk/ NEWS ext/pdo/pdo_dbh.c ext/pdo/pdo_stmt.c ext/pdo/php_pdo_driver.h
dmitry Thu, 06 May 2010 08:37:41 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299060 Log: Fixed PDO objects binary incompatibility Changed paths: U php/php-src/trunk/NEWS U php/php-src/trunk/ext/pdo/pdo_dbh.c U php/php-src/trunk/ext/pdo/pdo_stmt.c U php/php-src/trunk/ext/pdo/php_pdo_driver.h Modified: php/php-src/trunk/NEWS === --- php/php-src/trunk/NEWS 2010-05-06 08:14:00 UTC (rev 299059) +++ php/php-src/trunk/NEWS 2010-05-06 08:37:41 UTC (rev 299060) @@ -49,7 +49,9 @@ . session_is_registered(), session_register() and session_unregister() functions. (Kalle) . y2k_compliance ini option. (Kalle) - + +- Fixed PDO objects binary incompatibility. (Dmitry) + ?? ??? 20??, PHP 5.3.3 - Upgraded bundled PCRE to version 8.01. (Ilia) Modified: php/php-src/trunk/ext/pdo/pdo_dbh.c === --- php/php-src/trunk/ext/pdo/pdo_dbh.c 2010-05-06 08:14:00 UTC (rev 299059) +++ php/php-src/trunk/ext/pdo/pdo_dbh.c 2010-05-06 08:37:41 UTC (rev 299060) @@ -328,20 +328,20 @@ memcpy((char *)pdbh-persistent_id, hashkey, plen+1); pdbh-persistent_id_len = plen+1; pdbh-refcount = 1; - pdbh-properties = NULL; + pdbh-std.properties = NULL; } } if (pdbh) { /* let's copy the emalloc bits over from the other handle */ - if (pdbh-properties) { - zend_hash_destroy(dbh-properties); - efree(dbh-properties); + if (pdbh-std.properties) { + zend_hash_destroy(dbh-std.properties); + efree(dbh-std.properties); } else { - pdbh-ce = dbh-ce; + pdbh-std.ce = dbh-std.ce; pdbh-def_stmt_ce = dbh-def_stmt_ce; pdbh-def_stmt_ctor_args = dbh-def_stmt_ctor_args; - pdbh-properties = dbh-properties; + pdbh-std.properties = dbh-std.properties; } /* kill the non-persistent thingamy */ efree(dbh); @@ -1286,7 +1286,7 @@ ifunc-type = ZEND_INTERNAL_FUNCTION; ifunc-handler = funcs-handler; ifunc-function_name = (char*)funcs-fname; - ifunc-scope = dbh-ce; + ifunc-scope = dbh-std.ce; ifunc-prototype = NULL; if (funcs-arg_info) { ifunc-arg_info = (zend_arg_info*)funcs-arg_info + 1; @@ -1539,16 +1539,12 @@ dbh-methods-rollback(dbh TSRMLS_CC); dbh-in_txn = 0; } - - if (dbh-properties) { - zend_hash_destroy(dbh-properties); - efree(dbh-properties); - dbh-properties = NULL; - } if (dbh-is_persistent dbh-methods dbh-methods-persistent_shutdown) { dbh-methods-persistent_shutdown(dbh TSRMLS_CC); } + zend_object_std_dtor(dbh-std TSRMLS_CC); + dbh-std.properties = NULL; dbh_free(dbh TSRMLS_CC); } @@ -1560,11 +1556,9 @@ dbh = emalloc(sizeof(*dbh)); memset(dbh, 0, sizeof(*dbh)); - dbh-ce = ce; + zend_object_std_init(dbh-std, ce TSRMLS_CC); + zend_hash_copy(dbh-std.properties, ce-default_properties, (copy_ctor_func_t) zval_add_ref, (void *) tmp, sizeof(zval *)); dbh-refcount = 1; - ALLOC_HASHTABLE(dbh-properties); - zend_hash_init(dbh-properties, 0, NULL, ZVAL_PTR_DTOR, 0); - zend_hash_copy(dbh-properties, ce-default_properties, (copy_ctor_func_t) zval_add_ref, (void *) tmp, sizeof(zval *)); dbh-def_stmt_ce = pdo_dbstmt_ce; retval.handle = zend_objects_store_put(dbh, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t)pdo_dbh_free_storage, NULL TSRMLS_CC); Modified: php/php-src/trunk/ext/pdo/pdo_stmt.c === --- php/php-src/trunk/ext/pdo/pdo_stmt.c2010-05-06 08:14:00 UTC (rev 299059) +++ php/php-src/trunk/ext/pdo/pdo_stmt.c2010-05-06 08:37:41 UTC (rev 299060) @@ -2319,11 +2319,9 @@ zend_object_handle handle = Z_OBJ_HANDLE_P(zobject); stmt = ecalloc(1, sizeof(*stmt)); - stmt-ce = Z_OBJCE_P(zobject); + zend_object_std_init(stmt-std, Z_OBJCE_P(zobject) TSRMLS_CC); + zend_hash_copy(stmt-std.properties, stmt-std.ce-default_properties, (copy_ctor_func_t) zval_add_ref, (void *) tmp,
Re: [PHP-CVS] svn: /php/php-src/trunk/ NEWS ext/json/json.c ext/json/php_json.h ext/json/tests/serialize.phpt
On Thu, May 6, 2010 at 00:48, Sara Golemon poll...@php.net wrote: pollita Wed, 05 May 2010 22:48:14 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299037 Log: Add JSON_Serializable interface Slight bikeshedding.. but we don't use underscore for interface/classnames... -Hannes -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] svn: /php/php-src/trunk/ NEWS ext/json/json.c ext/json/php_json.h ext/json/tests/serialize.phpt
On Thu, May 6, 2010 at 12:59 PM, Hannes Magnusson hannes.magnus...@gmail.com wrote: On Thu, May 6, 2010 at 00:48, Sara Golemon poll...@php.net wrote: pollita Wed, 05 May 2010 22:48:14 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299037 Log: Add JSON_Serializable interface Slight bikeshedding.. but we don't use underscore for interface/classnames... And I would go with JsonSerializable. However, where does it come from? Does it have to be an interface or why not using __toJson? I must have lived under a rock as I don't see any proposal either, be RFC or internals. Cheers, -- Pierre @pierrejoye | http://blog.thepimp.net | http://www.libgd.org -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_object_handlers.c zend_vm_def.h zend_vm_execute.h
dmitry Thu, 06 May 2010 12:52:27 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299065 Log: Added compiler hints Changed paths: U php/php-src/trunk/Zend/zend_object_handlers.c U php/php-src/trunk/Zend/zend_vm_def.h U php/php-src/trunk/Zend/zend_vm_execute.h Modified: php/php-src/trunk/Zend/zend_object_handlers.c === --- php/php-src/trunk/Zend/zend_object_handlers.c 2010-05-06 12:46:22 UTC (rev 299064) +++ php/php-src/trunk/Zend/zend_object_handlers.c 2010-05-06 12:52:27 UTC (rev 299065) @@ -191,30 +191,33 @@ } /* }}} */ -static struct _zend_property_info *zend_get_property_info_quick(zend_class_entry *ce, zval *member, int silent, ulong h TSRMLS_DC) /* {{{ */ +static struct _zend_property_info *zend_get_property_info_quick(zend_class_entry *ce, zval *member, int silent, const zend_literal *key TSRMLS_DC) /* {{{ */ { - zend_property_info *property_info = NULL; + zend_property_info *property_info; zend_property_info *scope_property_info; zend_bool denied_access = 0; + ulong h; - if (Z_STRVAL_P(member)[0] == '\0') { + if (UNEXPECTED(Z_STRVAL_P(member)[0] == '\0')) { if (!silent) { if (Z_STRLEN_P(member) == 0) { -zend_error(E_ERROR, Cannot access empty property); +zend_error_noreturn(E_ERROR, Cannot access empty property); } else { -zend_error(E_ERROR, Cannot access property started with '\\0'); +zend_error_noreturn(E_ERROR, Cannot access property started with '\\0'); } } return NULL; } + property_info = NULL; + h = key ? key-hash_value : zend_get_hash_value(Z_STRVAL_P(member), Z_STRLEN_P(member) + 1); if (zend_hash_quick_find(ce-properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, h, (void **) property_info)==SUCCESS) { - if(property_info-flags ZEND_ACC_SHADOW) { + if (UNEXPECTED((property_info-flags ZEND_ACC_SHADOW) != 0)) { /* if it's a shadow - go to access it's private */ property_info = NULL; } else { - if (zend_verify_property_access(property_info, ce TSRMLS_CC)) { -if (property_info-flags ZEND_ACC_CHANGED - !(property_info-flags ZEND_ACC_PRIVATE)) { + if (EXPECTED(zend_verify_property_access(property_info, ce TSRMLS_CC) != 0)) { +if (EXPECTED((property_info-flags ZEND_ACC_CHANGED) != 0) + EXPECTED(!(property_info-flags ZEND_ACC_PRIVATE))) { /* We still need to make sure that we're not in a context * where the right property is a different 'statically linked' private * continue checking below... @@ -238,12 +241,12 @@ scope_property_info-flags ZEND_ACC_PRIVATE) { return scope_property_info; } else if (property_info) { - if (denied_access) { + if (UNEXPECTED(denied_access != 0)) { /* Information was available, but we were denied access. Error out. */ - if (silent) { -return NULL; + if (!silent) { +zend_error_noreturn(E_ERROR, Cannot access %s property %s::$%s, zend_visibility_string(property_info-flags), ce-name, Z_STRVAL_P(member)); } - zend_error(E_ERROR, Cannot access %s property %s::$%s, zend_visibility_string(property_info-flags), ce-name, Z_STRVAL_P(member)); + return NULL; } else { /* fall through, return property_info... */ } @@ -261,9 +264,7 @@ ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce, zval *member, int silent TSRMLS_DC) /* {{{ */ { - zend_ulong h = zend_get_hash_value(Z_STRVAL_P(member), Z_STRLEN_P(member) + 1); - - return zend_get_property_info_quick(ce, member, silent, h TSRMLS_CC); + return zend_get_property_info_quick(ce, member, silent, NULL TSRMLS_CC); } /* }}} */ @@ -275,7 +276,7 @@ zend_unmangle_property_name(prop_info_name, prop_info_name_len, class_name, prop_name); ZVAL_STRING(member, prop_name, 0); - property_info = zend_get_property_info(zobj-ce, member, 1 TSRMLS_CC); + property_info = zend_get_property_info_quick(zobj-ce, member, 1, NULL TSRMLS_CC); if (!property_info) { return FAILURE; } @@ -329,8 +330,8 @@ silent = (type == BP_VAR_IS); zobj = Z_OBJ_P(object); - if (Z_TYPE_P(member) != IS_STRING) { - ALLOC_ZVAL(tmp_member); + if (UNEXPECTED(Z_TYPE_P(member) != IS_STRING)) { + ALLOC_ZVAL(tmp_member); *tmp_member = *member; INIT_PZVAL(tmp_member); zval_copy_ctor(tmp_member); @@ -344,13 +345,10 @@ #endif /* make zend_get_property_info silent if we have getter - we may want to use it */ - if (key) { - property_info = zend_get_property_info_quick(zobj-ce, member, (zobj-ce-__get != NULL), key-hash_value TSRMLS_CC); - } else { - property_info = zend_get_property_info(zobj-ce, member, (zobj-ce-__get != NULL) TSRMLS_CC); - } + property_info = zend_get_property_info_quick(zobj-ce, member, (zobj-ce-__get != NULL), key TSRMLS_CC); - if (!property_info || zend_hash_quick_find(zobj-properties, property_info-name, property_info-name_length+1, property_info-h, (void **) retval) == FAILURE) { + if
[PHP-CVS] svn: /php/php-src/trunk/ext/json/ json.c
kalleThu, 06 May 2010 13:44:35 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299070 Log: Well we do need zend_throw_exception_ex ;-) Changed paths: U php/php-src/trunk/ext/json/json.c Modified: php/php-src/trunk/ext/json/json.c === --- php/php-src/trunk/ext/json/json.c 2010-05-06 13:31:10 UTC (rev 299069) +++ php/php-src/trunk/ext/json/json.c 2010-05-06 13:44:35 UTC (rev 299070) @@ -29,6 +29,7 @@ #include utf8_to_utf16.h #include JSON_parser.h #include php_json.h +#include zend_exceptions.h static PHP_MINFO_FUNCTION(json); static PHP_FUNCTION(json_encode); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ UPGRADING Zend/zend_builtin_functions.c
felipe Thu, 06 May 2010 15:18:20 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299078 Log: - Added get_declared_traits() Changed paths: U php/php-src/trunk/UPGRADING U php/php-src/trunk/Zend/zend_builtin_functions.c Modified: php/php-src/trunk/UPGRADING === --- php/php-src/trunk/UPGRADING 2010-05-06 15:17:56 UTC (rev 299077) +++ php/php-src/trunk/UPGRADING 2010-05-06 15:18:20 UTC (rev 299078) @@ -216,6 +216,7 @@ f. New global constants - Core: + - get_declared_traits() g. New classes Modified: php/php-src/trunk/Zend/zend_builtin_functions.c === --- php/php-src/trunk/Zend/zend_builtin_functions.c 2010-05-06 15:17:56 UTC (rev 299077) +++ php/php-src/trunk/Zend/zend_builtin_functions.c 2010-05-06 15:18:20 UTC (rev 299078) @@ -69,6 +69,7 @@ static ZEND_FUNCTION(set_exception_handler); static ZEND_FUNCTION(restore_exception_handler); static ZEND_FUNCTION(get_declared_classes); +static ZEND_FUNCTION(get_declared_traits); static ZEND_FUNCTION(get_declared_interfaces); static ZEND_FUNCTION(get_defined_functions); static ZEND_FUNCTION(get_defined_vars); @@ -261,6 +262,7 @@ ZEND_FE(set_exception_handler, arginfo_set_exception_handler) ZEND_FE(restore_exception_handler, arginfo_zend__void) ZEND_FE(get_declared_classes, arginfo_zend__void) + ZEND_FE(get_declared_traits,arginfo_zend__void) ZEND_FE(get_declared_interfaces,arginfo_zend__void) ZEND_FE(get_defined_functions, arginfo_zend__void) ZEND_FE(get_defined_vars, arginfo_zend__void) @@ -1564,12 +1566,28 @@ return ZEND_HASH_APPLY_KEEP; } +/* {{{ proto array get_declared_traits() + Returns an array of all declared traits. */ +ZEND_FUNCTION(get_declared_traits) +{ + zend_uint mask = ZEND_ACC_TRAIT; + zend_uint comply = 1; + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + array_init(return_value); + zend_hash_apply_with_arguments(EG(class_table) TSRMLS_CC, (apply_func_args_t) copy_class_or_interface_name, 3, return_value, mask, comply); +} +/* }}} */ + + /* {{{ proto array get_declared_classes() Returns an array of all declared classes. */ ZEND_FUNCTION(get_declared_classes) { - zend_uint mask = ZEND_ACC_INTERFACE; + zend_uint mask = ZEND_ACC_INTERFACE | (ZEND_ACC_TRAIT ~ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); zend_uint comply = 0; if (zend_parse_parameters_none() == FAILURE) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] svn: /php/php-src/trunk/ UPGRADING Zend/zend_builtin_functions.c
On Thu, 2010-05-06 at 15:18 +, Felipe Pena wrote: felipe Thu, 06 May 2010 15:18:20 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299078 Log: - Added get_declared_traits() do we need a traits-specific reflection class or will ReflectionClass work well enough? Does ReflectionClass return information about traits used by a random class? (I can/will look into it if nobody is faster) johannes -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/tests/traits/ get_declared_traits_001.phpt get_declared_traits_002.phpt get_declared_traits_003.phpt
felipe Thu, 06 May 2010 15:49:58 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299084 Log: - New tests Changed paths: A php/php-src/trunk/Zend/tests/traits/get_declared_traits_001.phpt A php/php-src/trunk/Zend/tests/traits/get_declared_traits_002.phpt A php/php-src/trunk/Zend/tests/traits/get_declared_traits_003.phpt Added: php/php-src/trunk/Zend/tests/traits/get_declared_traits_001.phpt === --- php/php-src/trunk/Zend/tests/traits/get_declared_traits_001.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/get_declared_traits_001.phpt 2010-05-06 15:49:58 UTC (rev 299084) @@ -0,0 +1,19 @@ +--TEST-- +Testing get_declared_traits() +--FILE-- +?php + +class a { } +interface b { } +trait c { } +abstract class d { } +final class e { } + +var_dump(get_declared_traits()); + +? +--EXPECT-- +array(1) { + [0]= + string(1) c +} Property changes on: php/php-src/trunk/Zend/tests/traits/get_declared_traits_001.phpt ___ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native Added: php/php-src/trunk/Zend/tests/traits/get_declared_traits_002.phpt === --- php/php-src/trunk/Zend/tests/traits/get_declared_traits_002.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/get_declared_traits_002.phpt 2010-05-06 15:49:58 UTC (rev 299084) @@ -0,0 +1,20 @@ +--TEST-- +Testing get_declared_traits() inside namespace +--FILE-- +?php + +namespace test { + class a { } + interface b { } + trait c { } + abstract class d { } + final class e { } + var_dump(get_declared_traits()); +} + +? +--EXPECT-- +array(1) { + [0]= + string(6) test\c +} Property changes on: php/php-src/trunk/Zend/tests/traits/get_declared_traits_002.phpt ___ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native Added: php/php-src/trunk/Zend/tests/traits/get_declared_traits_003.phpt === --- php/php-src/trunk/Zend/tests/traits/get_declared_traits_003.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/get_declared_traits_003.phpt 2010-05-06 15:49:58 UTC (rev 299084) @@ -0,0 +1,25 @@ +--TEST-- +Testing get_declared_classes() and get_declared_traits() +--FILE-- +?php + +class a { } +interface b { } +trait c { } +abstract class d { } +final class e { } +var_dump(get_declared_classes()); +var_dump(get_declared_traits()); + +? +--EXPECTF-- +%astring(1) a + [%d]= + string(1) d + [%d]= + string(1) e +} +array(1) { + [0]= + string(1) c +} Property changes on: php/php-src/trunk/Zend/tests/traits/get_declared_traits_003.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
Re: [PHP-CVS] svn: /php/php-src/trunk/ UPGRADING Zend/zend_builtin_functions.c
2010/5/6 Johannes Schlüter johan...@schlueters.de On Thu, 2010-05-06 at 15:18 +, Felipe Pena wrote: felipe Thu, 06 May 2010 15:18:20 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299078 Log: - Added get_declared_traits() do we need a traits-specific reflection class or will ReflectionClass work well enough? Does ReflectionClass return information about traits used by a random class? (I can/will look into it if nobody is faster) I guess better to create a traits-specific class. Currently the ReflectionClass doesn't return information about traits. -- Regards, Felipe Pena
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
felipe Thu, 06 May 2010 18:20:38 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299088 Log: - Fix error messages WS Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-05-06 17:17:45 UTC (rev 299087) +++ php/php-src/trunk/Zend/zend_compile.c 2010-05-06 18:20:38 UTC (rev 299088) @@ -3530,8 +3530,7 @@ lcname = zend_str_tolower_dup(aliases[i]-alias, lcname_len); if (zend_hash_add(target, lcname, lcname_len+1, fn_copy, sizeof(zend_function), NULL)==FAILURE) { - zend_error(E_ERROR, Failed to added aliased trait method (%s) to trait table. Propably there is already a trait method with same name\n, - fn_copy.common.function_name); + zend_error(E_ERROR, Failed to added aliased trait method (%s) to trait table. Propably there is already a trait method with same name, fn_copy.common.function_name); } /* aliases[i]-function = fn_copy; */ efree(lcname); @@ -3576,8 +3575,7 @@ lcname2 = zend_str_tolower_dup(aliases[i]-alias, lcname2_len); if (zend_hash_add(target, lcname2, lcname2_len+1, fn_copy2, sizeof(zend_function), NULL)==FAILURE) { - zend_error(E_ERROR, Failed to added aliased trait method (%s) to trait table. Propably there is already a trait method with same name\n, - fn_copy2.common.function_name); + zend_error(E_ERROR, Failed to added aliased trait method (%s) to trait table. Propably there is already a trait method with same name, fn_copy2.common.function_name); } efree(lcname2); } else { @@ -3595,8 +3593,7 @@ if (zend_hash_add(target, lcname, fnname_len+1, fn_copy, sizeof(zend_function), NULL)==FAILURE) { - zend_error(E_ERROR, Failed to added trait method (%s) to trait table. Propably there is already a trait method with same name\n, - fn_copy.common.function_name); + zend_error(E_ERROR, Failed to added trait method (%s) to trait table. Propably there is already a trait method with same name, fn_copy.common.function_name); } } @@ -3670,8 +3667,7 @@ char* lcname = zend_str_tolower_dup(precedences[i]-trait_method-method_name, lcname_len); if (zend_hash_add(exclude_table, lcname, lcname_len, NULL, 0, NULL)==FAILURE) { - zend_error(E_ERROR, Failed to evaluate a trait precedence (%s). Method of trait %s was defined to be excluded multiple times.\n, - precedences[i]-trait_method-method_name, trait-name); + zend_error(E_ERROR, Failed to evaluate a trait precedence (%s). Method of trait %s was defined to be excluded multiple times, precedences[i]-trait_method-method_name, trait-name); } efree(lcname); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
felipe Thu, 06 May 2010 18:28:45 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299089 Log: - Fix typos Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-05-06 18:20:38 UTC (rev 299088) +++ php/php-src/trunk/Zend/zend_compile.c 2010-05-06 18:28:45 UTC (rev 299089) @@ -3530,7 +3530,7 @@ lcname = zend_str_tolower_dup(aliases[i]-alias, lcname_len); if (zend_hash_add(target, lcname, lcname_len+1, fn_copy, sizeof(zend_function), NULL)==FAILURE) { - zend_error(E_ERROR, Failed to added aliased trait method (%s) to trait table. Propably there is already a trait method with same name, fn_copy.common.function_name); + zend_error(E_ERROR, Failed to add aliased trait method (%s) to trait table. Probably there is already a trait method with same name, fn_copy.common.function_name); } /* aliases[i]-function = fn_copy; */ efree(lcname); @@ -3575,7 +3575,7 @@ lcname2 = zend_str_tolower_dup(aliases[i]-alias, lcname2_len); if (zend_hash_add(target, lcname2, lcname2_len+1, fn_copy2, sizeof(zend_function), NULL)==FAILURE) { - zend_error(E_ERROR, Failed to added aliased trait method (%s) to trait table. Propably there is already a trait method with same name, fn_copy2.common.function_name); + zend_error(E_ERROR, Failed to add aliased trait method (%s) to trait table. Probably there is already a trait method with same name, fn_copy2.common.function_name); } efree(lcname2); } else { @@ -3591,9 +3591,8 @@ } } - if (zend_hash_add(target, lcname, fnname_len+1, fn_copy, sizeof(zend_function), NULL)==FAILURE) { - zend_error(E_ERROR, Failed to added trait method (%s) to trait table. Propably there is already a trait method with same name, fn_copy.common.function_name); + zend_error(E_ERROR, Failed to add trait method (%s) to trait table. Probably there is already a trait method with same name, fn_copy.common.function_name); } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_compile.c
felipe Thu, 06 May 2010 19:20:12 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299090 Log: - Added check for 'static' on trait visibility modifier Changed paths: U php/php-src/trunk/Zend/zend_compile.c Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-05-06 18:28:45 UTC (rev 299089) +++ php/php-src/trunk/Zend/zend_compile.c 2010-05-06 19:20:12 UTC (rev 299090) @@ -3308,8 +3308,7 @@ if (zend_hash_quick_find(ce-function_table, hash_key-arKey, hash_key-nKeyLength, hash_key-h, (void **)class_fn) == FAILURE || class_fn-common.scope != ce) { - zend_error(E_WARNING, Trait method %s has not been applied, because there are collisions with other trait methods on %s, - fn-common.function_name, ce-name); + zend_error(E_WARNING, Trait method %s has not been applied, because there are collisions with other trait methods on %s, fn-common.function_name, ce-name); } zend_function_dtor(fn); @@ -3318,8 +3317,7 @@ } else { /* Add it to result function table */ if (zend_hash_quick_add(resulting_table, hash_key-arKey, hash_key-nKeyLength, hash_key-h, fn, sizeof(zend_function), NULL)==FAILURE) { - zend_error(E_ERROR, Trait method %s has not been applied, because failure occured during updating resulting trait method table., - fn-common.function_name); + zend_error(E_ERROR, Trait method %s has not been applied, because failure occured during updating resulting trait method table, fn-common.function_name); } } @@ -3476,7 +3474,7 @@ } if (zend_hash_quick_update(ce-function_table, hash_key-arKey, hash_key-nKeyLength, hash_key-h, fn, sizeof(zend_function), NULL)==FAILURE) { - zend_error(E_ERROR, Trait method %s has not been applied, because failure occured during updating class method table., hash_key-arKey); + zend_error(E_ERROR, Trait method %s has not been applied, because failure occured during updating class method table, hash_key-arKey); } _ADD_MAGIC_METHOD(ce, hash_key-arKey, hash_key-nKeyLength, fn); @@ -3835,6 +3833,11 @@ trait_alias-trait_method = (zend_trait_method_reference*)method_reference-u.op.ptr; trait_alias-modifiers = Z_LVAL(modifiers-u.constant); + + if (Z_LVAL(modifiers-u.constant) == ZEND_ACC_STATIC) { + zend_error(E_COMPILE_ERROR, Cannot use 'static' as method modifier); + return; + } if (alias) { trait_alias-alias = Z_STRVAL(alias-u.constant); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/Zend/tests/traits/ error_010.phpt error_011.phpt error_012.phpt error_013.phpt error_014.phpt error_015.phpt
felipe Thu, 06 May 2010 19:21:11 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299091 Log: - New tests Changed paths: A php/php-src/trunk/Zend/tests/traits/error_010.phpt A php/php-src/trunk/Zend/tests/traits/error_011.phpt A php/php-src/trunk/Zend/tests/traits/error_012.phpt A php/php-src/trunk/Zend/tests/traits/error_013.phpt A php/php-src/trunk/Zend/tests/traits/error_014.phpt A php/php-src/trunk/Zend/tests/traits/error_015.phpt Added: php/php-src/trunk/Zend/tests/traits/error_010.phpt === --- php/php-src/trunk/Zend/tests/traits/error_010.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/error_010.phpt 2010-05-06 19:21:11 UTC (rev 299091) @@ -0,0 +1,27 @@ +--TEST-- +Trying to exclude trait method multiple times +--FILE-- +?php + +trait foo { + public function test() { return 3; } +} +trait c { + public function test() { return 2; } +} + +trait b { + public function test() { return 1; } +} + +class bar { + use foo, c { c::test insteadof foo, b; } + use foo, c { c::test insteadof foo, b; } +} + +$x = new bar; +var_dump($x-test()); + +? +--EXPECTF-- +Fatal error: Failed to evaluate a trait precedence (test). Method of trait foo was defined to be excluded multiple times in %s on line %d Property changes on: php/php-src/trunk/Zend/tests/traits/error_010.phpt ___ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native Added: php/php-src/trunk/Zend/tests/traits/error_011.phpt === --- php/php-src/trunk/Zend/tests/traits/error_011.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/error_011.phpt 2010-05-06 19:21:11 UTC (rev 299091) @@ -0,0 +1,28 @@ +--TEST-- +Testing trait collisions +--FILE-- +?php + +trait foo { + public function test() { return 3; } +} +trait c { + public function test() { return 2; } +} + +trait b { + public function test() { return 1; } +} + +class bar { + use foo, c, b; +} + +$x = new bar; +var_dump($x-test()); + +? +--EXPECTF-- +Warning: Trait method test has not been applied, because there are collisions with other trait methods on bar in %s on line %d + +Fatal error: Call to undefined method bar::test() in %s on line %d Property changes on: php/php-src/trunk/Zend/tests/traits/error_011.phpt ___ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native Added: php/php-src/trunk/Zend/tests/traits/error_012.phpt === --- php/php-src/trunk/Zend/tests/traits/error_012.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/error_012.phpt 2010-05-06 19:21:11 UTC (rev 299091) @@ -0,0 +1,19 @@ +--TEST-- +Trying to access a protected trait method +--FILE-- +?php + +trait foo { + public function test() { return 3; } +} + +class bar { + use foo { test as protected; } +} + +$x = new bar; +var_dump($x-test()); + +? +--EXPECTF-- +Fatal error: Call to protected method bar::test() from context '' in %s on line %d Property changes on: php/php-src/trunk/Zend/tests/traits/error_012.phpt ___ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native Added: php/php-src/trunk/Zend/tests/traits/error_013.phpt === --- php/php-src/trunk/Zend/tests/traits/error_013.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/error_013.phpt 2010-05-06 19:21:11 UTC (rev 299091) @@ -0,0 +1,19 @@ +--TEST-- +Trying to use static as method modifier +--FILE-- +?php + +trait foo { + public function test() { return 3; } +} + +class bar { + use foo { test as static; } +} + +$x = new bar; +var_dump($x-test()); + +? +--EXPECTF-- +Fatal error: Cannot use 'static' as method modifier in %s on line %d Property changes on: php/php-src/trunk/Zend/tests/traits/error_013.phpt ___ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native Added: php/php-src/trunk/Zend/tests/traits/error_014.phpt === --- php/php-src/trunk/Zend/tests/traits/error_014.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/error_014.phpt 2010-05-06 19:21:11 UTC (rev 299091) @@ -0,0 +1,23 @@ +--TEST-- +Trying to override final method +--FILE-- +?php + +trait foo { + public function test() { return 3; } +} + +class baz { + final public function test() { return 4; } +} + +class bar extends baz { + use
Re: [PHP-CVS] svn: /php/php-src/trunk/Zend/tests/traits/ error_010.phpt error_011.phpt error_012.phpt error_013.phpt error_014.phpt error_015.phpt
2010/5/6 Felipe Pena fel...@php.net: felipe Thu, 06 May 2010 19:21:11 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299091 +Fatal error: Failed to add aliased trait method (zzz) to trait table. Probably there is already a trait method with same name in %s on line %d This error message is strange. I think it should be changed to: Failed to add aliased trait method (zzz) to the trait table. There is probably already a trait method with the same name or similar. -- regards, Kalle Sommer Nielsen ka...@php.net -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php