@@ -666,21 +666,35 @@ PHP_METHOD(XSLTProcessor, setParameter)
666
666
{
667
667
668
668
zval * id = ZEND_THIS ;
669
- zval * array_value , * entry , new_string ;
669
+ zval * entry , new_string ;
670
+ HashTable * array_value ;
670
671
xsl_object * intern ;
671
672
char * namespace ;
672
673
size_t namespace_len ;
673
- zend_string * string_key , * name , * value ;
674
+ zend_string * string_key , * name , * value = NULL ;
675
+
676
+ ZEND_PARSE_PARAMETERS_START (2 , 3 )
677
+ Z_PARAM_STRING (namespace , namespace_len )
678
+ Z_PARAM_STR_OR_ARRAY_HT (name , array_value )
679
+ Z_PARAM_OPTIONAL
680
+ Z_PARAM_STR_OR_NULL (value )
681
+ ZEND_PARSE_PARAMETERS_END ();
682
+
683
+ intern = Z_XSL_P (id );
684
+
685
+ if (array_value ) {
686
+ if (value ) {
687
+ zend_argument_value_error (3 , "must be null when argument #2 ($name) is an array" );
688
+ RETURN_THROWS ();
689
+ }
674
690
675
- if (zend_parse_parameters_ex (ZEND_PARSE_PARAMS_QUIET , ZEND_NUM_ARGS (), "sa" , & namespace , & namespace_len , & array_value ) == SUCCESS ) {
676
- intern = Z_XSL_P (id );
677
- ZEND_HASH_FOREACH_STR_KEY_VAL (Z_ARRVAL_P (array_value ), string_key , entry ) {
691
+ ZEND_HASH_FOREACH_STR_KEY_VAL (array_value , string_key , entry ) {
678
692
zval tmp ;
679
693
zend_string * str ;
680
694
681
695
if (string_key == NULL ) {
682
- php_error_docref ( NULL , E_WARNING , "Invalid parameter array " );
683
- RETURN_FALSE ;
696
+ zend_argument_type_error ( 2 , "must contain only string keys " );
697
+ RETURN_THROWS () ;
684
698
}
685
699
str = zval_try_get_string (entry );
686
700
if (UNEXPECTED (!str )) {
@@ -690,18 +704,17 @@ PHP_METHOD(XSLTProcessor, setParameter)
690
704
zend_hash_update (intern -> parameter , string_key , & tmp );
691
705
} ZEND_HASH_FOREACH_END ();
692
706
RETURN_TRUE ;
693
- } else if (zend_parse_parameters_ex (ZEND_PARSE_PARAMS_QUIET , ZEND_NUM_ARGS (), "sSS" , & namespace , & namespace_len , & name , & value ) == SUCCESS ) {
694
-
695
- intern = Z_XSL_P (id );
707
+ } else {
708
+ if (!value ) {
709
+ zend_argument_value_error (3 , "cannot be null when argument #2 ($name) is a string" );
710
+ RETURN_THROWS ();
711
+ }
696
712
697
713
ZVAL_STR_COPY (& new_string , value );
698
714
699
715
zend_hash_update (intern -> parameter , name , & new_string );
700
716
RETURN_TRUE ;
701
- } else {
702
- WRONG_PARAM_COUNT ;
703
717
}
704
-
705
718
}
706
719
/* }}} end XSLTProcessor::setParameter */
707
720
0 commit comments