@@ -760,33 +760,46 @@ PHP_METHOD(XSLTProcessor, registerPHPFunctions)
760
760
{
761
761
zval * id = ZEND_THIS ;
762
762
xsl_object * intern ;
763
- zval * array_value , * entry , new_string ;
764
- zend_string * name ;
763
+ zval * zv = NULL , * entry , new_string ;
764
+
765
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "|z!" , & zv ) == FAILURE ) {
766
+ RETURN_THROWS ();
767
+ }
765
768
766
- if (zend_parse_parameters_ex ( ZEND_PARSE_PARAMS_QUIET , ZEND_NUM_ARGS (), "a" , & array_value ) == SUCCESS ) {
769
+ if (! zv ) {
767
770
intern = Z_XSL_P (id );
771
+ intern -> registerPhpFunctions = 1 ;
768
772
769
- ZEND_HASH_FOREACH_VAL (Z_ARRVAL_P (array_value ), entry ) {
770
- zend_string * str = zval_try_get_string (entry );
771
- if (UNEXPECTED (!str )) {
772
- return ;
773
- }
774
- ZVAL_LONG (& new_string , 1 );
775
- zend_hash_update (intern -> registered_phpfunctions , str , & new_string );
776
- zend_string_release (str );
777
- } ZEND_HASH_FOREACH_END ();
773
+ return ;
774
+ }
778
775
779
- intern -> registerPhpFunctions = 2 ;
780
- } else if ( zend_parse_parameters_ex ( ZEND_PARSE_PARAMS_QUIET , ZEND_NUM_ARGS (), "S" , & name ) == SUCCESS ) {
781
- intern = Z_XSL_P (id );
776
+ switch ( Z_TYPE_P ( zv )) {
777
+ case IS_ARRAY :
778
+ intern = Z_XSL_P (id );
782
779
783
- ZVAL_LONG (& new_string ,1 );
784
- zend_hash_update (intern -> registered_phpfunctions , name , & new_string );
785
- intern -> registerPhpFunctions = 2 ;
780
+ ZEND_HASH_FOREACH_VAL (Z_ARRVAL_P (zv ), entry ) {
781
+ zend_string * str = zval_try_get_string (entry );
782
+ if (UNEXPECTED (!str )) {
783
+ return ;
784
+ }
785
+ ZVAL_LONG (& new_string , 1 );
786
+ zend_hash_update (intern -> registered_phpfunctions , str , & new_string );
787
+ zend_string_release (str );
788
+ } ZEND_HASH_FOREACH_END ();
786
789
787
- } else if (zend_parse_parameters_none () == SUCCESS ) {
788
- intern = Z_XSL_P (id );
789
- intern -> registerPhpFunctions = 1 ;
790
+ intern -> registerPhpFunctions = 2 ;
791
+ break ;
792
+
793
+ case IS_STRING :
794
+ intern = Z_XSL_P (id );
795
+
796
+ ZVAL_LONG (& new_string , 1 );
797
+ zend_hash_update (intern -> registered_phpfunctions , Z_STR_P (zv ), & new_string );
798
+ intern -> registerPhpFunctions = 2 ;
799
+ break ;
800
+
801
+ default :
802
+ zend_argument_type_error (1 , "must be of type string|array|null, %s given" , zend_zval_type_name (zv ));
790
803
}
791
804
}
792
805
/* }}} end XSLTProcessor::registerPHPFunctions(); */
0 commit comments