|
28 | 28 | #include "ext/standard/php_string.h" |
29 | 29 | #include "ext/pcre/php_pcre.h" |
30 | 30 | #include "ext/standard/php_filestat.h" |
| 31 | +#if PHP_VERSION_ID >= 70200 |
| 32 | +#include "zend_interfaces.h" |
| 33 | +#elif defined(HAVE_SPL) |
| 34 | +#include "ext/spl/spl_iterators.h" |
| 35 | +#endif |
31 | 36 | #include "php_zip.h" |
32 | 37 |
|
33 | 38 | /* zip_open is a macro for renaming libzip zipopen, so we need to use PHP_NAMED_FUNCTION */ |
@@ -1548,6 +1553,23 @@ static ZIPARCHIVE_METHOD(close) |
1548 | 1553 | } |
1549 | 1554 | /* }}} */ |
1550 | 1555 |
|
| 1556 | +/* {{{ proto bool ZipArchive::count() |
| 1557 | +close the zip archive */ |
| 1558 | +static ZIPARCHIVE_METHOD(count) |
| 1559 | +{ |
| 1560 | + struct zip *intern; |
| 1561 | + zval *self = getThis(); |
| 1562 | + |
| 1563 | + if (!self) { |
| 1564 | + RETURN_FALSE; |
| 1565 | + } |
| 1566 | + |
| 1567 | + ZIP_FROM_OBJECT(intern, self); |
| 1568 | + |
| 1569 | + RETVAL_LONG(zip_get_num_files(intern)); |
| 1570 | +} |
| 1571 | +/* }}} */ |
| 1572 | + |
1551 | 1573 | /* {{{ proto string ZipArchive::getStatusString() |
1552 | 1574 | * Returns the status error message, system and/or zip messages */ |
1553 | 1575 | static ZIPARCHIVE_METHOD(getStatusString) |
@@ -3069,6 +3091,7 @@ static const zend_function_entry zip_class_functions[] = { |
3069 | 3091 | ZIPARCHIVE_ME(open, arginfo_ziparchive_open, ZEND_ACC_PUBLIC) |
3070 | 3092 | ZIPARCHIVE_ME(setPassword, arginfo_ziparchive_setpassword, ZEND_ACC_PUBLIC) |
3071 | 3093 | ZIPARCHIVE_ME(close, arginfo_ziparchive__void, ZEND_ACC_PUBLIC) |
| 3094 | + ZIPARCHIVE_ME(count, arginfo_ziparchive__void, ZEND_ACC_PUBLIC) |
3072 | 3095 | ZIPARCHIVE_ME(getStatusString, arginfo_ziparchive__void, ZEND_ACC_PUBLIC) |
3073 | 3096 | ZIPARCHIVE_ME(addEmptyDir, arginfo_ziparchive_addemptydir, ZEND_ACC_PUBLIC) |
3074 | 3097 | ZIPARCHIVE_ME(addFromString, arginfo_ziparchive_addfromstring, ZEND_ACC_PUBLIC) |
@@ -3141,6 +3164,11 @@ static PHP_MINIT_FUNCTION(zip) |
3141 | 3164 | php_zip_register_prop_handler(&zip_prop_handlers, "numFiles", php_zip_get_num_files, NULL, NULL, IS_LONG); |
3142 | 3165 | php_zip_register_prop_handler(&zip_prop_handlers, "filename", NULL, NULL, php_zipobj_get_filename, IS_STRING); |
3143 | 3166 | php_zip_register_prop_handler(&zip_prop_handlers, "comment", NULL, php_zipobj_get_zip_comment, NULL, IS_STRING); |
| 3167 | +#if PHP_VERSION_ID >= 70200 |
| 3168 | + zend_class_implements(zip_class_entry, 1, zend_ce_countable); |
| 3169 | +#elif defined(HAVE_SPL) |
| 3170 | + zend_class_implements(zip_class_entry, 1, spl_ce_Countable); |
| 3171 | +#endif |
3144 | 3172 |
|
3145 | 3173 | REGISTER_ZIP_CLASS_CONST_LONG("CREATE", ZIP_CREATE); |
3146 | 3174 | REGISTER_ZIP_CLASS_CONST_LONG("EXCL", ZIP_EXCL); |
|
0 commit comments