cvs: ZendEngine2 / zend_builtin_functions.c php-src/tests/lang bug26182.phpt
| From: | Marcus Boerger | Date: | Thu, 27 Nov 2003 17:06:26 +0000 |
| Subject: | cvs: ZendEngine2 / zend_builtin_functions.c php-src/tests/lang bug26182.phpt | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-2009@lists.php.net to get a copy of this message | ||
helly Thu Nov 27 12:06:26 2003 EDT
Modified files:
/php-src/tests/lang bug26182.phpt
/ZendEngine2 zend_builtin_functions.c
Log:
Add a support function to check for property existance which is different
from checking a property from being empty/set.
Update test #26182.
Index: php-src/tests/lang/bug26182.phpt
diff -u php-src/tests/lang/bug26182.phpt:1.2 php-src/tests/lang/bug26182.phpt:1.3
--- php-src/tests/lang/bug26182.phpt:1.2 Wed Nov 26 03:47:58 2003
+++ php-src/tests/lang/bug26182.phpt Thu Nov 27 12:06:25 2003
@@ -17,6 +17,13 @@
$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--
@@ -24,3 +31,9 @@
(
[x] =>
)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(true)
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.216 ZendEngine2/zend_builtin_functions.c:1.217
--- ZendEngine2/zend_builtin_functions.c:1.216 Mon Nov 24 13:13:29 2003
+++ ZendEngine2/zend_builtin_functions.c Thu Nov 27 12:06:26 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_builtin_functions.c,v 1.216 2003/11/24 18:13:29 andi Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.217 2003/11/27 17:06:26 helly Exp $ */
#include "zend.h"
#include "zend_API.h"
@@ -42,6 +42,7 @@
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);
@@ -99,6 +100,7 @@
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)
@@ -756,6 +758,28 @@
/* }}} */
+/* {{{ 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)