@@ -472,19 +472,14 @@ static void spl_filesystem_info_set_filename(spl_filesystem_object *intern, zend
472
472
intern -> path = zend_string_init (ZSTR_VAL (path ), path_len , 0 );
473
473
} /* }}} */
474
474
475
- static spl_filesystem_object * spl_filesystem_object_create_info (spl_filesystem_object * source , zend_string * file_path , zend_class_entry * ce , zval * return_value ) /* {{{ */
475
+ // TODO Do not pass return_value pointer but actually use value returned by function at call site?
476
+ static spl_filesystem_object * spl_filesystem_object_create_info (zend_string * file_path , zend_class_entry * ce , zval * return_value ) /* {{{ */
476
477
{
477
478
spl_filesystem_object * intern ;
478
479
zval arg1 ;
479
480
480
- if (!file_path || !ZSTR_LEN (file_path )) {
481
- #ifdef PHP_WIN32
482
- zend_throw_exception_ex (spl_ce_RuntimeException , 0 , "Cannot create SplFileInfo for empty path" );
483
- #endif
484
- return NULL ;
485
- }
486
-
487
- ce = ce ? ce : source -> info_class ;
481
+ ZEND_ASSERT (file_path && ZSTR_LEN (file_path ) > 0 );
482
+ ZEND_ASSERT (ce != NULL );
488
483
489
484
intern = spl_filesystem_from_obj (spl_filesystem_object_new_ex (ce ));
490
485
RETVAL_OBJ (& intern -> std );
@@ -1383,18 +1378,22 @@ PHP_METHOD(SplFileInfo, getFileInfo)
1383
1378
PHP_METHOD (SplFileInfo , getPathInfo )
1384
1379
{
1385
1380
spl_filesystem_object * intern = spl_filesystem_from_obj (Z_OBJ_P (ZEND_THIS ));
1386
- zend_class_entry * ce = intern -> info_class ;
1381
+ zend_class_entry * ce = NULL ;
1387
1382
zend_string * path ;
1388
1383
1389
1384
if (zend_parse_parameters (ZEND_NUM_ARGS (), "|C!" , & ce ) == FAILURE ) {
1390
1385
RETURN_THROWS ();
1391
1386
}
1392
1387
1388
+ if (ce == NULL ) {
1389
+ ce = intern -> info_class ;
1390
+ }
1391
+
1393
1392
path = spl_filesystem_object_get_pathname (intern );
1394
1393
if (path && ZSTR_LEN (path )) {
1395
1394
zend_string * dpath = zend_string_init (ZSTR_VAL (path ), ZSTR_LEN (path ), 0 );
1396
1395
ZSTR_LEN (dpath ) = php_dirname (ZSTR_VAL (dpath ), ZSTR_LEN (path ));
1397
- spl_filesystem_object_create_info (intern , dpath , ce , return_value );
1396
+ spl_filesystem_object_create_info (dpath , ce , return_value );
1398
1397
zend_string_release (dpath );
1399
1398
}
1400
1399
}
0 commit comments