static ZEND_FUNCTION(defined);
static ZEND_FUNCTION(get_class);
static ZEND_FUNCTION(get_parent_class);
+static ZEND_FUNCTION(property_exists);
static ZEND_FUNCTION(method_exists);
static ZEND_FUNCTION(class_exists);
static ZEND_FUNCTION(function_exists);
ZEND_FE(defined, NULL)
ZEND_FE(get_class, NULL)
ZEND_FE(get_parent_class, NULL)
+ ZEND_FE(property_exists, NULL)
ZEND_FE(method_exists, NULL)
ZEND_FE(class_exists, NULL)
ZEND_FE(function_exists, NULL)
/* }}} */
+/* {{{ proto bool property_exists(object obj, string property_name)
+ Checks if the object has a property */
+ZEND_FUNCTION(property_exists)
+{
+ zval **object, **property;
+
+ if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2, &object, &property)==FAILURE) {
+ ZEND_WRONG_PARAM_COUNT();
+ }
+ if ((*object)->type != IS_OBJECT) {
+ RETURN_FALSE;
+ }
+
+ if (Z_OBJ_HANDLER_PP(object, has_property) && Z_OBJ_HANDLER_PP(object, has_property)(*object, *property, 1 TSRMLS_CC)) {
+ RETURN_TRUE;
+ } else {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+
/* {{{ proto bool method_exists(object object, string method)
Checks if the class method exists */
ZEND_FUNCTION(method_exists)
$t = new A ();
print_r($t);
+var_dump(property_exists($t, 'x'));
+var_dump(property_exists($t, 'y'));
+var_dump(property_exists($t, 'z'));
+var_dump(isset($t->y));
+var_dump(property_exists($t, 'y'));
+$t->z = 1;
+var_dump(property_exists($t, 'z'));
?>
--EXPECT--
(
[x] =>
)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(true)