summaryrefslogtreecommitdiff
path: root/php/src
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2017-03-29 15:36:53 -0700
committerMark Spruiell <mes@zeroc.com>2017-03-29 15:36:53 -0700
commit949ea036642e4640cf09aed1b2e70ca739579504 (patch)
treefe646f06609f8496c132c9cad7e9cc4153d940c3 /php/src
parentOverride java.lang.AutoCloseable.close in Ice.Communicator to not throw any e... (diff)
downloadice-949ea036642e4640cf09aed1b2e70ca739579504.tar.bz2
ice-949ea036642e4640cf09aed1b2e70ca739579504.tar.xz
ice-949ea036642e4640cf09aed1b2e70ca739579504.zip
ICE-7716 - more scripting language fixes
Diffstat (limited to 'php/src')
-rw-r--r--php/src/php7/Communicator.cpp89
-rw-r--r--php/src/php7/Init.cpp4
-rw-r--r--php/src/php7/Properties.cpp10
3 files changed, 74 insertions, 29 deletions
diff --git a/php/src/php7/Communicator.cpp b/php/src/php7/Communicator.cpp
index 50e124a2615..4c7a9fd5d8b 100644
--- a/php/src/php7/Communicator.cpp
+++ b/php/src/php7/Communicator.cpp
@@ -1101,52 +1101,82 @@ ZEND_FUNCTION(Ice_initialize)
zval* zvinit = 0;
//
- // Accept the following invocations:
+ // The argument options are:
//
- // initialize(array, InitializationData)
- // initialize(array)
- // initialize(InitializationData)
// initialize()
+ // initialize(args)
+ // initialize(initData)
+ // initialize(args, initData)
+ // initialize(initData, args)
//
- bool hasArgs = false;
- if(ZEND_NUM_ARGS())
+
+ if(ZEND_NUM_ARGS() > 2)
{
- if(Z_TYPE(args[0]) == IS_ARRAY)
+ runtimeError("too many arguments to initialize");
+ RETURN_NULL();
+ }
+
+ if(ZEND_NUM_ARGS() > 0)
+ {
+ zval* arg = &args[0];
+ while(Z_TYPE_P(arg) == IS_REFERENCE)
+ {
+ arg = Z_REFVAL_P(arg);
+ }
+
+ if(Z_TYPE_P(arg) == IS_ARRAY)
+ {
+ zvargs = arg;
+ }
+ else if(Z_TYPE_P(arg) == IS_OBJECT && Z_OBJCE_P(arg) == initClass)
{
- if(!extractStringArray(&args[0], seq))
+ zvinit = arg;
+ }
+ else
+ {
+ invalidArgument("initialize expects an argument list, an InitializationData object, or both");
+ RETURN_NULL();
+ }
+ }
+
+ if(ZEND_NUM_ARGS() > 1)
+ {
+ zval* arg = &args[1];
+ while(Z_TYPE_P(arg) == IS_REFERENCE)
+ {
+ arg = Z_REFVAL_P(arg);
+ }
+
+ if(Z_TYPE_P(arg) == IS_ARRAY)
+ {
+ if(zvargs)
{
+ invalidArgument("unexpected array argument to initialize");
RETURN_NULL();
}
- zvargs = &args[0];
- hasArgs = true;
- if(ZEND_NUM_ARGS() > 1)
- {
- if(Z_TYPE(args[1]) != IS_OBJECT || Z_OBJCE(args[1]) != initClass)
- {
- string s = zendTypeToString(Z_TYPE(args[1]));
- invalidArgument("expected InitializationData object but received %s", s.c_str());
- RETURN_NULL();
- }
- zvinit = &args[1];
- }
+ zvargs = arg;
}
- else if(Z_TYPE(args[0]) == IS_OBJECT && Z_OBJCE(args[0]) == initClass)
+ else if(Z_TYPE_P(arg) == IS_OBJECT && Z_OBJCE_P(arg) == initClass)
{
- if(ZEND_NUM_ARGS() > 1)
+ if(zvinit)
{
- runtimeError("too many arguments");
+ invalidArgument("unexpected InitializationData argument to initialize");
RETURN_NULL();
}
- zvinit = &args[0];
+ zvinit = arg;
}
else
{
- string s = zendTypeToString(Z_TYPE(args[0]));
- invalidArgument("unexpected argument type %s", s.c_str());
+ invalidArgument("initialize expects an argument list, an InitializationData object, or both");
RETURN_NULL();
}
}
+ if(zvargs && !extractStringArray(zvargs, seq))
+ {
+ RETURN_NULL();
+ }
+
if(zvinit)
{
zval* data;
@@ -1180,13 +1210,16 @@ ZEND_FUNCTION(Ice_initialize)
initData.compactIdResolver = new IdResolver();
initData.valueFactoryManager = new ValueFactoryManager;
- CommunicatorInfoIPtr info = initializeCommunicator(return_value, seq, hasArgs, initData);
+ CommunicatorInfoIPtr info = initializeCommunicator(return_value, seq, zvargs != 0, initData);
if(!info)
{
RETURN_NULL();
}
- if(zvargs && Z_ISREF_P(zvargs))
+ //
+ // Replace the existing argument array with the filtered set.
+ //
+ if(zvargs)
{
zval_dtor(zvargs);
if(!createStringArray(zvargs, seq))
diff --git a/php/src/php7/Init.cpp b/php/src/php7/Init.cpp
index 15b19085ad1..5d10252aa0e 100644
--- a/php/src/php7/Init.cpp
+++ b/php/src/php7/Init.cpp
@@ -23,9 +23,13 @@ using namespace IcePHP;
ZEND_DECLARE_MODULE_GLOBALS(ice)
ZEND_BEGIN_ARG_INFO_EX(Ice_initialize_arginfo, 1, ZEND_RETURN_VALUE, static_cast<zend_ulong>(-1))
+ ZEND_ARG_PASS_INFO(1)
+ ZEND_ARG_PASS_INFO(1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(Ice_createProperties_arginfo, 1, ZEND_RETURN_VALUE, static_cast<zend_ulong>(-1))
+ ZEND_ARG_PASS_INFO(1)
+ ZEND_ARG_PASS_INFO(0)
ZEND_END_ARG_INFO()
#ifdef ICEPHP_USE_NAMESPACES
diff --git a/php/src/php7/Properties.cpp b/php/src/php7/Properties.cpp
index e394d62c00c..df4ffb4848b 100644
--- a/php/src/php7/Properties.cpp
+++ b/php/src/php7/Properties.cpp
@@ -524,6 +524,14 @@ ZEND_FUNCTION(Ice_createProperties)
RETURN_NULL();
}
+ if(arglist)
+ {
+ while(Z_TYPE_P(arglist) == IS_REFERENCE)
+ {
+ arglist = Z_REFVAL_P(arglist);
+ }
+ }
+
Ice::StringSeq seq;
if(arglist && !extractStringArray(arglist, seq))
{
@@ -553,7 +561,7 @@ ZEND_FUNCTION(Ice_createProperties)
RETURN_NULL();
}
- if(arglist && Z_ISREF_P(arglist))
+ if(arglist)
{
zval_dtor(arglist);
if(!createStringArray(arglist, seq))