summaryrefslogtreecommitdiff
path: root/src/callable.h
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-04-05 18:17:09 +0200
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-04-05 18:17:09 +0200
commit5d84ff5483f2db57762311714ff3c779db1e0f96 (patch)
tree0691e7395a292b152af3525b1e65a11b15bad46f /src/callable.h
parent5973954b7428aa95ec8f0b2424b5725d2815049f (diff)
removed zend code from the argument.h header file
Diffstat (limited to 'src/callable.h')
-rw-r--r--src/callable.h50
1 files changed, 48 insertions, 2 deletions
diff --git a/src/callable.h b/src/callable.h
index f123c8b..aef5649 100644
--- a/src/callable.h
+++ b/src/callable.h
@@ -43,11 +43,11 @@ public:
// loop through the arguments
for (auto it = arguments.begin(); it != arguments.end(); it++)
{
- // increment required
+ // increment counter with number of required parameters
if (it->required()) _required++;
// fill the arg info
- it->fill(&_argv[i++]);
+ fill(&_argv[i], *it);
}
}
@@ -140,7 +140,53 @@ protected:
* @var zend_arg_info[]
*/
struct _zend_arg_info *_argv = nullptr;
+
+ /**
+ * Private helper method to fill an argument object
+ * @param info object from the zend engine
+ * @param arg original object
+ */
+ void fill(zend_arg_info *info, const Argument &arg) const
+ {
+ // fill members
+ info->name = arg.name().c_str();
+ info->name_len = arg.name().size();
+
+#if PHP_VERSION_ID >= 50400
+
+ // since php 5.4 there is a type-hint, but we only support arrays, objects and callables
+ switch (arg.type()) {
+ case Type::Array: info->type_hint = IS_ARRAY; break;
+ case Type::Callable: info->type_hint = IS_CALLABLE; break;
+ case Type::Object: info->type_hint = IS_OBJECT; break;
+ default: info->type_hint = IS_NULL; break;
+ }
+
+# 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 = arg.type() == Type::Object ? arg.classname().c_str() : nullptr;
+ info->class_name_len = arg.type() == Type::Object ? arg.classname().size() : 0;
+ info->allow_null = arg.allowNull();
+ info->pass_by_reference = arg.byReference();
+ }
};
/**