summaryrefslogtreecommitdiff
path: root/zend/super.cpp
blob: 02a1e46b2b0808c85c9595278de492dcc5a017be (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
/**
 *  Super.cpp
 *
 *  @copyright 2014 Copernica BV
 *  @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
 */
#include "includes.h"

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

/**
 *  A number of super-globals are always accessible
 */
Super POST      (TRACK_VARS_POST,    "_POST");
Super GET       (TRACK_VARS_GET,     "_GET");
Super COOKIE    (TRACK_VARS_COOKIE,  "_COOKIE");
Super SERVER    (TRACK_VARS_SERVER,  "_SERVER");
Super ENV       (TRACK_VARS_ENV,     "_ENV");
Super FILES     (TRACK_VARS_FILES,   "_FILES");
Super REQUEST   (TRACK_VARS_REQUEST, "_REQUEST");

/**
 *  Convert object to a value
 *  @return Value
 */
Value Super::value()
{
    // we need the tsrm_ls pointer
    TSRMLS_FETCH();

    // call zend_is_auto_global to ensure that the just-in-time globals are loaded
    if (_name) {
        // make the variable an auto global
        zend_is_auto_global(zend_string_init(_name, ::strlen(_name), 1) TSRMLS_CC);

        // reset because we only need to do this once
        _name = nullptr;
    }

    // create a value object that wraps around the actual zval
    return &PG(http_globals)[_index];
}

/**
 *  End namespace
 */
}