summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-04-04 17:33:12 +0200
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-04-04 17:33:12 +0200
commit51f1d74a2279276ce762056856767b7dc140dd5b (patch)
treed8a2421ad165438814b64e2c219f001e4c20cf12
parent2eb4e891d9b2d3c71a2b1d7367d85b22f4ecc9cf (diff)
fixes to make the library compile for php 5.6 environments (problem discovered in issue #59)
-rw-r--r--src/argument.cpp46
-rw-r--r--src/callable.cpp12
-rw-r--r--src/iterator.cpp4
3 files changed, 57 insertions, 5 deletions
diff --git a/src/argument.cpp b/src/argument.cpp
index 8690a5c..a2aa8d5 100644
--- a/src/argument.cpp
+++ b/src/argument.cpp
@@ -28,13 +28,32 @@ Argument::Argument(const char *name, Type type, bool required, bool byref)
// fill members
_info->name = name;
_info->name_len = strlen(name);
-#if PHP_VERSION_ID >= 50400
+
+#if PHP_VERSION_ID >= 50400
+
+ // since php 5.4 there is a type-hint
_info->type_hint = (unsigned char)(type == Type::Array || type == Type::Callable ? type : Type::Null);
+
+# if PHP_VERSION_ID >= 50600
+
+ // from PHP 5.6 and onwards, an is_variadic property can be set, this
+ // specifies whether this argument is the first argument that specifies
+ // the type for a variable length list of arguments. For now we only
+ // support methods and functions with a fixed number of arguments.
+ _info->is_variadic = false;
+
+# endif
+
#else
+
+ // php 5.3 code
_info->array_type_hint = type == Type::Array;
_info->return_reference = false;
_info->required_num_args = 0; // @todo is this correct?
+
#endif
+
+ // this parameter is a regular type
_info->class_name = NULL;
_info->class_name_len = 0;
_info->allow_null = false;
@@ -60,9 +79,32 @@ Argument::Argument(const char *name, const char *classname, bool nullable, bool
// fill members
_info->name = name;
_info->name_len = strlen(name);
-#if PHP_VERSION_ID >= 50400
+
+#if PHP_VERSION_ID >= 50400
+
+ // since php 5.4 there is a type hint
_info->type_hint = (unsigned char)Type::Object;
+
+# if PHP_VERSION_ID >= 50600
+
+ // from PHP 5.6 and onwards, an is_variadic property can be set, this
+ // specifies whether this argument is the first argument that specifies
+ // the type for a variable length list of arguments. For now we only
+ // support methods and functions with a fixed number of arguments.
+ _info->is_variadic = false;
+
+# endif
+
+#else
+
+ // php 5.3 code
+ _info->array_type_hint = false;
+ _info->return_reference = false;
+ _info->required_num_args = 0; // @todo is this correct?
+
#endif
+
+ // the parameter is a class
_info->class_name = classname;
_info->class_name_len = strlen(classname);
_info->allow_null = nullable;
diff --git a/src/callable.cpp b/src/callable.cpp
index 55f2833..5e37df7 100644
--- a/src/callable.cpp
+++ b/src/callable.cpp
@@ -99,8 +99,18 @@ void Callable::initialize(zend_arg_info *info, const char *classname) const
// we do not support return-by-reference
finfo->return_reference = false;
- // passing by reference is not used
+# if PHP_VERSION_ID >= 50600
+ // since php 5.6 there are _allow_null and _is_variadic properties. It's
+ // not exactly clear what they do (@todo find this out) so for now we set
+ // them to false
+ finfo->_allow_null = false;
+ finfo->_is_variadic = false;
+
+# else
+ // passing by reference is not used (only for php 5.4 and php 5.5)
finfo->pass_rest_by_reference = false;
+# endif
+
#else
// php 5.3 code
info->name = nullptr;
diff --git a/src/iterator.cpp b/src/iterator.cpp
index 6242440..0362fb1 100644
--- a/src/iterator.cpp
+++ b/src/iterator.cpp
@@ -83,10 +83,10 @@ void Iterator::key(zend_object_iterator *iter, zval *key TSRMLS_DC)
Value retval(iterator->key());
// detach the underlying zval
- zval *zval = retval.detach();
+ zval *val = retval.detach();
// copy it to the key
- ZVAL_ZVAL(key, zval, 1, 1);
+ ZVAL_ZVAL(key, val, 1, 1);
}
/**