1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/**
* ArgInfo.h
*
* Internal class that wraps the Zend information about an argument
*
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* @copyright 2013 Copernica BV
*/
/**
* Set up namespace
*/
namespace Php {
/**
* Class definition
*/
class ArgInfo
{
public:
/**
* Constructor if this argument should be an instance of a certain class
* @param name Name of the argument
* @param classname If a specific class is required, the class type
* @param null Are NULL values allowed in stead of an instance?
* @param ref Is this a pass-by-reference argument?
*/
ArgInfo(const std::string &name, const std::string &classname, bool null = true, bool ref = false) :
_name(name), _classname(name), _type(objectType), _null(null), _ref(ref) {}
/**
* Constructor if this argument can be anything
* @param name Name of the argument
* @param type Type hint (arrayType or callableType)
* @param ref Is this a pass-by-reference argument?
*/
ArgInfo(const std::string &name, Type type = nullType, bool ref = false) :
_name(name), _type(type), _null(false), _ref(ref) {}
/**
* Constructor if this argument can be anything
* @param name Name of the argument
* @param ref Is this a pass-by-reference argument?
*/
ArgInfo(const std::string &name, bool ref = false) :
_name(name), _type(nullType), _null(false), _ref(ref) {}
/**
* Destructor
*/
virtual ~ArgInfo() {}
/**
* Fill a zend_arg_info structure
* @param info
*/
void fill(zend_arg_info *info)
{
// fill all members
info->name = _name.c_str();
info->name_len = _name.size();
info->class_name = _classname.size() ? _classname.c_str() : NULL;
info->class_name_len = _classname.size();
info->type_hint = _type;
info->allow_null = _null;
info->pass_by_reference = _ref;
}
private:
/**
* The argument name
* @var string
*/
std::string _name;
/**
* The class name
* @var string
*/
std::string _classname;
/**
* Type of the argument
* @var Type
*/
Type _type;
/**
* Can this argument be set to NULL?
* @var bool
*/
bool _null;
/**
* Is this a pass-by-reference argument?
* @var bool
*/
bool _ref;
};
/**
* End of namespace
*/
}
|