@@ -206,7 +206,7 @@ static inline void spl_filesystem_object_get_file_name(spl_filesystem_object *in
206
206
case SPL_FS_INFO :
207
207
case SPL_FS_FILE :
208
208
if (!intern -> file_name ) {
209
- php_error_docref (NULL , E_ERROR , "Object not initialized" );
209
+ zend_throw_error (NULL , "Object not initialized" );
210
210
}
211
211
break ;
212
212
case SPL_FS_DIR :
@@ -290,7 +290,7 @@ static int spl_filesystem_file_open(spl_filesystem_object *intern, int use_inclu
290
290
if (Z_TYPE (tmp ) == IS_TRUE ) {
291
291
intern -> u .file .open_mode = NULL ;
292
292
intern -> file_name = NULL ;
293
- zend_throw_exception_ex ( spl_ce_LogicException , 0 , "Cannot use SplFileObject with directories" );
293
+ zend_throw_error ( NULL , "Cannot use SplFileObject with directories" );
294
294
return FAILURE ;
295
295
}
296
296
@@ -428,18 +428,20 @@ void spl_filesystem_info_set_filename(spl_filesystem_object *intern, char *path,
428
428
intern -> _path = estrndup (path , intern -> _path_len );
429
429
} /* }}} */
430
430
431
- static spl_filesystem_object * spl_filesystem_object_create_info (spl_filesystem_object * source , char * file_path , size_t file_path_len , int use_copy , zend_class_entry * ce , zval * return_value ) /* {{{ */
431
+ static spl_filesystem_object * spl_filesystem_object_create_info (spl_filesystem_object * source ,
432
+ char * file_path , size_t file_path_len , int use_copy , zend_class_entry * ce , zval * return_value ) /* {{{ */
432
433
{
433
434
spl_filesystem_object * intern ;
434
435
zval arg1 ;
435
436
zend_error_handling error_handling ;
436
437
437
438
if (!file_path || !file_path_len ) {
438
439
#if defined(PHP_WIN32 )
439
- zend_throw_exception_ex ( spl_ce_RuntimeException , 0 , "Cannot create SplFileInfo for empty path " );
440
+ zend_value_error ( "Path cannot be empty" );
440
441
if (file_path && !use_copy ) {
441
442
efree (file_path );
442
443
}
444
+ return NULL ;
443
445
#else
444
446
if (file_path && !use_copy ) {
445
447
efree (file_path );
@@ -714,18 +716,18 @@ void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, zend_long cto
714
716
flags |= SPL_FILE_DIR_UNIXPATHS ;
715
717
}
716
718
if (parsed == FAILURE ) {
717
- return ;
719
+ RETURN_THROWS () ;
718
720
}
719
721
720
722
if (!len ) {
721
- zend_value_error ( "Directory name must not be empty" );
723
+ zend_argument_value_error ( 1 , "cannot be empty" );
722
724
return ;
723
725
}
724
726
725
727
intern = Z_SPLFILESYSTEM_P (ZEND_THIS );
726
728
if (intern -> _path ) {
727
729
/* object is already initialized */
728
- php_error_docref (NULL , E_WARNING , "Directory object is already initialized" );
730
+ zend_throw_error (NULL , "Directory object is already initialized" );
729
731
return ;
730
732
}
731
733
intern -> flags = flags ;
@@ -850,7 +852,7 @@ SPL_METHOD(DirectoryIterator, seek)
850
852
valid = zend_is_true (& retval );
851
853
zval_ptr_dtor (& retval );
852
854
if (!valid ) {
853
- zend_value_error ( "Seek position " ZEND_LONG_FMT " is out of range" , pos );
855
+ zend_argument_value_error ( 1 , " position " ZEND_LONG_FMT " is out of range" , pos );
854
856
RETURN_THROWS ();
855
857
}
856
858
zend_call_method_with_0_params (Z_OBJ_P (ZEND_THIS ), Z_OBJCE_P (ZEND_THIS ), & intern -> u .dir .func_next , "next" , NULL );
@@ -1239,21 +1241,18 @@ SPL_METHOD(SplFileInfo, getLinkTarget)
1239
1241
spl_filesystem_object * intern = Z_SPLFILESYSTEM_P (ZEND_THIS );
1240
1242
ssize_t ret ;
1241
1243
char buff [MAXPATHLEN ];
1242
- zend_error_handling error_handling ;
1243
1244
1244
1245
if (zend_parse_parameters_none () == FAILURE ) {
1245
1246
RETURN_THROWS ();
1246
1247
}
1247
1248
1248
- zend_replace_error_handling (EH_THROW , spl_ce_RuntimeException , & error_handling );
1249
-
1250
1249
if (intern -> file_name == NULL ) {
1251
1250
spl_filesystem_object_get_file_name (intern );
1252
1251
}
1253
1252
#if defined(PHP_WIN32 ) || HAVE_SYMLINK
1254
1253
if (intern -> file_name == NULL ) {
1255
- php_error_docref ( NULL , E_WARNING , "Empty filename " );
1256
- RETURN_FALSE ;
1254
+ zend_value_error ( "Filename cannot be empty " );
1255
+ RETURN_THROWS () ;
1257
1256
} else if (!IS_ABSOLUTE_PATH (intern -> file_name , intern -> file_name_len )) {
1258
1257
char expanded_path [MAXPATHLEN ];
1259
1258
if (!expand_filepath_with_mode (intern -> file_name , expanded_path , NULL , 0 , CWD_EXPAND )) {
@@ -1277,8 +1276,6 @@ SPL_METHOD(SplFileInfo, getLinkTarget)
1277
1276
1278
1277
RETVAL_STRINGL (buff , ret );
1279
1278
}
1280
-
1281
- zend_restore_error_handling (& error_handling );
1282
1279
}
1283
1280
/* }}} */
1284
1281
@@ -1605,7 +1602,7 @@ SPL_METHOD(GlobIterator, count)
1605
1602
RETURN_LONG (php_glob_stream_get_count (intern -> u .dir .dirp , NULL ));
1606
1603
} else {
1607
1604
/* should not happen */
1608
- php_error_docref (NULL , E_ERROR , "GlobIterator lost glob state" );
1605
+ zend_throw_error (NULL , "GlobIterator lost glob state" );
1609
1606
}
1610
1607
}
1611
1608
/* }}} */
@@ -2180,7 +2177,7 @@ static int spl_filesystem_file_read_line(zval * this_ptr, spl_filesystem_object
2180
2177
static void spl_filesystem_file_rewind (zval * this_ptr , spl_filesystem_object * intern ) /* {{{ */
2181
2178
{
2182
2179
if (!intern -> u .file .stream ) {
2183
- zend_throw_exception_ex ( spl_ce_RuntimeException , 0 , "Object not initialized" );
2180
+ zend_throw_error ( NULL , "Object not initialized" );
2184
2181
return ;
2185
2182
}
2186
2183
if (-1 == php_stream_rewind (intern -> u .file .stream )) {
@@ -2312,7 +2309,7 @@ SPL_METHOD(SplFileObject, eof)
2312
2309
}
2313
2310
2314
2311
if (!intern -> u .file .stream ) {
2315
- zend_throw_exception_ex ( spl_ce_RuntimeException , 0 , "Object not initialized" );
2312
+ zend_throw_error ( NULL , "Object not initialized" );
2316
2313
RETURN_THROWS ();
2317
2314
}
2318
2315
@@ -2350,7 +2347,7 @@ SPL_METHOD(SplFileObject, fgets)
2350
2347
}
2351
2348
2352
2349
if (!intern -> u .file .stream ) {
2353
- zend_throw_exception_ex ( spl_ce_RuntimeException , 0 , "Object not initialized" );
2350
+ zend_throw_error ( NULL , "Object not initialized" );
2354
2351
RETURN_THROWS ();
2355
2352
}
2356
2353
@@ -2371,7 +2368,7 @@ SPL_METHOD(SplFileObject, current)
2371
2368
}
2372
2369
2373
2370
if (!intern -> u .file .stream ) {
2374
- zend_throw_exception_ex ( spl_ce_RuntimeException , 0 , "Object not initialized" );
2371
+ zend_throw_error ( NULL , "Object not initialized" );
2375
2372
RETURN_THROWS ();
2376
2373
}
2377
2374
@@ -2460,7 +2457,7 @@ SPL_METHOD(SplFileObject, setMaxLineLen)
2460
2457
}
2461
2458
2462
2459
if (max_len < 0 ) {
2463
- zend_value_error ( "Maximum line length must be greater than or equal zero " );
2460
+ zend_argument_value_error ( 1 , " must be greater than or equal to 0 " );
2464
2461
RETURN_THROWS ();
2465
2462
}
2466
2463
@@ -2523,37 +2520,37 @@ SPL_METHOD(SplFileObject, fgetcsv)
2523
2520
if (zend_parse_parameters (ZEND_NUM_ARGS (), "|sss" , & delim , & d_len , & enclo , & e_len , & esc , & esc_len ) == SUCCESS ) {
2524
2521
2525
2522
if (!intern -> u .file .stream ) {
2526
- zend_throw_exception_ex ( spl_ce_RuntimeException , 0 , "Object not initialized" );
2523
+ zend_throw_error ( NULL , "Object not initialized" );
2527
2524
RETURN_THROWS ();
2528
2525
}
2529
2526
2530
2527
switch (ZEND_NUM_ARGS ())
2531
2528
{
2532
2529
case 3 :
2533
2530
if (esc_len > 1 ) {
2534
- php_error_docref ( NULL , E_WARNING , "escape must be empty or a single character" );
2535
- RETURN_FALSE ;
2531
+ zend_argument_value_error ( 3 , " must be empty or a single character" );
2532
+ RETURN_THROWS () ;
2536
2533
}
2537
2534
if (esc_len == 0 ) {
2538
2535
escape = PHP_CSV_NO_ESCAPE ;
2539
2536
} else {
2540
2537
escape = (unsigned char ) esc [0 ];
2541
2538
}
2542
- /* no break */
2539
+ /* explicit fallthrough */
2543
2540
case 2 :
2544
2541
if (e_len != 1 ) {
2545
- php_error_docref ( NULL , E_WARNING , "enclosure must be a character" );
2546
- RETURN_FALSE ;
2542
+ zend_argument_value_error ( 2 , " must be a character" );
2543
+ RETURN_THROWS () ;
2547
2544
}
2548
2545
enclosure = enclo [0 ];
2549
- /* no break */
2546
+ /* explicit fallthrough */
2550
2547
case 1 :
2551
2548
if (d_len != 1 ) {
2552
- php_error_docref ( NULL , E_WARNING , "delimiter must be a character" );
2553
- RETURN_FALSE ;
2549
+ zend_argument_value_error ( 1 , " must be a character" );
2550
+ RETURN_THROWS () ;
2554
2551
}
2555
2552
delimiter = delim [0 ];
2556
- /* no break */
2553
+ /* explicit fallthrough */
2557
2554
case 0 :
2558
2555
break ;
2559
2556
}
@@ -2586,24 +2583,24 @@ SPL_METHOD(SplFileObject, fputcsv)
2586
2583
escape = (unsigned char ) esc [0 ];
2587
2584
break ;
2588
2585
default :
2589
- php_error_docref ( NULL , E_WARNING , "escape must be empty or a single character" );
2590
- RETURN_FALSE ;
2586
+ zend_argument_value_error ( 3 , " must be empty or a single character" );
2587
+ RETURN_THROWS () ;
2591
2588
}
2592
- /* no break */
2589
+ /* explicit fallthrough */
2593
2590
case 3 :
2594
2591
if (e_len != 1 ) {
2595
- php_error_docref ( NULL , E_WARNING , "enclosure must be a character" );
2596
- RETURN_FALSE ;
2592
+ zend_argument_value_error ( 3 , " must be a character" );
2593
+ RETURN_THROWS () ;
2597
2594
}
2598
2595
enclosure = enclo [0 ];
2599
- /* no break */
2596
+ /* explicit fallthrough */
2600
2597
case 2 :
2601
2598
if (d_len != 1 ) {
2602
- php_error_docref ( NULL , E_WARNING , "delimiter must be a character" );
2603
- RETURN_FALSE ;
2599
+ zend_argument_value_error ( 2 , " must be a character" );
2600
+ RETURN_THROWS () ;
2604
2601
}
2605
2602
delimiter = delim [0 ];
2606
- /* no break */
2603
+ /* explicit fallthrough */
2607
2604
case 1 :
2608
2605
case 0 :
2609
2606
break ;
@@ -2639,24 +2636,24 @@ SPL_METHOD(SplFileObject, setCsvControl)
2639
2636
escape = (unsigned char ) esc [0 ];
2640
2637
break ;
2641
2638
default :
2642
- php_error_docref ( NULL , E_WARNING , "escape must be empty or a single character" );
2643
- RETURN_FALSE ;
2639
+ zend_argument_value_error ( 3 , " must be empty or a single character" );
2640
+ RETURN_THROWS () ;
2644
2641
}
2645
- /* no break */
2642
+ /* explicit fallthrough */
2646
2643
case 2 :
2647
2644
if (e_len != 1 ) {
2648
- php_error_docref ( NULL , E_WARNING , "enclosure must be a character" );
2649
- RETURN_FALSE ;
2645
+ zend_argument_value_error ( 2 , " must be a character" );
2646
+ RETURN_THROWS () ;
2650
2647
}
2651
2648
enclosure = enclo [0 ];
2652
- /* no break */
2649
+ /* explicit fallthrough */
2653
2650
case 1 :
2654
2651
if (d_len != 1 ) {
2655
- php_error_docref ( NULL , E_WARNING , "delimiter must be a character" );
2656
- RETURN_FALSE ;
2652
+ zend_argument_value_error ( 1 , " must be a character" );
2653
+ RETURN_THROWS () ;
2657
2654
}
2658
2655
delimiter = delim [0 ];
2659
- /* no break */
2656
+ /* explicit fallthrough */
2660
2657
case 0 :
2661
2658
break ;
2662
2659
}
@@ -2705,7 +2702,7 @@ SPL_METHOD(SplFileObject, fflush)
2705
2702
spl_filesystem_object * intern = Z_SPLFILESYSTEM_P (ZEND_THIS );
2706
2703
2707
2704
if (!intern -> u .file .stream ) {
2708
- zend_throw_exception_ex ( spl_ce_RuntimeException , 0 , "Object not initialized" );
2705
+ zend_throw_error ( NULL , "Object not initialized" );
2709
2706
RETURN_THROWS ();
2710
2707
}
2711
2708
@@ -2720,7 +2717,7 @@ SPL_METHOD(SplFileObject, ftell)
2720
2717
zend_long ret ;
2721
2718
2722
2719
if (!intern -> u .file .stream ) {
2723
- zend_throw_exception_ex ( spl_ce_RuntimeException , 0 , "Object not initialized" );
2720
+ zend_throw_error ( NULL , "Object not initialized" );
2724
2721
RETURN_THROWS ();
2725
2722
}
2726
2723
@@ -2745,7 +2742,7 @@ SPL_METHOD(SplFileObject, fseek)
2745
2742
}
2746
2743
2747
2744
if (!intern -> u .file .stream ) {
2748
- zend_throw_exception_ex ( spl_ce_RuntimeException , 0 , "Object not initialized" );
2745
+ zend_throw_error ( NULL , "Object not initialized" );
2749
2746
RETURN_THROWS ();
2750
2747
}
2751
2748
@@ -2762,7 +2759,7 @@ SPL_METHOD(SplFileObject, fgetc)
2762
2759
int result ;
2763
2760
2764
2761
if (!intern -> u .file .stream ) {
2765
- zend_throw_exception_ex ( spl_ce_RuntimeException , 0 , "Object not initialized" );
2762
+ zend_throw_error ( NULL , "Object not initialized" );
2766
2763
RETURN_THROWS ();
2767
2764
}
2768
2765
@@ -2790,7 +2787,7 @@ SPL_METHOD(SplFileObject, fpassthru)
2790
2787
spl_filesystem_object * intern = Z_SPLFILESYSTEM_P (ZEND_THIS );
2791
2788
2792
2789
if (!intern -> u .file .stream ) {
2793
- zend_throw_exception_ex ( spl_ce_RuntimeException , 0 , "Object not initialized" );
2790
+ zend_throw_error ( NULL , "Object not initialized" );
2794
2791
RETURN_THROWS ();
2795
2792
}
2796
2793
@@ -2804,7 +2801,7 @@ SPL_METHOD(SplFileObject, fscanf)
2804
2801
spl_filesystem_object * intern = Z_SPLFILESYSTEM_P (ZEND_THIS );
2805
2802
2806
2803
if (!intern -> u .file .stream ) {
2807
- zend_throw_exception_ex ( spl_ce_RuntimeException , 0 , "Object not initialized" );
2804
+ zend_throw_error ( NULL , "Object not initialized" );
2808
2805
RETURN_THROWS ();
2809
2806
}
2810
2807
@@ -2830,7 +2827,7 @@ SPL_METHOD(SplFileObject, fwrite)
2830
2827
}
2831
2828
2832
2829
if (!intern -> u .file .stream ) {
2833
- zend_throw_exception_ex ( spl_ce_RuntimeException , 0 , "Object not initialized" );
2830
+ zend_throw_error ( NULL , "Object not initialized" );
2834
2831
RETURN_THROWS ();
2835
2832
}
2836
2833
@@ -2864,13 +2861,13 @@ SPL_METHOD(SplFileObject, fread)
2864
2861
}
2865
2862
2866
2863
if (!intern -> u .file .stream ) {
2867
- zend_throw_exception_ex ( spl_ce_RuntimeException , 0 , "Object not initialized" );
2864
+ zend_throw_error ( NULL , "Object not initialized" );
2868
2865
RETURN_THROWS ();
2869
2866
}
2870
2867
2871
2868
if (length <= 0 ) {
2872
- php_error_docref ( NULL , E_WARNING , "Length parameter must be greater than 0" );
2873
- RETURN_FALSE ;
2869
+ zend_argument_value_error ( 1 , " must be greater than 0" );
2870
+ RETURN_THROWS () ;
2874
2871
}
2875
2872
2876
2873
str = php_stream_read_to_str (intern -> u .file .stream , length );
@@ -2897,7 +2894,7 @@ SPL_METHOD(SplFileObject, ftruncate)
2897
2894
}
2898
2895
2899
2896
if (!intern -> u .file .stream ) {
2900
- zend_throw_exception_ex ( spl_ce_RuntimeException , 0 , "Object not initialized" );
2897
+ zend_throw_error ( NULL , "Object not initialized" );
2901
2898
RETURN_THROWS ();
2902
2899
}
2903
2900
@@ -2920,7 +2917,7 @@ SPL_METHOD(SplFileObject, seek)
2920
2917
RETURN_THROWS ();
2921
2918
}
2922
2919
if (!intern -> u .file .stream ) {
2923
- zend_throw_exception_ex ( spl_ce_RuntimeException , 0 , "Object not initialized" );
2920
+ zend_throw_error ( NULL , "Object not initialized" );
2924
2921
RETURN_THROWS ();
2925
2922
}
2926
2923
0 commit comments