summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/com_dotnet/com_persist.c50
-rw-r--r--ext/com_dotnet/com_persist.stub.php21
-rw-r--r--ext/com_dotnet/com_persist_arginfo.h30
3 files changed, 82 insertions, 19 deletions
diff --git a/ext/com_dotnet/com_persist.c b/ext/com_dotnet/com_persist.c
index 656215dd1a..f9eb36f105 100644
--- a/ext/com_dotnet/com_persist.c
+++ b/ext/com_dotnet/com_persist.c
@@ -29,6 +29,7 @@
#include "php_com_dotnet.h"
#include "php_com_dotnet_internal.h"
#include "Zend/zend_exceptions.h"
+#include "com_persist_arginfo.h"
/* {{{ expose php_stream as a COM IStream */
@@ -336,6 +337,10 @@ CPH_METHOD(GetCurFileName)
OLECHAR *olename = NULL;
CPH_FETCH();
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
+
CPH_NO_OBJ();
res = get_persist_file(helper);
@@ -374,15 +379,15 @@ CPH_METHOD(SaveToFile)
OLECHAR *olefilename = NULL;
CPH_FETCH();
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "p!|b",
+ &filename, &filename_len, &remember)) {
+ RETURN_THROWS();
+ }
+
CPH_NO_OBJ();
res = get_persist_file(helper);
if (helper->ipf) {
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "p!|b",
- &filename, &filename_len, &remember)) {
- RETURN_THROWS();
- }
-
if (filename) {
fullpath = expand_filepath(filename, NULL);
if (!fullpath) {
@@ -436,16 +441,15 @@ CPH_METHOD(LoadFromFile)
OLECHAR *olefilename;
CPH_FETCH();
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "p|l",
+ &filename, &filename_len, &flags)) {
+ RETURN_THROWS();
+ }
+
CPH_NO_OBJ();
res = get_persist_file(helper);
if (helper->ipf) {
-
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "p|l",
- &filename, &filename_len, &flags)) {
- RETURN_THROWS();
- }
-
if (!(fullpath = expand_filepath(filename, NULL))) {
RETURN_FALSE;
}
@@ -479,6 +483,10 @@ CPH_METHOD(GetMaxStreamSize)
ULARGE_INTEGER size;
CPH_FETCH();
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
+
CPH_NO_OBJ();
res = get_persist_stream_init(helper);
@@ -510,6 +518,10 @@ CPH_METHOD(InitNew)
HRESULT res;
CPH_FETCH();
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
+
CPH_NO_OBJ();
res = get_persist_stream_init(helper);
@@ -671,14 +683,14 @@ CPH_METHOD(__construct)
static const zend_function_entry com_persist_helper_methods[] = {
- CPH_ME(__construct, NULL)
- CPH_ME(GetCurFileName, NULL)
- CPH_ME(SaveToFile, NULL)
- CPH_ME(LoadFromFile, NULL)
- CPH_ME(GetMaxStreamSize, NULL)
- CPH_ME(InitNew, NULL)
- CPH_ME(LoadFromStream, NULL)
- CPH_ME(SaveToStream, NULL)
+ CPH_ME(__construct, arginfo_class_COMPersistHelper___construct)
+ CPH_ME(GetCurFileName, arginfo_class_COMPersistHelper_GetCurFileName)
+ CPH_ME(SaveToFile, arginfo_class_COMPersistHelper_SaveToFile)
+ CPH_ME(LoadFromFile, arginfo_class_COMPersistHelper_LoadFromFile)
+ CPH_ME(GetMaxStreamSize, arginfo_class_COMPersistHelper_GetMaxStreamSize)
+ CPH_ME(InitNew, arginfo_class_COMPersistHelper_InitNew)
+ CPH_ME(LoadFromStream, arginfo_class_COMPersistHelper_LoadFromStream)
+ CPH_ME(SaveToStream, arginfo_class_COMPersistHelper_SaveToStream)
PHP_FE_END
};
diff --git a/ext/com_dotnet/com_persist.stub.php b/ext/com_dotnet/com_persist.stub.php
new file mode 100644
index 0000000000..5f183b175a
--- /dev/null
+++ b/ext/com_dotnet/com_persist.stub.php
@@ -0,0 +1,21 @@
+<?php
+
+final class COMPersistHelper {
+ public function __construct(?VARIANT $com_object);
+
+ public function GetCurFileName(): string|false;
+
+ public function SaveToFile(?string $filename, bool $remember = true): bool;
+
+ public function LoadFromFile(string $path, int $flags = 0): bool;
+
+ public function GetMaxStreamSize(): int;
+
+ public function InitNew(): bool;
+
+ /** @param resource $stream */
+ public function LoadFromStream($stream): bool;
+
+ /** @param resource $stream */
+ public function SaveToStream($stream): bool;
+}
diff --git a/ext/com_dotnet/com_persist_arginfo.h b/ext/com_dotnet/com_persist_arginfo.h
new file mode 100644
index 0000000000..ba79007ccc
--- /dev/null
+++ b/ext/com_dotnet/com_persist_arginfo.h
@@ -0,0 +1,30 @@
+/* This is a generated file, edit the .stub.php file instead. */
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_COMPersistHelper___construct, 0, 0, 1)
+ ZEND_ARG_OBJ_INFO(0, com_object, VARIANT, 1)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_COMPersistHelper_GetCurFileName, 0, 0, MAY_BE_STRING|MAY_BE_FALSE)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_COMPersistHelper_SaveToFile, 0, 1, _IS_BOOL, 0)
+ ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 1)
+ ZEND_ARG_TYPE_INFO(0, remember, _IS_BOOL, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_COMPersistHelper_LoadFromFile, 0, 1, _IS_BOOL, 0)
+ ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_COMPersistHelper_GetMaxStreamSize, 0, 0, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_COMPersistHelper_InitNew, 0, 0, _IS_BOOL, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_COMPersistHelper_LoadFromStream, 0, 1, _IS_BOOL, 0)
+ ZEND_ARG_INFO(0, stream)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_COMPersistHelper_SaveToStream arginfo_class_COMPersistHelper_LoadFromStream