[PHP-DEV] XML URIs and streams
Just realized there is an issue with URI handling and XML. Problem deals with escaping and non-filesystem URIs. Doesn't work unless URI gets double escaped. Have a patch that's only been tested a bit with latest libxml so far, though I dont forsee any issues with earlier versions. http://www.ctindustries.net/patches/libxml.diff.txt The issue is it may break existing apps that double escape only the arguments and not the entire URI. It will though make it work like the rest of the stream based functions like file_get_contents, but still allow the loading of a URI that has been completely escaped, which the other functions fail on but worked for xml under PHP 5.0. I'm out for the week as of tomorrow morning but would like to get some fix in for 5.1. Should I commit now to get it into RC1, wait till I get back and do more testing first, or not do it since it potentially will break some apps. Personally I think what it fixes greatly outweighs any potential breakage. Rob -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] non-standard behavior of socket_recvfrom()
Hi, This may be an odd suggestion/request, and nothing in the line of what's currently hot around here (PHP 5.1 that is), but I'm making it anyway: The current behavior of socket_recvfrom() (/etc/sockets/socket.h) on a connection error, is that it frees the buffer (recv_buf), throws an error and returns from the function. I'd like to suggest that more correct behaviour would be to use the buffer before returning. As far as I know, even on failure, the buffer can be used to extract information on why the connection was refused. I came upon this while I was trying to implement a traceroute algorithm, which should be pretty simple, but seems impossible because of this socket behavior in PHP. The change in the code of socket_recvfrom() would be very minimal. I would suggest a patch myself, but the problems are that I don't know how and I don't know nearly enough about the PHP engine to write solid code for it (maybe I should work on that). Ron -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Property Overloading RFC
Derick Rethans wrote: Problems: 1. There is no way to document the 'virtual' properties with any of the existing documentation tools (such as phpdoc and doxygen) Rather then adding abstract properties, why not simply document the possible values inside the doc comments ala: /** * @var abstract int Contains all X */ 2. There is no way how the magic methods know if a specific 'virtual' property exists or not as those properties are not declared usually - unless you define an array with property names as a class constant (which is not allowed either). That's the whole concept behind the feature, if the values were known you may as well use clearly declared property and method names. 3. There is no way for the magic methods to return a meaningfull error when a property doesn't "exist". Of course it is possible to throw an error with "trigger_error" or "throw" in case a property doesn't "exist" in a specific class, but the file and line numbers would not match the actually get/set action. debug_backtrace() can be used to retrieve the correct file and line, but as you have to do this for every class where you want to use setters and getters *and* you have to implement your own error message rendering function this is not really a suitable option either. How about adding a 3rd optional argument to __get and __set which would be an array of acceptable values for the "name" parameter? If there is a mismatch a standard warning message will be raised if this parameter was supplied. ilia -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Property Overloading RFC
On Sun, 7 Aug 2005, Ilia Alshanetsky wrote: > Derick Rethans wrote: > > Problems: > > 1. There is no way to document the 'virtual' properties with any of the > > existing > >documentation tools (such as phpdoc and doxygen) > > Rather then adding abstract properties, why not simply document the possible > values inside the doc comments ala: > /** > * @var abstract int Contains all X > */ That would work, if __set and __get were also called for declared properties... but they don't do that so you need some keyword - or break BC. > > 2. There is no way how the magic methods know if a specific 'virtual' > > property > >exists or not as those properties are not declared usually - unless you > >define an array with property names as a class constant (which is not > >allowed either). > > That's the whole concept behind the feature, if the values were known you may > as well use clearly declared property and method names. True, unless you want to force all property access to go through a setter/getter for all declared properties for checks. This is also useful for catching typoes: fo = 42; ?> does not throw any notice now for BC reasons. > > 3. There is no way for the magic methods to return a meaningfull > >error when a property doesn't "exist". Of course it is possible > >to throw an error with "trigger_error" or "throw" in case a > >property doesn't "exist" in a specific class, but the file and > >line numbers would not match the actually get/set action. > >debug_backtrace() can be used to retrieve the correct file and > >line, but as you have to do this for every class where you want > >to use setters and getters *and* you have to implement your own > >error message rendering function this is not really a suitable > >option either. > > How about adding a 3rd optional argument to __get and __set which would be an > array of acceptable values for the "name" parameter? If there is a mismatch a > standard warning message will be raised if this parameter was supplied. How does the engine know which list is allowed? The engine is calling the __set and __get methods, not users. The whole idea of using a keyword here is to provide the engine with such a list. Derick -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DEV] Re: [PATCH] Namespace Patch, Beta 2
I was made aware of the fact that the patch wasn't compiling in ZTS mode, so I fixed this in the attached patch (I still have not gotten a chance to test under Windows, but it does work on Linux, both in ZTS and non-ZTS mode). Other than that, there are no other changes. Regards, Jessie Index: Zend/zend.c === RCS file: /repository/ZendEngine2/zend.c,v retrieving revision 1.306 diff -u -r1.306 zend.c --- Zend/zend.c 27 Jun 2005 22:04:41 - 1.306 +++ Zend/zend.c 8 Aug 2005 03:48:29 - @@ -34,10 +34,14 @@ # define GLOBAL_CLASS_TABLE global_class_table # define GLOBAL_CONSTANTS_TABLE global_constants_table # define GLOBAL_AUTO_GLOBALS_TABLEglobal_auto_globals_table +# define GLOBAL_IMPORT_CLASS_TABLEglobal_import_class_table +# define GLOBAL_IMPORT_NAMESPACE_TABLEglobal_import_namespace_table #else # define GLOBAL_FUNCTION_TABLECG(function_table) # define GLOBAL_CLASS_TABLE CG(class_table) # define GLOBAL_AUTO_GLOBALS_TABLECG(auto_globals) +# define GLOBAL_IMPORT_CLASS_TABLECG(import_class_table) +# define GLOBAL_IMPORT_NAMESPACE_TABLECG(import_namespace_table) #endif #if defined(ZEND_WIN32) && ZEND_DEBUG @@ -88,6 +92,8 @@ HashTable *global_class_table; HashTable *global_constants_table; HashTable *global_auto_globals_table; +HashTable *global_import_class_table; +HashTable *global_import_namespace_table; #endif ZEND_API zend_utility_values zend_uv; @@ -430,6 +436,7 @@ { zend_function tmp_func; zend_class_entry *tmp_class; + HashTable tmp_hash; compiler_globals->compiled_filename = NULL; @@ -443,6 +450,24 @@ zend_set_default_compile_time_values(TSRMLS_C); + /* initialize namespace variables */ + compiler_globals->in_anonymous_namespace = 0; + compiler_globals->namespace_prefix = NULL; + compiler_globals->namespace_prefix_lc = NULL; + compiler_globals->namespace_prefix_len = 0; + + /* initialize the import class table */ + compiler_globals->import_class_table = (HashTable *) malloc(sizeof(HashTable)); + compiler_globals->current_import_class_table = NULL; + zend_hash_init_ex(compiler_globals->import_class_table, 10, NULL, (dtor_func_t) zend_hash_destroy, 1, 0); + zend_hash_copy(compiler_globals->import_class_table, global_import_class_table, NULL, &tmp_hash, sizeof(tmp_hash)); + + /* initialize the import namespace table */ + compiler_globals->import_namespace_table = (HashTable *) malloc(sizeof(HashTable)); + compiler_globals->current_import_namespace_table = NULL; + zend_hash_init_ex(compiler_globals->import_namespace_table, 10, NULL, (dtor_func_t) zend_hash_destroy, 1, 0); + zend_hash_copy(compiler_globals->import_namespace_table, global_import_namespace_table, NULL, &tmp_hash, sizeof(tmp_hash)); + CG(interactive) = 0; compiler_globals->auto_globals = (HashTable *) malloc(sizeof(HashTable)); @@ -465,6 +490,14 @@ zend_hash_destroy(compiler_globals->auto_globals); free(compiler_globals->auto_globals); } + if (compiler_globals->import_class_table != GLOBAL_IMPORT_CLASS_TABLE) { + zend_hash_destroy(compiler_globals->import_class_table); + free(compiler_globals->import_class_table); + } + if (compiler_globals->import_namespace_table != GLOBAL_IMPORT_NAMESPACE_TABLE) { + zend_hash_destroy(compiler_globals->import_namespace_table); + free(compiler_globals->import_namespace_table); + } } @@ -588,11 +621,15 @@ GLOBAL_FUNCTION_TABLE = (HashTable *) malloc(sizeof(HashTable)); GLOBAL_CLASS_TABLE = (HashTable *) malloc(sizeof(HashTable)); GLOBAL_AUTO_GLOBALS_TABLE = (HashTable *) malloc(sizeof(HashTable)); + GLOBAL_IMPORT_CLASS_TABLE = (HashTable *) malloc(sizeof(HashTable)); + GLOBAL_IMPORT_NAMESPACE_TABLE = (HashTable *) malloc(sizeof(HashTable)); #ifdef ZTS GLOBAL_CONSTANTS_TABLE = (HashTable *) malloc(sizeof(HashTable)); #endif zend_hash_init_ex(GLOBAL_FUNCTION_TABLE, 100, NULL, ZEND_FUNCTION_DTOR, 1, 0); zend_hash_init_ex(GLOBAL_CLASS_TABLE, 10, NULL, ZEND_CLASS_DTOR, 1, 0); + zend_hash_init_ex(GLOBAL_IMPORT_CLASS_TABLE, 10, NULL, (dtor_func_t) zend_hash_destroy, 1, 0); + zend_hash_init_ex(GLOBAL_IMPORT_NAMESPACE_TABLE, 10, NULL, (dtor_func_t) zend_hash_destroy, 1, 0); zend_hash_init_ex(&module_registry, 50, NULL, ZEND_MODULE_DTOR, 1, 0); zend_init_rsrc_list_dtors(); @@ -618,10 +655,17 @@ compiler_globals->in_compilation = 0; compiler_globals->function_table = (HashTable *) malloc(sizeof(HashTable)); compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable)); + compiler_globals->import_class_table = (HashTable *) malloc(sizeof(HashTable)); + compiler_globals->import_namespace_table = (HashTable *) malloc(sizeof(HashTable)); + compiler_globals->in_anonymous_namespace = 0; + compiler_globals->current_import_class_table = NULL; + compiler_globals->current_import_namespace_table = NULL; *compiler_globals->function_table = *GLOBAL_FUNCTION_TABLE; *compiler_globals->class_table = *G