Skip to content

Commit 3e0b31a

Browse files
committed
Remove some unnecessary error handler setting
The exception type is going to change from UnexpectedValueException to TypeError here.
1 parent f67dc49 commit 3e0b31a

File tree

1 file changed

+20
-31
lines changed

1 file changed

+20
-31
lines changed

ext/spl/spl_directory.c

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,15 +1344,12 @@ SPL_METHOD(SplFileInfo, setFileClass)
13441344
{
13451345
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
13461346
zend_class_entry *ce = spl_ce_SplFileObject;
1347-
zend_error_handling error_handling;
1348-
1349-
zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling);
13501347

1351-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|C", &ce) == SUCCESS) {
1352-
intern->file_class = ce;
1348+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|C", &ce) == FAILURE) {
1349+
return;
13531350
}
13541351

1355-
zend_restore_error_handling(&error_handling);
1352+
intern->file_class = ce;
13561353
}
13571354
/* }}} */
13581355

@@ -1362,15 +1359,12 @@ SPL_METHOD(SplFileInfo, setInfoClass)
13621359
{
13631360
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
13641361
zend_class_entry *ce = spl_ce_SplFileInfo;
1365-
zend_error_handling error_handling;
13661362

1367-
zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling );
1368-
1369-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|C", &ce) == SUCCESS) {
1370-
intern->info_class = ce;
1363+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|C", &ce) == FAILURE) {
1364+
return;
13711365
}
13721366

1373-
zend_restore_error_handling(&error_handling);
1367+
intern->info_class = ce;
13741368
}
13751369
/* }}} */
13761370

@@ -1380,15 +1374,12 @@ SPL_METHOD(SplFileInfo, getFileInfo)
13801374
{
13811375
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
13821376
zend_class_entry *ce = intern->info_class;
1383-
zend_error_handling error_handling;
1384-
1385-
zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling);
13861377

1387-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|C", &ce) == SUCCESS) {
1388-
spl_filesystem_object_create_type(ZEND_NUM_ARGS(), intern, SPL_FS_INFO, ce, return_value);
1378+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|C", &ce) == FAILURE) {
1379+
return;
13891380
}
13901381

1391-
zend_restore_error_handling(&error_handling);
1382+
spl_filesystem_object_create_type(ZEND_NUM_ARGS(), intern, SPL_FS_INFO, ce, return_value);
13921383
}
13931384
/* }}} */
13941385

@@ -1398,22 +1389,20 @@ SPL_METHOD(SplFileInfo, getPathInfo)
13981389
{
13991390
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
14001391
zend_class_entry *ce = intern->info_class;
1401-
zend_error_handling error_handling;
1402-
1403-
zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling);
1392+
size_t path_len;
1393+
char *path;
14041394

1405-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|C", &ce) == SUCCESS) {
1406-
size_t path_len;
1407-
char *path = spl_filesystem_object_get_pathname(intern, &path_len);
1408-
if (path) {
1409-
char *dpath = estrndup(path, path_len);
1410-
path_len = php_dirname(dpath, path_len);
1411-
spl_filesystem_object_create_info(intern, dpath, path_len, 1, ce, return_value);
1412-
efree(dpath);
1413-
}
1395+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|C", &ce) == FAILURE) {
1396+
return;
14141397
}
14151398

1416-
zend_restore_error_handling(&error_handling);
1399+
path = spl_filesystem_object_get_pathname(intern, &path_len);
1400+
if (path) {
1401+
char *dpath = estrndup(path, path_len);
1402+
path_len = php_dirname(dpath, path_len);
1403+
spl_filesystem_object_create_info(intern, dpath, path_len, 1, ce, return_value);
1404+
efree(dpath);
1405+
}
14171406
}
14181407
/* }}} */
14191408

0 commit comments

Comments
 (0)