summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToon Schoenmakers <toon.schoenmakers@copernica.com>2014-08-19 14:20:11 +0200
committerToon Schoenmakers <toon.schoenmakers@copernica.com>2014-08-19 14:20:11 +0200
commit36ab68bd25aaedc81fdf6745faf5f3a14474c53f (patch)
tree6edbb9a5cd0d7e138a2ffac28863f6942a87b603
parentcc106471bee34549d0db18a6d3797e791853fc6c (diff)
Fixed the compile issues against php 5.3
-rw-r--r--zend/exists.cpp9
-rw-r--r--zend/value.cpp34
2 files changed, 32 insertions, 11 deletions
diff --git a/zend/exists.cpp b/zend/exists.cpp
index 3add227..1177e47 100644
--- a/zend/exists.cpp
+++ b/zend/exists.cpp
@@ -13,6 +13,15 @@
#include "includes.h"
/**
+ * On php 5.3 ZEND_ACC_TRAIT isn't defined, so we simply define it to 0
+ * so all operations with it are basically no-ops. Currently unconfirmed
+ * if this actually works correctly on php 5.3, but it at least compiles.
+ */
+#ifndef ZEND_ACC_TRAIT
+#define ZEND_ACC_TRAIT 0
+#endif
+
+/**
* Open the PHP namespace
*/
namespace Php {
diff --git a/zend/value.cpp b/zend/value.cpp
index 50c4b64..69f7e2c 100644
--- a/zend/value.cpp
+++ b/zend/value.cpp
@@ -1445,10 +1445,10 @@ zend_class_entry *Value::classEntry(bool allowString) const
/**
* Check whether this object is an instance of a certain class
- *
+ *
* If you set the parameter 'allowString' to true, and the Value object
* holds a string, the string will be treated as class name.
- *
+ *
* @param classname The class of which this should be an instance
* @param size Length of the classname string
* @param allowString Is it allowed for 'this' to be a string
@@ -1462,23 +1462,29 @@ bool Value::instanceOf(const char *classname, size_t size, bool allowString) con
// the class-entry of 'this'
zend_class_entry *this_ce = classEntry(allowString);
if (!this_ce) return false;
-
+
// class entry of the parameter
zend_class_entry **ce;
-
+
// now we can look up the actual class
+ // the signature of zend_lookup_class_ex is slightly different since 5.4
+ // TODO The signature of this changed once again as of 5.6!
+#if PHP_VERSION_ID >= 50400
if (zend_lookup_class_ex(classname, size, NULL, 0, &ce TSRMLS_CC) == FAILURE) return false;
-
+#else
+ if (zend_lookup_class_ex(classname, size, 0, &ce TSRMLS_CC) == FAILURE) return false;
+#endif
+
// check if this is a subclass
return instanceof_function(this_ce, *ce TSRMLS_CC);
}
/**
* Check whether this object is derived from a certain class
- *
+ *
* If you set the parameter 'allowString' to true, and the Value object
* holds a string, the string will be treated as class name.
- *
+ *
* @param classname The class of which this should be an instance
* @param size Length of the classname string
* @param allowString Is it allowed for 'this' to be a string
@@ -1492,16 +1498,22 @@ bool Value::derivedFrom(const char *classname, size_t size, bool allowString) co
// the class-entry of 'this'
zend_class_entry *this_ce = classEntry(allowString);
if (!this_ce) return false;
-
+
// class entry of the parameter
zend_class_entry **ce;
-
+
// now we can look up the actual class
+ // the signature of zend_lookup_class_ex is slightly different since 5.4
+ // TODO The signature of this changed once again as of 5.6!
+#if PHP_VERSION_ID >= 50400
if (zend_lookup_class_ex(classname, size, NULL, 0, &ce TSRMLS_CC) == FAILURE) return false;
-
+#else
+ if (zend_lookup_class_ex(classname, size, 0, &ce TSRMLS_CC) == FAILURE) return false;
+#endif
+
// should not be identical, it must be a real derived object
if (this_ce == *ce) return false;
-
+
// check if this is a subclass
return instanceof_function(this_ce, *ce TSRMLS_CC);
}