Skip to content

Commit

Permalink
fixed issue #584 (yaf_view_simple __isset missed)
Browse files Browse the repository at this point in the history
  • Loading branch information
laruence committed Jun 26, 2024
1 parent 4ea204e commit ccee505
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/029.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ print_r($view->get("a"));
print_r($view->get());
$view->clear("b");
print_r($view->get());
var_dump(empty($view->a));
var_dump(isset($view->a));
$view->clear();
print_r($view->get());
var_dump(empty($view->a));
var_dump(isset($view->a));
?>
--EXPECTF--
bArray
Expand All @@ -27,6 +31,10 @@ Array
(
[a] => b
)
bool(false)
bool(true)
Array
(
)
bool(true)
bool(false)
15 changes: 15 additions & 0 deletions views/yaf_view_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,20 @@ PHP_METHOD(yaf_view_simple, get) {
}
/* }}} */

/** {{{ proto public Yaf_View_Simple::__isset($name)
*/
PHP_METHOD(yaf_view_simple, __isset) {
zend_string *name = NULL;
yaf_view_object *view = Z_YAFVIEWOBJ_P(getThis());

if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &name) == FAILURE) {
return;
}

RETURN_BOOL(zend_hash_exists(&view->tpl_vars, name));
}
/* }}} */

/** {{{ proto public Yaf_View_Simple::render(string $tpl, array $vars = NULL)
*/
PHP_METHOD(yaf_view_simple, render) {
Expand Down Expand Up @@ -638,6 +652,7 @@ zend_function_entry yaf_view_simple_methods[] = {
PHP_ME(yaf_view_simple, clear, arginfo_class_Yaf_View_Simple_clear, ZEND_ACC_PUBLIC)
PHP_ME(yaf_view_simple, setScriptPath, arginfo_class_Yaf_View_Simple_setScriptPath, ZEND_ACC_PUBLIC)
PHP_ME(yaf_view_simple, getScriptPath, arginfo_class_Yaf_View_Simple_getScriptPath, ZEND_ACC_PUBLIC)
PHP_ME(yaf_view_simple, __isset, arginfo_class_Yaf_View_Simple___isset, ZEND_ACC_PUBLIC)
PHP_MALIAS(yaf_view_simple, __get, get, arginfo_class_Yaf_View_Simple___get, ZEND_ACC_PUBLIC)
PHP_MALIAS(yaf_view_simple, __set, assign, arginfo_class_Yaf_View_Simple___set, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
Expand Down

0 comments on commit ccee505

Please sign in to comment.