File tree Expand file tree Collapse file tree 2 files changed +24
-15
lines changed Expand file tree Collapse file tree 2 files changed +24
-15
lines changed Original file line number Diff line number Diff line change @@ -2448,23 +2448,24 @@ PHP_FUNCTION(extract)
2448
2448
extract_type &= 0xff ;
2449
2449
2450
2450
if (extract_type < EXTR_OVERWRITE || extract_type > EXTR_IF_EXISTS ) {
2451
- php_error_docref (NULL , E_WARNING , "Invalid extract type" );
2451
+ zend_throw_error (NULL , "Invalid extract type" );
2452
2452
return ;
2453
2453
}
2454
2454
2455
2455
if (extract_type > EXTR_SKIP && extract_type <= EXTR_PREFIX_IF_EXISTS && ZEND_NUM_ARGS () < 3 ) {
2456
- php_error_docref (NULL , E_WARNING , "specified extract type requires the prefix parameter" );
2456
+ zend_throw_error (NULL , "specified extract type requires the prefix parameter" );
2457
2457
return ;
2458
2458
}
2459
2459
2460
2460
if (prefix ) {
2461
2461
if (ZSTR_LEN (prefix ) && !php_valid_var_name (ZSTR_VAL (prefix ), ZSTR_LEN (prefix ))) {
2462
- php_error_docref (NULL , E_WARNING , "prefix is not a valid identifier" );
2462
+ zend_throw_error (NULL , "prefix is not a valid identifier" );
2463
2463
return ;
2464
2464
}
2465
2465
}
2466
2466
2467
2467
if (zend_forbid_dynamic_call ("extract()" ) == FAILURE ) {
2468
+ /* TODO Elevate to exception ? */
2468
2469
return ;
2469
2470
}
2470
2471
Original file line number Diff line number Diff line change @@ -8,25 +8,33 @@ echo "*** Testing Error Conditions ***\n";
8
8
9
9
/* Invalid second argument ( only 0-6 is valid) */
10
10
$ arr = array (1 );
11
- var_dump ( extract ($ arr , -1 . "wddr " ) );
12
- var_dump ( extract ($ arr , 7 , "wddr " ) );
11
+
12
+ try {
13
+ var_dump ( extract ($ arr , -1 . "wddr " ) );
14
+ } catch (\Error $ e ) {
15
+ echo $ e ->getMessage () . "\n" ;
16
+ }
17
+
18
+ try {
19
+ var_dump ( extract ($ arr , 7 , "wddr " ) );
20
+ } catch (\Error $ e ) {
21
+ echo $ e ->getMessage () . "\n" ;
22
+ }
13
23
14
24
/* Two Arguments, second as prefix but without prefix string as third argument */
15
- var_dump ( extract ($ arr ,EXTR_PREFIX_IF_EXISTS ) );
25
+ try {
26
+ var_dump ( extract ($ arr ,EXTR_PREFIX_IF_EXISTS ) );
27
+ } catch (\Error $ e ) {
28
+ echo $ e ->getMessage () . "\n" ;
29
+ }
16
30
17
31
echo "Done \n" ;
18
32
?>
19
33
--EXPECTF--
20
34
*** Testing Error Conditions ***
21
35
22
36
Notice: A non well formed numeric value encountered in %s on line %d
23
-
24
- Warning: extract(): Invalid extract type in %s on line %d
25
- NULL
26
-
27
- Warning: extract(): Invalid extract type in %s on line %d
28
- NULL
29
-
30
- Warning: extract(): specified extract type requires the prefix parameter in %s on line %d
31
- NULL
37
+ Invalid extract type
38
+ Invalid extract type
39
+ specified extract type requires the prefix parameter
32
40
Done
You can’t perform that action at this time.
0 commit comments