Hi Antony,

On Wed, 2007-08-01 at 11:45 +0400, Antony Dovgal wrote:
> Johannes, the patch looks a bit weird to me.
> 
> You called new parameter "categorize", which to my understanding means
> that the only difference it makes - adds categories to the list of extensions.
> But that's not what it does, since without it the list is not the same.
> 
> I suggest we should either add zend extensions to the list when new parameter 
> is 
> not passed (this way the parameter would really "categorize" the list) 

I don't think adding zend exts always would be good since it would break
code like foreach (get_loaded_extensions() as $e) $r = new
ReflectionExtension($e);

> OR return _only_ zend extensions when it's passed (and rename the parameter).
> That would make much more sense to me.

I'm fine with that. The original patch was a result from discussions on
IRC but I'll update it later today.

johannes

> What do you think?
> 
> > -/* {{{ proto array get_loaded_extensions(void)
> > +/* {{{ proto array get_loaded_extensions([mixed categorize]) U
> >     Return an array containing names of loaded extensions */
> >  ZEND_FUNCTION(get_loaded_extensions)
> >  {
> > -   if (ZEND_NUM_ARGS() != 0) {
> > +   int argc = ZEND_NUM_ARGS();
> > +
> > +   if (argc != 0 && argc != 1) {
> >             ZEND_WRONG_PARAM_COUNT();
> >     }
> >  
> >     array_init(return_value);
> > -   zend_hash_apply_with_argument(&module_registry, (apply_func_arg_t) 
> > add_extension_info, return_value TSRMLS_CC);
> > +
> > +   if (argc) {
> > +           zval *modules;
> > +           zval *extensions;
> > +
> > +           MAKE_STD_ZVAL(modules);
> > +           array_init(modules);
> > +           zend_hash_apply_with_argument(&module_registry, 
> > (apply_func_arg_t) add_extension_info, modules TSRMLS_CC);
> > +           add_assoc_zval_ex(return_value, "PHP Modules", sizeof("PHP 
> > Modules"), modules);
> > +
> > +           MAKE_STD_ZVAL(extensions);
> > +           array_init(extensions);
> > +           zend_llist_apply_with_argument(&zend_extensions, 
> > (llist_apply_with_arg_func_t) add_zendext_info, extensions TSRMLS_CC);
> > +           add_assoc_zval_ex(return_value, "Zend Extensions", sizeof("Zend 
> > Extensions"), extensions);
> > +   } else {
> > +           zend_hash_apply_with_argument(&module_registry, 
> > (apply_func_arg_t) add_extension_info, return_value TSRMLS_CC);
> > +   }
> >  }
> >  /* }}} */
> 
> 

Reply via email to