[patch] Separating ZEND_METHOD and ZEND_FUNCTION

php.internals

Johannes Schlueter

20 years ago
Hi, following a recent discussion on IRC I'd like to propose a little patch separating ZEND_FUNCTION and ZEND_METHOD. Currently functions declared as ZEND_FUNCTION are named zif_exported_name. Class methods are exported as zif_class_method. If you try to create a PHP function called foo_bar but already have some class foo with a method bar this leads to a "redefinition of `zif_foo_bar`". The attached patch solves this kind of issues by prefixing methods with zim_ (with m like in method) instead of zif_. Additionally it might help a bit while debugging since you can see wether you're in some class/object or a function context. As always the patch is also available at my repository on http://svn.schlueters.de/phpatches/HEAD/zend_separate_zend_method.diff johannes

Andi Gutmans

20 years ago
Makes sense to me. At 02:30 PM 3/3/2006, Johannes Schlueter wrote:

Pierre Joye

20 years ago
On 3/3/06, Andi Gutmans <andi@zend.com> wrote:
> Makes sense to me.
For me too, I was requesting that on IRC and Johannes wrote the patch, thanks :-) A perfect example of this need is the current zip extension, I have both a zip_open function and a zip::open method, acting differently. Many extensions have to (re)define themselves these macros, as I did. --Pierre