@@ -66,27 +66,22 @@ static char **php_xsl_xslt_make_params(HashTable *parht, int xpath_params)
66
66
memset ((char * )params , 0 , parsize );
67
67
68
68
ZEND_HASH_FOREACH_STR_KEY_VAL (parht , string_key , value ) {
69
- if (string_key == NULL ) {
70
- php_error_docref (NULL , E_WARNING , "Invalid argument or parameter array" );
71
- efree (params );
72
- return NULL ;
73
- } else {
74
- if (Z_TYPE_P (value ) != IS_STRING ) {
75
- if (!try_convert_to_string (value )) {
76
- efree (params );
77
- return NULL ;
78
- }
69
+ ZEND_ASSERT (string_key != NULL );
70
+ if (Z_TYPE_P (value ) != IS_STRING ) {
71
+ if (!try_convert_to_string (value )) {
72
+ efree (params );
73
+ return NULL ;
79
74
}
75
+ }
80
76
81
- if (!xpath_params ) {
82
- xpath_expr = php_xsl_xslt_string_to_xpathexpr (Z_STRVAL_P (value ));
83
- } else {
84
- xpath_expr = estrndup (Z_STRVAL_P (value ), Z_STRLEN_P (value ));
85
- }
86
- if (xpath_expr ) {
87
- params [i ++ ] = estrndup (ZSTR_VAL (string_key ), ZSTR_LEN (string_key ));
88
- params [i ++ ] = xpath_expr ;
89
- }
77
+ if (!xpath_params ) {
78
+ xpath_expr = php_xsl_xslt_string_to_xpathexpr (Z_STRVAL_P (value ));
79
+ } else {
80
+ xpath_expr = estrndup (Z_STRVAL_P (value ), Z_STRLEN_P (value ));
81
+ }
82
+ if (xpath_expr ) {
83
+ params [i ++ ] = estrndup (ZSTR_VAL (string_key ), ZSTR_LEN (string_key ));
84
+ params [i ++ ] = xpath_expr ;
90
85
}
91
86
} ZEND_HASH_FOREACH_END ();
92
87
@@ -336,8 +331,8 @@ PHP_METHOD(XSLTProcessor, importStylesheet)
336
331
doc = nodep -> doc ;
337
332
}
338
333
if (doc == NULL ) {
339
- php_error ( E_WARNING , "Invalid Document " );
340
- RETURN_FALSE ;
334
+ zend_argument_value_error ( 1 , "must be a valid XML node " );
335
+ RETURN_THROWS () ;
341
336
}
342
337
343
338
/* libxslt uses _private, so we must copy the imported
@@ -417,13 +412,17 @@ static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStyl
417
412
if (node ) {
418
413
doc = node -> doc ;
419
414
}
415
+
420
416
if (doc == NULL ) {
421
- php_error_docref ( NULL , E_WARNING , "Invalid Document " );
417
+ zend_argument_value_error ( 1 , "must be a valid XML node " );
422
418
return NULL ;
423
419
}
424
420
425
421
if (style == NULL ) {
426
- php_error_docref (NULL , E_WARNING , "No stylesheet associated to this object" );
422
+ zend_string * name = get_active_function_or_method_name ();
423
+ zend_throw_error (NULL , "%s() can only be called after a stylesheet has been imported" ,
424
+ ZSTR_VAL (name ));
425
+ zend_string_release (name );
427
426
return NULL ;
428
427
}
429
428
0 commit comments