Skip to content

Commit

Permalink
Added support for the new argument called 'ignoreStrictCheck'.
Browse files Browse the repository at this point in the history
  • Loading branch information
derickr committed Oct 28, 2011
1 parent b7b260b commit 7cc2808
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions twig.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ static void twig_add_class_to_cache(zval *cache, zval *object, char *class_name)
add_assoc_zval(cache, class_name, class_info);
}

/* {{{ proto mixed twig_template_get_attributes(TwigTemplate template, mixed object, mixed item, array arguments, string type, boolean isDefinedTest)
/* {{{ proto mixed twig_template_get_attributes(TwigTemplate template, mixed object, mixed item, array arguments, string type, boolean isDefinedTest, boolean ignoreStrictCheck)
A C implementation of TwigTemplate::getAttribute() */
PHP_FUNCTION(twig_template_get_attributes)
{
Expand All @@ -700,9 +700,10 @@ PHP_FUNCTION(twig_template_get_attributes)
char *type = NULL;
int type_len = 0;
zend_bool isDefinedTest = 0;
zend_bool ignoreStrictCheck = 0;
int free_ret = 0;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ozzasb", &template, &object, &item, &arguments, &type, &type_len, &isDefinedTest) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ozzasb", &template, &object, &item, &arguments, &type, &type_len, &isDefinedTest, &ignoreStrictCheck) == FAILURE) {
return;
}

Expand Down Expand Up @@ -742,15 +743,15 @@ PHP_FUNCTION(twig_template_get_attributes)
if ($isDefinedTest) {
return false;
}
if (!$this->env->isStrictVariables()) {
if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
return null;
}
*/
if (strcmp("array", type) == 0) {
if (isDefinedTest) {
RETURN_FALSE;
}
if (!TWIG_CALL_BOOLEAN(TWIG_PROPERTY_CHAR(template, "env"), "isStrictVariables")) {
if (ignoreStrictCheck || !TWIG_CALL_BOOLEAN(TWIG_PROPERTY_CHAR(template, "env"), "isStrictVariables")) {
return;
}
/*
Expand Down Expand Up @@ -784,13 +785,13 @@ PHP_FUNCTION(twig_template_get_attributes)
RETURN_FALSE;
}
/*
if (!$this->env->isStrictVariables()) {
if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
return null;
}
throw new Twig_Error_Runtime(sprintf('Item "%s" for "%s" does not exist', $item, implode(', ', array_keys($object))));
}
*/
if (!TWIG_CALL_BOOLEAN(TWIG_PROPERTY_CHAR(template, "env"), "isStrictVariables")) {
if (ignoreStrictCheck || !TWIG_CALL_BOOLEAN(TWIG_PROPERTY_CHAR(template, "env"), "isStrictVariables")) {
RETURN_FALSE;
}
TWIG_THROW_EXCEPTION("Twig_Error_Runtime", "Item \"%s\" for \"%s\" does not exist", Z_STRVAL_P(item), TWIG_IMPLODE_ARRAY_KEYS(", ", object));
Expand Down Expand Up @@ -916,7 +917,7 @@ PHP_FUNCTION(twig_template_get_attributes)
if ($isDefinedTest) {
return false;
}
if (!$this->env->isStrictVariables()) {
if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
return null;
}
throw new Twig_Error_Runtime(sprintf('Method "%s" for object "%s" does not exist', $item, get_class($object)));
Expand All @@ -929,7 +930,7 @@ PHP_FUNCTION(twig_template_get_attributes)
if (isDefinedTest) {
RETURN_FALSE;
}
if (!TWIG_CALL_BOOLEAN(TWIG_PROPERTY_CHAR(template, "env"), "isStrictVariables")) {
if (ignoreStrictCheck || !TWIG_CALL_BOOLEAN(TWIG_PROPERTY_CHAR(template, "env"), "isStrictVariables")) {
return;
}
TWIG_THROW_EXCEPTION("Twig_Error_Runtime", "Method \"%s\" for object \"%s\" does not exist", Z_STRVAL_P(item), TWIG_GET_CLASS_NAME(object));
Expand Down

0 comments on commit 7cc2808

Please sign in to comment.