summaryrefslogtreecommitdiff
path: root/zend/nullmember.h
blob: e03589763bd0e560d9cbc2080fa5a233f9b31c42 (plain)
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
/**
 *  NullMember.h
 *
 *  Implementation for a property that is initially set to NULL
 *
 *  @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
 *  @copyright 2013 Copernica BV
 */

/**
 *  Set up namespace
 */
namespace Php {

/**
 *  Class definition
 */
class NullMember : public Member
{
public:
    /**
     *  Constructor
     *  @param  name
     *  @param  flags
     */
    NullMember(const char *name, int flags) : Member(name, flags) {}

    /**
     *  Destructor
     */
    virtual ~NullMember() {}

    /**
     *  Internal method to declare the property as constant
     *  @param  zend_class_entry
     *  @param  tsrm_ls
     */
    virtual void constant(struct _zend_class_entry *entry TSRMLS_DC) override
    {
        zend_declare_class_constant_null(entry, _name.c_str(), _name.size() TSRMLS_CC);
    }

    /**
     *  Virtual method to declare the property
     *  @param  entry       Class entry
     *  @param  tsrm_ls
     */
    virtual void declare(struct _zend_class_entry *entry TSRMLS_DC) override
    {
        // char* cast is necessary for php 5.3
        zend_declare_property_null(entry, (char *)_name.c_str(), _name.size(), _flags TSRMLS_CC);
    }
};

/**
 *  End of namespace
 */
}