summaryrefslogtreecommitdiff
path: root/framework/core.php
diff options
context:
space:
mode:
authorxue <>2006-03-13 02:38:47 +0000
committerxue <>2006-03-13 02:38:47 +0000
commit7770c298450237e092d6d801fd547609ba2db230 (patch)
treeddc92889b2f10256f59a4024f5bed5cc01d73bdf /framework/core.php
parent6ae6538555d45b3e947f5ce0d948d9b88d95364a (diff)
TDataFieldAccessor can access public member variables now. Added implementation to cope with low PHP versions.
Diffstat (limited to 'framework/core.php')
-rw-r--r--framework/core.php80
1 files changed, 80 insertions, 0 deletions
diff --git a/framework/core.php b/framework/core.php
index bac24ca2..56fe12e7 100644
--- a/framework/core.php
+++ b/framework/core.php
@@ -883,4 +883,84 @@ class TTextWriter extends TComponent implements ITextWriter
}
}
+if(version_compare(phpversion(),'5.1.0','>='))
+{
+ /**
+ * TReflectionClass class.
+ * This class is written to cope with the incompatibility between different PHP versions.
+ * It is equivalent to ReflectionClass if PHP version >= 5.1.0
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @version $Revision: $ $Date: $
+ * @package System
+ * @since 3.0
+ */
+ class TReflectionClass extends ReflectionClass
+ {
+ }
+}
+else // PHP < 5.1.0
+{
+ /**
+ * TReflectionClass class.
+ * This class is written to cope with the incompatibility between different PHP versions.
+ * It mainly provides a way to detect if a method exists for a given class name.
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @version $Revision: $ $Date: $
+ * @package System
+ * @since 3.0
+ */
+ class TReflectionClass extends ReflectionClass
+ {
+ /**
+ * @param string method name
+ * @return boolean whether the method exists
+ */
+ public function hasMethod($method)
+ {
+ try
+ {
+ return $this->getMethod($method)!==null;
+ }
+ catch(Exception $e)
+ {
+ return false;
+ }
+ }
+
+ /**
+ * @param string property name
+ * @return boolean whether the property exists
+ */
+ public function hasProperty($property)
+ {
+ try
+ {
+ return $this->getProperty($property)!==null;
+ }
+ catch(Exception $e)
+ {
+ return false;
+ }
+ }
+ }
+
+ if(!function_exists('property_exists'))
+ {
+ /**
+ * Detects whether an object contains the specified member variable.
+ * @param object
+ * @param string member variable (property) name
+ * @return boolean
+ */
+ function property_exists($object, $property)
+ {
+ if(is_object($object))
+ return array_key_exists($property, get_object_vars($object));
+ else
+ return false;
+ }
+ }
+}
+
?> \ No newline at end of file