]> granicus.if.org Git - php/commitdiff
- Need to change a few things to exception based error handling
authorMarcus Boerger <helly@php.net>
Sat, 4 Mar 2006 22:56:11 +0000 (22:56 +0000)
committerMarcus Boerger <helly@php.net>
Sat, 4 Mar 2006 22:56:11 +0000 (22:56 +0000)
- Drop erroneus/useless RecursiveDirectoryIterator::getSubPathInfo()

ext/spl/spl.php
ext/spl/spl_directory.c

index 9f41df46c26906228f9f1f4e69f0cb55c1f9c329..aa37e454d95032ba3bb54ea127ff7661489d82b7 100755 (executable)
@@ -948,8 +948,8 @@ class SplFileInfo
         */
        function setFileClass(string class_name = "SplFileObject") {/**/}
 
-       /** @param class_name name of class used with getFileInfo(), getPathInfo()
-        *                    getSubPathInfo(). Must be derived from SplFileInfo.
+       /** @param class_name name of class used with getFileInfo(), getPathInfo().
+        *                     Must be derived from SplFileInfo.
         */
        function setInfoClass(string class_name = "SplFileInfo") {/**/}
 }
@@ -1041,13 +1041,6 @@ class RecursiveDirectoryIterator extends DirectoryIterator implements RecursiveI
        /** @return the current sub path
         */
        function getSubPathname() {/**/}
-
-       /** @return SplFileInfo created for the current sub path
-        * @param class_name name of class to instantiate
-        * @see SplFileInfo::setInfoClass()
-        */
-       function getSubPathInfo(string $class_name = NULL) {/**/}
-
 }
 
 /** @ingroup SPL
index e02ce2bf95110df26a73d6387b75be77957bdbb1..1f4f5891337f536eb81784dfc4d2c516434c6a22 100755 (executable)
@@ -748,26 +748,30 @@ SPL_METHOD(SplFileInfo, setFileClass)
        spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        zend_class_entry *ce = spl_ce_SplFileObject;
        
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|C", &ce) == FAILURE) {
-               return;
+       php_set_error_handling(EH_THROW, spl_ce_UnexpectedValueException TSRMLS_CC);
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|C", &ce) == SUCCESS) {
+               intern->file_class = ce;
        }
 
-       intern->file_class = ce;
+       php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
 }
 /* }}} */
 
 /* {{{ proto SplFileObject SplFileInfo::setInfoClass([string class_name])
-   Class to use in getFileInfo(), getPathInfo(), getSubPathInfo() */
+   Class to use in getFileInfo(), getPathInfo() */
 SPL_METHOD(SplFileInfo, setInfoClass)
 {
        spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        zend_class_entry *ce = spl_ce_SplFileInfo;
        
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|C", &ce) == FAILURE) {
-               return;
+       php_set_error_handling(EH_THROW, spl_ce_UnexpectedValueException TSRMLS_CC);
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|C", &ce) == SUCCESS) {
+               intern->info_class = ce;
        }
 
-       intern->info_class = ce;
+       php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
 }
 /* }}} */
 
@@ -778,11 +782,13 @@ SPL_METHOD(SplFileInfo, getFileInfo)
        spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        zend_class_entry *ce = intern->info_class;
        
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|C", &ce) == FAILURE) {
-               return;
+       php_set_error_handling(EH_THROW, spl_ce_UnexpectedValueException TSRMLS_CC);
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|C", &ce) == SUCCESS) {
+               spl_filesystem_object_create_type(ht, intern, SPL_FS_INFO, ce, return_value TSRMLS_CC);
        }
 
-       spl_filesystem_object_create_type(ht, intern, SPL_FS_INFO, ce, return_value TSRMLS_CC);
+       php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
 }
 /* }}} */
 
@@ -793,11 +799,13 @@ SPL_METHOD(SplFileInfo, getPathInfo)
        spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        zend_class_entry *ce = intern->info_class;
        
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|C", &ce) == FAILURE) {
-               return;
+       php_set_error_handling(EH_THROW, spl_ce_UnexpectedValueException TSRMLS_CC);
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|C", &ce) == SUCCESS) {
+               spl_filesystem_object_create_info(intern, intern->path, intern->path_len, 1, ce, return_value TSRMLS_CC);
        }
 
-       spl_filesystem_object_create_info(intern, intern->path, intern->path_len, 1, ce, return_value TSRMLS_CC);
+       php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
 }
 /* }}} */
 
@@ -810,7 +818,7 @@ SPL_METHOD(RecursiveDirectoryIterator, __construct)
        int len;
        long flags = SPL_FILE_DIR_CURRENT_AS_FILEINFO;
 
-       php_set_error_handling(EH_THROW, spl_ce_RuntimeException TSRMLS_CC);
+       php_set_error_handling(EH_THROW, spl_ce_UnexpectedValueException TSRMLS_CC);
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &path, &len, &flags) == FAILURE) {
                php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
@@ -950,28 +958,6 @@ SPL_METHOD(RecursiveDirectoryIterator, getSubPathname)
 }
 /* }}} */
 
-/* {{{ proto SplFileInfo RecursiveDirectoryIterator::getSubPathInfo([string $class_info])
-   Create SplFileInfo for sub path */
-SPL_METHOD(RecursiveDirectoryIterator, getSubPathInfo)
-{
-       spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
-       char *sub_name;
-       int len;
-       zend_class_entry *ce = intern->info_class;
-       
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|C", &ce) == FAILURE) {
-               return;
-       }
-
-       if (intern->u.dir.sub_path) {
-               len = spprintf(&sub_name, 0, "%s%c%s", intern->u.dir.sub_path, DEFAULT_SLASH, intern->u.dir.entry.d_name);
-               spl_filesystem_object_create_info(intern, sub_name, len, 0, ce, return_value TSRMLS_CC);
-       } else {
-               spl_filesystem_object_create_info(intern, intern->path, intern->path_len, 1, ce, return_value TSRMLS_CC);
-       }
-}
-/* }}} */
-
 /* define an overloaded iterator structure */
 typedef struct {
        zend_object_iterator  intern;
@@ -1337,7 +1323,6 @@ static zend_function_entry spl_RecursiveDirectoryIterator_functions[] = {
        SPL_ME(RecursiveDirectoryIterator, getChildren,   NULL, ZEND_ACC_PUBLIC)
        SPL_ME(RecursiveDirectoryIterator, getSubPath,    NULL, ZEND_ACC_PUBLIC)
        SPL_ME(RecursiveDirectoryIterator, getSubPathname,NULL, ZEND_ACC_PUBLIC)
-       SPL_ME(RecursiveDirectoryIterator, getSubPathInfo,arginfo_info_optinalFileClass, ZEND_ACC_PUBLIC)
        {NULL, NULL, NULL}
 };