summaryrefslogtreecommitdiff
path: root/zend/super.cpp
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-04-06 21:53:24 +0200
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-04-06 21:53:24 +0200
commit35fd3ccbeb4def71b4d8a59dfbb5c31201b099b9 (patch)
tree915223360aed4743aa6127fde4836aa413a260e5 /zend/super.cpp
parentda4710512865e6816585ac4ab8edab2fa125e2d8 (diff)
renamed src directory to zend directory, disabled TSRM debug code
Diffstat (limited to 'zend/super.cpp')
-rw-r--r--zend/super.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/zend/super.cpp b/zend/super.cpp
new file mode 100644
index 0000000..506d4a5
--- /dev/null
+++ b/zend/super.cpp
@@ -0,0 +1,71 @@
+/**
+ * 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");
+
+/**
+ * Array access operator
+ * This can be used for accessing associative arrays
+ * @param key
+ * @return Value
+ */
+Value Super::operator[](const std::string &key)
+{
+ // 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) { zend_is_auto_global(_name, strlen(_name) TSRMLS_CC); _name = nullptr; }
+
+ // create a value object that wraps around the actual zval
+ Value value(PG(http_globals)[_index]);
+
+ // pass on the call
+ return value[key];
+}
+
+/**
+ * Array access operator
+ * This can be used for accessing associative arrays
+ * @param key
+ * @return Value
+ */
+Value Super::operator[](const char *key)
+{
+ // 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) { zend_is_auto_global(_name, strlen(_name) TSRMLS_CC); _name = nullptr; }
+
+ // create a value object that wraps around the actual zval
+ Value value(PG(http_globals)[_index]);
+
+ // pass on the call
+ return value[key];
+}
+
+/**
+ * End namespace
+ */
+}
+