@@ -131,18 +131,16 @@ static inline spl_recursive_it_object *spl_recursive_it_from_obj(zend_object *ob
131
131
do { \
132
132
spl_dual_it_object *it = Z_SPLDUAL_IT_P(objzval); \
133
133
if (it->dit_type == DIT_Unknown) { \
134
- zend_throw_exception_ex(spl_ce_LogicException, 0, \
135
- "The object is in an invalid state as the parent constructor was not called"); \
136
- RETURN_THROWS(); \
134
+ zend_throw_error(NULL, "The object is in an invalid state as the parent constructor was not called"); \
135
+ RETURN_THROWS(); \
137
136
} \
138
137
(var) = it; \
139
138
} while (0)
140
139
141
140
#define SPL_FETCH_SUB_ELEMENT (var , object , element ) \
142
141
do { \
143
142
if(!(object)->iterators) { \
144
- zend_throw_exception_ex(spl_ce_LogicException, 0, \
145
- "The object is in an invalid state as the parent constructor was not called"); \
143
+ zend_throw_error(NULL, "The object is in an invalid state as the parent constructor was not called"); \
146
144
return; \
147
145
} \
148
146
(var) = (object)->iterators[(object)->level].element; \
@@ -151,8 +149,7 @@ static inline spl_recursive_it_object *spl_recursive_it_from_obj(zend_object *ob
151
149
#define SPL_FETCH_SUB_ELEMENT_ADDR (var , object , element ) \
152
150
do { \
153
151
if(!(object)->iterators) { \
154
- zend_throw_exception_ex(spl_ce_LogicException, 0, \
155
- "The object is in an invalid state as the parent constructor was not called"); \
152
+ zend_throw_error(NULL, "The object is in an invalid state as the parent constructor was not called"); \
156
153
RETURN_THROWS(); \
157
154
} \
158
155
(var) = &(object)->iterators[(object)->level].element; \
@@ -258,7 +255,7 @@ static void spl_recursive_it_move_forward_ex(spl_recursive_it_object *object, zv
258
255
break ;
259
256
}
260
257
object -> iterators [object -> level ].state = RS_TEST ;
261
- /* break; */
258
+ /* break; */ // wat?
262
259
case RS_TEST :
263
260
ce = object -> iterators [object -> level ].ce ;
264
261
zobject = & object -> iterators [object -> level ].zobject ;
@@ -343,8 +340,9 @@ static void spl_recursive_it_move_forward_ex(spl_recursive_it_object *object, zv
343
340
344
341
if (Z_TYPE (child ) == IS_UNDEF || Z_TYPE (child ) != IS_OBJECT ||
345
342
!((ce = Z_OBJCE (child )) && instanceof_function (ce , spl_ce_RecursiveIterator ))) {
343
+ zend_type_error ("Return value of RecursiveIterator::getChildren() must be of type RecursiveIterator, %s returned" ,
344
+ zend_zval_type_name (& child ));
346
345
zval_ptr_dtor (& child );
347
- zend_throw_exception (spl_ce_UnexpectedValueException , "Objects returned by RecursiveIterator::getChildren() must implement RecursiveIterator" , 0 );
348
346
return ;
349
347
}
350
348
@@ -453,13 +451,13 @@ static zend_object_iterator *spl_recursive_it_get_iterator(zend_class_entry *ce,
453
451
spl_recursive_it_object * object ;
454
452
455
453
if (by_ref ) {
456
- zend_throw_exception ( spl_ce_RuntimeException , "An iterator cannot be used with foreach by reference" , 0 );
454
+ zend_throw_error ( NULL , "An iterator cannot be used with foreach by reference" );
457
455
return NULL ;
458
456
}
459
457
iterator = emalloc (sizeof (spl_recursive_it_iterator ));
460
458
object = Z_SPLRECURSIVE_IT_P (zobject );
461
459
if (object -> iterators == NULL ) {
462
- zend_error ( E_ERROR , "The object to be iterated is in an invalid state: "
460
+ zend_throw_error ( NULL , "The object to be iterated is in an invalid state: "
463
461
"the parent constructor has not been called" );
464
462
}
465
463
@@ -529,7 +527,7 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla
529
527
if (iterator ) {
530
528
zval_ptr_dtor (iterator );
531
529
}
532
- zend_throw_exception ( spl_ce_InvalidArgumentException , "An instance of RecursiveIterator or IteratorAggregate creating it is required" , 0 );
530
+ zend_throw_error ( NULL , "An instance of RecursiveIterator or IteratorAggregate creating it is required" );
533
531
zend_restore_error_handling (& error_handling );
534
532
return ;
535
533
}
@@ -708,8 +706,7 @@ SPL_METHOD(RecursiveIteratorIterator, getSubIterator)
708
706
}
709
707
710
708
if (!object -> iterators ) {
711
- zend_throw_exception_ex (spl_ce_LogicException , 0 ,
712
- "The object is in an invalid state as the parent constructor was not called" );
709
+ zend_throw_error (NULL , "The object is in an invalid state as the parent constructor was not called" );
713
710
RETURN_THROWS ();
714
711
}
715
712
@@ -848,7 +845,7 @@ SPL_METHOD(RecursiveIteratorIterator, setMaxDepth)
848
845
RETURN_THROWS ();
849
846
}
850
847
if (max_depth < -1 ) {
851
- zend_value_error ( "Parameter max_depth must be greater or equal than -1" );
848
+ zend_argument_value_error ( 1 , " must be greater or equal than -1" );
852
849
RETURN_THROWS ();
853
850
} else if (max_depth > INT_MAX ) {
854
851
max_depth = INT_MAX ;
@@ -882,7 +879,8 @@ static zend_function *spl_recursive_it_get_method(zend_object **zobject, zend_st
882
879
zval * zobj ;
883
880
884
881
if (!object -> iterators ) {
885
- php_error_docref (NULL , E_ERROR , "The %s instance wasn't initialized properly" , ZSTR_VAL ((* zobject )-> ce -> name ));
882
+ zend_throw_error (NULL , "The %s instance wasn't initialized properly" ,
883
+ ZSTR_VAL ((* zobject )-> ce -> name ));
886
884
}
887
885
zobj = & object -> iterators [level ].zobject ;
888
886
@@ -1084,7 +1082,7 @@ SPL_METHOD(RecursiveTreeIterator, setPrefixPart)
1084
1082
}
1085
1083
1086
1084
if (0 > part || part > 5 ) {
1087
- zend_value_error ( "Use RecursiveTreeIterator::PREFIX_* constant " );
1085
+ zend_argument_value_error ( 2 , "must be one of RecursiveTreeIterator::PREFIX_*" );
1088
1086
RETURN_THROWS ();
1089
1087
}
1090
1088
@@ -1103,7 +1101,7 @@ SPL_METHOD(RecursiveTreeIterator, getPrefix)
1103
1101
}
1104
1102
1105
1103
if (!object -> iterators ) {
1106
- zend_throw_exception_ex ( spl_ce_LogicException , 0 ,
1104
+ zend_throw_error ( NULL ,
1107
1105
"The object is in an invalid state as the parent constructor was not called" );
1108
1106
RETURN_THROWS ();
1109
1107
}
@@ -1138,7 +1136,7 @@ SPL_METHOD(RecursiveTreeIterator, getEntry)
1138
1136
}
1139
1137
1140
1138
if (!object -> iterators ) {
1141
- zend_throw_exception_ex ( spl_ce_LogicException , 0 ,
1139
+ zend_throw_error ( NULL ,
1142
1140
"The object is in an invalid state as the parent constructor was not called" );
1143
1141
RETURN_THROWS ();
1144
1142
}
@@ -1157,7 +1155,7 @@ SPL_METHOD(RecursiveTreeIterator, getPostfix)
1157
1155
}
1158
1156
1159
1157
if (!object -> iterators ) {
1160
- zend_throw_exception_ex ( spl_ce_LogicException , 0 ,
1158
+ zend_throw_error ( NULL ,
1161
1159
"The object is in an invalid state as the parent constructor was not called" );
1162
1160
RETURN_THROWS ();
1163
1161
}
@@ -1179,7 +1177,7 @@ SPL_METHOD(RecursiveTreeIterator, current)
1179
1177
}
1180
1178
1181
1179
if (!object -> iterators ) {
1182
- zend_throw_exception_ex ( spl_ce_LogicException , 0 ,
1180
+ zend_throw_error ( NULL ,
1183
1181
"The object is in an invalid state as the parent constructor was not called" );
1184
1182
RETURN_THROWS ();
1185
1183
}
@@ -1325,7 +1323,7 @@ static zend_function *spl_dual_it_get_method(zend_object **object, zend_string *
1325
1323
1326
1324
#define SPL_CHECK_CTOR (intern , classname ) \
1327
1325
if (intern->dit_type == DIT_Unknown) { \
1328
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 , "Classes derived from %s must call %s::__construct()", \
1326
+ zend_throw_error(NULL , "Classes derived from %s must call %s::__construct()", \
1329
1327
ZSTR_VAL((spl_ce_##classname)->name), ZSTR_VAL((spl_ce_##classname)->name)); \
1330
1328
RETURN_THROWS(); \
1331
1329
}
@@ -1357,7 +1355,8 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
1357
1355
intern = Z_SPLDUAL_IT_P (ZEND_THIS );
1358
1356
1359
1357
if (intern -> dit_type != DIT_Unknown ) {
1360
- zend_throw_exception_ex (spl_ce_BadMethodCallException , 0 , "%s::getIterator() must be called exactly once per instance" , ZSTR_VAL (ce_base -> name ));
1358
+ zend_throw_error (NULL , "%s::getIterator() must be called exactly once per instance" ,
1359
+ ZSTR_VAL (ce_base -> name ));
1361
1360
return NULL ;
1362
1361
}
1363
1362
@@ -1370,11 +1369,11 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
1370
1369
return NULL ;
1371
1370
}
1372
1371
if (intern -> u .limit .offset < 0 ) {
1373
- zend_value_error ( "Parameter offset must be >= 0" );
1372
+ zend_argument_value_error ( 1 , " must be greater or equal to 0" );
1374
1373
return NULL ;
1375
1374
}
1376
1375
if (intern -> u .limit .count < 0 && intern -> u .limit .count != -1 ) {
1377
- zend_value_error ( "Parameter count must either be -1 or a value greater than or equal 0" );
1376
+ zend_argument_value_error ( 2 , " must be greater or equal to 0" );
1378
1377
return NULL ;
1379
1378
}
1380
1379
break ;
@@ -1386,7 +1385,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
1386
1385
return NULL ;
1387
1386
}
1388
1387
if (spl_cit_check_flags (flags ) != SUCCESS ) {
1389
- zend_value_error ( "Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER" );
1388
+ zend_argument_value_error ( 2 , " must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER" );
1390
1389
return NULL ;
1391
1390
}
1392
1391
intern -> u .caching .flags |= flags & CIT_PUBLIC ;
@@ -1407,7 +1406,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
1407
1406
|| !instanceof_function (ce , ce_cast )
1408
1407
|| !ce_cast -> get_iterator
1409
1408
) {
1410
- zend_type_error ( "Class to downcast to not found or not base class or does not implement Traversable" );
1409
+ zend_argument_type_error ( 1 , "Class to downcast to not found or not base class or does not implement Traversable" );
1411
1410
return NULL ;
1412
1411
}
1413
1412
ce = ce_cast ;
@@ -1419,7 +1418,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
1419
1418
return NULL ;
1420
1419
}
1421
1420
if (Z_TYPE (retval ) != IS_OBJECT || !instanceof_function (Z_OBJCE (retval ), zend_ce_traversable )) {
1422
- zend_type_error ("%s::getIterator() must return an object that implements Traversable" , ZSTR_VAL (ce -> name ));
1421
+ zend_type_error ("Return value of %s::getIterator() must be Traversable" , ZSTR_VAL (ce -> name ));
1423
1422
return NULL ;
1424
1423
}
1425
1424
zobject = & retval ;
@@ -1451,7 +1450,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
1451
1450
return NULL ;
1452
1451
}
1453
1452
if (mode < 0 || mode >= REGIT_MODE_MAX ) {
1454
- zend_value_error ( "Illegal mode " ZEND_LONG_FMT , mode );
1453
+ zend_argument_value_error ( 3 , "is illegal" );
1455
1454
return NULL ;
1456
1455
}
1457
1456
intern -> u .regex .mode = mode ;
@@ -2331,11 +2330,11 @@ static inline void spl_limit_it_seek(spl_dual_it_object *intern, zend_long pos)
2331
2330
2332
2331
spl_dual_it_free (intern );
2333
2332
if (pos < intern -> u .limit .offset ) {
2334
- zend_throw_exception_ex ( spl_ce_OutOfBoundsException , 0 , "Cannot seek to " ZEND_LONG_FMT " which is below the offset " ZEND_LONG_FMT , pos , intern -> u . limit . offset );
2333
+ zend_value_error ( "Seek position is out of bounds" );
2335
2334
return ;
2336
2335
}
2337
2336
if (pos >= intern -> u .limit .offset + intern -> u .limit .count && intern -> u .limit .count != -1 ) {
2338
- zend_throw_exception_ex ( spl_ce_OutOfBoundsException , 0 , "Cannot seek to " ZEND_LONG_FMT " which is behind offset " ZEND_LONG_FMT " plus count " ZEND_LONG_FMT , pos , intern -> u . limit . offset , intern -> u . limit . count );
2337
+ zend_value_error ( "Seek position is out of bounds" );
2339
2338
return ;
2340
2339
}
2341
2340
if (pos != intern -> current .pos && instanceof_function (intern -> inner .ce , spl_ce_SeekableIterator )) {
@@ -2637,6 +2636,7 @@ SPL_METHOD(CachingIterator, __toString)
2637
2636
SPL_FETCH_AND_CHECK_DUAL_IT (intern , ZEND_THIS );
2638
2637
2639
2638
if (!(intern -> u .caching .flags & (CIT_CALL_TOSTRING |CIT_TOSTRING_USE_KEY |CIT_TOSTRING_USE_CURRENT |CIT_TOSTRING_USE_INNER ))) {
2639
+ // Todo conversion
2640
2640
zend_throw_exception_ex (spl_ce_BadMethodCallException , 0 , "%s does not fetch string value (see CachingIterator::__construct)" , ZSTR_VAL (Z_OBJCE_P (ZEND_THIS )-> name ));
2641
2641
RETURN_THROWS ();
2642
2642
}
@@ -2672,6 +2672,7 @@ SPL_METHOD(CachingIterator, offsetSet)
2672
2672
SPL_FETCH_AND_CHECK_DUAL_IT (intern , ZEND_THIS );
2673
2673
2674
2674
if (!(intern -> u .caching .flags & CIT_FULL_CACHE )) {
2675
+ // Todo convert to standard exception
2675
2676
zend_throw_exception_ex (spl_ce_BadMethodCallException , 0 , "%s does not use a full cache (see CachingIterator::__construct)" , ZSTR_VAL (Z_OBJCE_P (ZEND_THIS )-> name ));
2676
2677
RETURN_THROWS ();
2677
2678
}
@@ -2696,6 +2697,7 @@ SPL_METHOD(CachingIterator, offsetGet)
2696
2697
SPL_FETCH_AND_CHECK_DUAL_IT (intern , ZEND_THIS );
2697
2698
2698
2699
if (!(intern -> u .caching .flags & CIT_FULL_CACHE )) {
2700
+ // Todo convert to standard exception
2699
2701
zend_throw_exception_ex (spl_ce_BadMethodCallException , 0 , "%s does not use a full cache (see CachingIterator::__construct)" , ZSTR_VAL (Z_OBJCE_P (ZEND_THIS )-> name ));
2700
2702
RETURN_THROWS ();
2701
2703
}
@@ -2723,6 +2725,7 @@ SPL_METHOD(CachingIterator, offsetUnset)
2723
2725
}
2724
2726
2725
2727
if (!(intern -> u .caching .flags & CIT_FULL_CACHE )) {
2728
+ // Todo convert to standard exception
2726
2729
zend_throw_exception_ex (spl_ce_BadMethodCallException , 0 , "%s does not use a full cache (see CachingIterator::__construct)" , ZSTR_VAL (Z_OBJCE_P (ZEND_THIS )-> name ));
2727
2730
RETURN_THROWS ();
2728
2731
}
@@ -2745,6 +2748,7 @@ SPL_METHOD(CachingIterator, offsetExists)
2745
2748
SPL_FETCH_AND_CHECK_DUAL_IT (intern , ZEND_THIS );
2746
2749
2747
2750
if (!(intern -> u .caching .flags & CIT_FULL_CACHE )) {
2751
+ // Todo convert to standard exception
2748
2752
zend_throw_exception_ex (spl_ce_BadMethodCallException , 0 , "%s does not use a full cache (see CachingIterator::__construct)" , ZSTR_VAL (Z_OBJCE_P (ZEND_THIS )-> name ));
2749
2753
RETURN_THROWS ();
2750
2754
}
@@ -2766,6 +2770,7 @@ SPL_METHOD(CachingIterator, getCache)
2766
2770
SPL_FETCH_AND_CHECK_DUAL_IT (intern , ZEND_THIS );
2767
2771
2768
2772
if (!(intern -> u .caching .flags & CIT_FULL_CACHE )) {
2773
+ // Todo convert to standard exception
2769
2774
zend_throw_exception_ex (spl_ce_BadMethodCallException , 0 , "%s does not use a full cache (see CachingIterator::__construct)" , ZSTR_VAL (Z_OBJCE_P (ZEND_THIS )-> name ));
2770
2775
RETURN_THROWS ();
2771
2776
}
@@ -2804,15 +2809,15 @@ SPL_METHOD(CachingIterator, setFlags)
2804
2809
SPL_FETCH_AND_CHECK_DUAL_IT (intern , ZEND_THIS );
2805
2810
2806
2811
if (spl_cit_check_flags (flags ) != SUCCESS ) {
2807
- zend_value_error ( "Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER" );
2812
+ zend_argument_value_error ( 1 , " must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER" );
2808
2813
RETURN_THROWS ();
2809
2814
}
2810
2815
if ((intern -> u .caching .flags & CIT_CALL_TOSTRING ) != 0 && (flags & CIT_CALL_TOSTRING ) == 0 ) {
2811
- zend_throw_exception ( spl_ce_InvalidArgumentException , "Unsetting flag CALL_TO_STRING is not possible " , 0 );
2816
+ zend_argument_value_error ( 1 , "cannot unset flag CALL_TO_STRING" , 0 );
2812
2817
RETURN_THROWS ();
2813
2818
}
2814
2819
if ((intern -> u .caching .flags & CIT_TOSTRING_USE_INNER ) != 0 && (flags & CIT_TOSTRING_USE_INNER ) == 0 ) {
2815
- zend_throw_exception ( spl_ce_InvalidArgumentException , "Unsetting flag TOSTRING_USE_INNER is not possible " , 0 );
2820
+ zend_argument_value_error ( 1 , "cannot unset flag TOSTRING_USE_INNER" , 0 );
2816
2821
RETURN_THROWS ();
2817
2822
}
2818
2823
if ((flags & CIT_FULL_CACHE ) != 0 && (intern -> u .caching .flags & CIT_FULL_CACHE ) == 0 ) {
@@ -2836,6 +2841,7 @@ SPL_METHOD(CachingIterator, count)
2836
2841
SPL_FETCH_AND_CHECK_DUAL_IT (intern , ZEND_THIS );
2837
2842
2838
2843
if (!(intern -> u .caching .flags & CIT_FULL_CACHE )) {
2844
+ // Todo convert to standard exception
2839
2845
zend_throw_exception_ex (spl_ce_BadMethodCallException , 0 , "%s does not use a full cache (see CachingIterator::__construct)" , ZSTR_VAL (Z_OBJCE_P (ZEND_THIS )-> name ));
2840
2846
RETURN_THROWS ();
2841
2847
}
@@ -3090,7 +3096,7 @@ SPL_METHOD(EmptyIterator, key)
3090
3096
RETURN_THROWS ();
3091
3097
}
3092
3098
3093
- zend_throw_exception ( spl_ce_BadMethodCallException , "Accessing the key of an EmptyIterator" , 0 );
3099
+ zend_throw_error ( NULL , "Accessing the key of an EmptyIterator" );
3094
3100
} /* }}} */
3095
3101
3096
3102
/* {{{ proto void EmptyIterator::current()
@@ -3101,7 +3107,7 @@ SPL_METHOD(EmptyIterator, current)
3101
3107
RETURN_THROWS ();
3102
3108
}
3103
3109
3104
- zend_throw_exception ( spl_ce_BadMethodCallException , "Accessing the value of an EmptyIterator" , 0 );
3110
+ zend_throw_error ( NULL , "Accessing the value of an EmptyIterator" );
3105
3111
} /* }}} */
3106
3112
3107
3113
/* {{{ proto void EmptyIterator::next()
0 commit comments