@@ -175,7 +175,7 @@ zval *xmlreader_write_property(zend_object *object, zend_string *name, zval *val
175
175
hnd = zend_hash_find_ptr (obj -> prop_handler , name );
176
176
}
177
177
if (hnd != NULL ) {
178
- php_error_docref (NULL , E_WARNING , "Cannot write to read-only property" );
178
+ zend_throw_error (NULL , "Cannot write to read-only property" );
179
179
} else {
180
180
value = zend_std_write_property (object , name , value , cache_slot );
181
181
}
@@ -391,8 +391,8 @@ static void php_xmlreader_string_arg(INTERNAL_FUNCTION_PARAMETERS, xmlreader_rea
391
391
}
392
392
393
393
if (!name_len ) {
394
- php_error_docref ( NULL , E_WARNING , "Argument cannot be an empty string " );
395
- RETURN_FALSE ;
394
+ zend_argument_value_error ( 1 , " cannot be empty" );
395
+ RETURN_THROWS () ;
396
396
}
397
397
398
398
id = ZEND_THIS ;
@@ -480,8 +480,8 @@ static void php_xmlreader_set_relaxng_schema(INTERNAL_FUNCTION_PARAMETERS, int t
480
480
}
481
481
482
482
if (source != NULL && !source_len ) {
483
- php_error_docref ( NULL , E_WARNING , "Schema data source is required " );
484
- RETURN_FALSE ;
483
+ zend_argument_value_error ( 1 , "cannot be empty " );
484
+ RETURN_THROWS () ;
485
485
}
486
486
487
487
id = ZEND_THIS ;
@@ -506,15 +506,16 @@ static void php_xmlreader_set_relaxng_schema(INTERNAL_FUNCTION_PARAMETERS, int t
506
506
intern -> schema = schema ;
507
507
508
508
RETURN_TRUE ;
509
+ } else {
510
+ php_error_docref (NULL , E_WARNING , "Schema contains errors" );
511
+ RETURN_FALSE ;
509
512
}
513
+ } else {
514
+ zend_throw_error (NULL , "Schema must be set prior to reading" );
515
+ RETURN_THROWS ();
510
516
}
511
-
512
- php_error_docref (NULL , E_WARNING , "Unable to set schema. This must be set prior to reading or schema contains errors." );
513
-
514
- RETURN_FALSE ;
515
517
#else
516
- php_error_docref (NULL , E_WARNING , "No Schema support built into libxml." );
517
-
518
+ php_error_docref (NULL , E_WARNING , "No schema support built into libxml" );
518
519
RETURN_FALSE ;
519
520
#endif
520
521
}
@@ -585,9 +586,14 @@ PHP_METHOD(XMLReader, getAttributeNs)
585
586
RETURN_THROWS ();
586
587
}
587
588
588
- if (name_len == 0 || ns_uri_len == 0 ) {
589
- php_error_docref (NULL , E_WARNING , "Attribute Name and Namespace URI cannot be empty" );
590
- RETURN_FALSE ;
589
+ if (name_len == 0 ) {
590
+ zend_argument_value_error (1 , "cannot be empty" );
591
+ RETURN_THROWS ();
592
+ }
593
+
594
+ if (ns_uri_len == 0 ) {
595
+ zend_argument_value_error (2 , "cannot be empty" );
596
+ RETURN_THROWS ();
591
597
}
592
598
593
599
id = ZEND_THIS ;
@@ -622,8 +628,8 @@ PHP_METHOD(XMLReader, getParserProperty)
622
628
retval = xmlTextReaderGetParserProp (intern -> ptr ,property );
623
629
}
624
630
if (retval == -1 ) {
625
- php_error_docref ( NULL , E_WARNING , "Invalid parser property" );
626
- RETURN_FALSE ;
631
+ zend_argument_value_error ( 1 , "must be a valid parser property" );
632
+ RETURN_THROWS () ;
627
633
}
628
634
629
635
RETURN_BOOL (retval );
@@ -660,8 +666,8 @@ PHP_METHOD(XMLReader, moveToAttribute)
660
666
}
661
667
662
668
if (name_len == 0 ) {
663
- php_error_docref ( NULL , E_WARNING , "Attribute Name is required " );
664
- RETURN_FALSE ;
669
+ zend_argument_value_error ( 1 , "cannot be empty " );
670
+ RETURN_THROWS () ;
665
671
}
666
672
667
673
id = ZEND_THIS ;
@@ -719,9 +725,14 @@ PHP_METHOD(XMLReader, moveToAttributeNs)
719
725
RETURN_THROWS ();
720
726
}
721
727
722
- if (name_len == 0 || ns_uri_len == 0 ) {
723
- php_error_docref (NULL , E_WARNING , "Attribute Name and Namespace URI cannot be empty" );
724
- RETURN_FALSE ;
728
+ if (name_len == 0 ) {
729
+ zend_argument_value_error (1 , "cannot be empty" );
730
+ RETURN_THROWS ();
731
+ }
732
+
733
+ if (ns_uri_len == 0 ) {
734
+ zend_argument_value_error (2 , "cannot be empty" );
735
+ RETURN_THROWS ();
725
736
}
726
737
727
738
id = ZEND_THIS ;
@@ -772,17 +783,17 @@ PHP_METHOD(XMLReader, read)
772
783
773
784
id = ZEND_THIS ;
774
785
intern = Z_XMLREADER_P (id );
775
- if (intern != NULL && intern -> ptr != NULL ) {
776
- retval = xmlTextReaderRead (intern -> ptr );
777
- if (retval == -1 ) {
778
- RETURN_FALSE ;
779
- } else {
780
- RETURN_BOOL (retval );
781
- }
786
+ if (intern == NULL || intern -> ptr == NULL ) {
787
+ zend_throw_error (NULL , "Data must be loaded before reading" );
788
+ RETURN_THROWS ();
782
789
}
783
790
784
- php_error_docref (NULL , E_WARNING , "Load Data before trying to read" );
785
- RETURN_FALSE ;
791
+ retval = xmlTextReaderRead (intern -> ptr );
792
+ if (retval == -1 ) {
793
+ RETURN_FALSE ;
794
+ } else {
795
+ RETURN_BOOL (retval );
796
+ }
786
797
}
787
798
/* }}} */
788
799
@@ -816,8 +827,7 @@ PHP_METHOD(XMLReader, next)
816
827
}
817
828
}
818
829
819
- php_error_docref (NULL , E_WARNING , "Load Data before trying to read" );
820
- RETURN_FALSE ;
830
+ zend_throw_error (NULL , "Data must be loaded before reading" );
821
831
}
822
832
/* }}} */
823
833
@@ -848,8 +858,8 @@ PHP_METHOD(XMLReader, open)
848
858
}
849
859
850
860
if (!source_len ) {
851
- php_error_docref ( NULL , E_WARNING , "Empty string supplied as input " );
852
- RETURN_FALSE ;
861
+ zend_argument_value_error ( 1 , "cannot be empty " );
862
+ RETURN_THROWS () ;
853
863
}
854
864
855
865
valid_file = _xmlreader_get_valid_file_path (source , resolved_path , MAXPATHLEN );
@@ -920,8 +930,8 @@ PHP_METHOD(XMLReader, setSchema)
920
930
}
921
931
922
932
if (source != NULL && !source_len ) {
923
- php_error_docref ( NULL , E_WARNING , "Schema data source is required " );
924
- RETURN_FALSE ;
933
+ zend_argument_value_error ( 1 , "cannot be empty " );
934
+ RETURN_THROWS () ;
925
935
}
926
936
927
937
id = ZEND_THIS ;
@@ -932,15 +942,16 @@ PHP_METHOD(XMLReader, setSchema)
932
942
933
943
if (retval == 0 ) {
934
944
RETURN_TRUE ;
945
+ } else {
946
+ php_error_docref (NULL , E_WARNING , "Schema contains errors" );
947
+ RETURN_FALSE ;
935
948
}
949
+ } else {
950
+ zend_throw_error (NULL , "Schema must be set prior to reading" );
951
+ RETURN_THROWS ();
936
952
}
937
-
938
- php_error_docref (NULL , E_WARNING , "Unable to set schema. This must be set prior to reading or schema contains errors." );
939
-
940
- RETURN_FALSE ;
941
953
#else
942
- php_error_docref (NULL , E_WARNING , "No Schema support built into libxml." );
943
-
954
+ php_error_docref (NULL , E_WARNING , "No schema support built into libxml" );
944
955
RETURN_FALSE ;
945
956
#endif
946
957
}
@@ -967,8 +978,8 @@ PHP_METHOD(XMLReader, setParserProperty)
967
978
retval = xmlTextReaderSetParserProp (intern -> ptr ,property , value );
968
979
}
969
980
if (retval == -1 ) {
970
- php_error_docref ( NULL , E_WARNING , "Invalid parser property" );
971
- RETURN_FALSE ;
981
+ zend_argument_value_error ( 1 , "must be a valid parser property" );
982
+ RETURN_THROWS () ;
972
983
}
973
984
974
985
RETURN_TRUE ;
@@ -1022,8 +1033,8 @@ PHP_METHOD(XMLReader, XML)
1022
1033
}
1023
1034
1024
1035
if (!source_len ) {
1025
- php_error_docref ( NULL , E_WARNING , "Empty string supplied as input " );
1026
- RETURN_FALSE ;
1036
+ zend_argument_value_error ( 1 , "cannot be empty " );
1037
+ RETURN_THROWS () ;
1027
1038
}
1028
1039
1029
1040
inputbfr = xmlParserInputBufferCreateMem (source , source_len , XML_CHAR_ENCODING_NONE );
@@ -1105,7 +1116,7 @@ PHP_METHOD(XMLReader, expand)
1105
1116
node = xmlTextReaderExpand (intern -> ptr );
1106
1117
1107
1118
if (node == NULL ) {
1108
- php_error_docref (NULL , E_WARNING , "An Error Occurred while expanding " );
1119
+ php_error_docref (NULL , E_WARNING , "An Error Occurred while expanding" );
1109
1120
RETURN_FALSE ;
1110
1121
} else {
1111
1122
nodec = xmlDocCopyNode (node , docp , 1 );
@@ -1117,8 +1128,8 @@ PHP_METHOD(XMLReader, expand)
1117
1128
}
1118
1129
}
1119
1130
} else {
1120
- php_error_docref (NULL , E_WARNING , "Load Data before trying to expand " );
1121
- RETURN_FALSE ;
1131
+ zend_throw_error (NULL , " Data must be loaded before expanding " );
1132
+ RETURN_THROWS () ;
1122
1133
}
1123
1134
#else
1124
1135
php_error (E_WARNING , "DOM support is not enabled" );
0 commit comments