mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 19:36:43 +00:00
adding missing dots to some exception messages
This commit is contained in:
+14
-14
@@ -144,7 +144,7 @@ static zval *TWIG_GET_ARRAYOBJECT_ELEMENT(zval *object, zval *offset TSRMLS_DC)
|
||||
|
||||
if (!retval) {
|
||||
if (!EG(exception)) {
|
||||
zend_error(E_ERROR, "Undefined offset for object of type %s used as array", ce->name);
|
||||
zend_error(E_ERROR, "Undefined offset for object of type %s used as array.", ce->name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -167,7 +167,7 @@ static int TWIG_ISSET_ARRAYOBJECT_ELEMENT(zval *object, zval *offset TSRMLS_DC)
|
||||
|
||||
if (!retval) {
|
||||
if (!EG(exception)) {
|
||||
zend_error(E_ERROR, "Undefined offset for object of type %s used as array", ce->name);
|
||||
zend_error(E_ERROR, "Undefined offset for object of type %s used as array.", ce->name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -811,15 +811,15 @@ PHP_FUNCTION(twig_template_get_attributes)
|
||||
}
|
||||
*/
|
||||
if (TWIG_INSTANCE_OF(object, zend_ce_arrayaccess TSRMLS_CC)) {
|
||||
TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Key \"%s\" in object with ArrayAccess of class \"%s\" does not exist", item, TWIG_GET_CLASS_NAME(object TSRMLS_CC));
|
||||
TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Key \"%s\" in object with ArrayAccess of class \"%s\" does not exist.", item, TWIG_GET_CLASS_NAME(object TSRMLS_CC));
|
||||
} else if (Z_TYPE_P(object) == IS_OBJECT) {
|
||||
TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Impossible to access a key \"%s\" on an object of class \"%s\" that does not implement ArrayAccess interface", item, TWIG_GET_CLASS_NAME(object TSRMLS_CC));
|
||||
TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Impossible to access a key \"%s\" on an object of class \"%s\" that does not implement ArrayAccess interface.", item, TWIG_GET_CLASS_NAME(object TSRMLS_CC));
|
||||
} else if (Z_TYPE_P(object) == IS_ARRAY) {
|
||||
if (0 == zend_hash_num_elements(Z_ARRVAL_P(object))) {
|
||||
TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Key \"%s\" does not exist as the array is empty", item);
|
||||
TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Key \"%s\" does not exist as the array is empty.", item);
|
||||
} else {
|
||||
char *array_keys = TWIG_IMPLODE_ARRAY_KEYS(", ", object TSRMLS_CC);
|
||||
TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Key \"%s\" for array with keys \"%s\" does not exist", item, array_keys);
|
||||
TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Key \"%s\" for array with keys \"%s\" does not exist.", item, array_keys);
|
||||
efree(array_keys);
|
||||
}
|
||||
} else {
|
||||
@@ -829,15 +829,15 @@ PHP_FUNCTION(twig_template_get_attributes)
|
||||
convert_to_string(object);
|
||||
TWIG_RUNTIME_ERROR(template TSRMLS_CC,
|
||||
(strcmp("array", type) == 0)
|
||||
? "Impossible to access a key (\"%s\") on a %s variable"
|
||||
: "Impossible to access an attribute (\"%s\") on a %s variable",
|
||||
? "Impossible to access a key (\"%s\") on a %s variable."
|
||||
: "Impossible to access an attribute (\"%s\") on a %s variable.",
|
||||
item, type_name);
|
||||
} else {
|
||||
convert_to_string(object);
|
||||
TWIG_RUNTIME_ERROR(template TSRMLS_CC,
|
||||
(strcmp("array", type) == 0)
|
||||
? "Impossible to access a key (\"%s\") on a %s variable (\"%s\")"
|
||||
: "Impossible to access an attribute (\"%s\") on a %s variable (\"%s\")",
|
||||
? "Impossible to access a key (\"%s\") on a %s variable (\"%s\")."
|
||||
: "Impossible to access an attribute (\"%s\") on a %s variable (\"%s\").",
|
||||
item, type_name, Z_STRVAL_P(object));
|
||||
}
|
||||
zval_ptr_dtor(&object);
|
||||
@@ -883,11 +883,11 @@ PHP_FUNCTION(twig_template_get_attributes)
|
||||
if (Z_TYPE_P(object) == IS_NULL) {
|
||||
convert_to_string_ex(&object);
|
||||
|
||||
TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Impossible to invoke a method (\"%s\") on a %s variable", item, type_name);
|
||||
TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Impossible to invoke a method (\"%s\") on a %s variable.", item, type_name);
|
||||
} else {
|
||||
convert_to_string_ex(&object);
|
||||
|
||||
TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Impossible to invoke a method (\"%s\") on a %s variable (\"%s\")", item, type_name, Z_STRVAL_P(object));
|
||||
TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Impossible to invoke a method (\"%s\") on a %s variable (\"%s\").", item, type_name, Z_STRVAL_P(object));
|
||||
}
|
||||
|
||||
zval_ptr_dtor(&object);
|
||||
@@ -1020,7 +1020,7 @@ PHP_FUNCTION(twig_template_get_attributes)
|
||||
return null;
|
||||
}
|
||||
|
||||
throw new Twig_Error_Runtime(sprintf('Method "%s" for object "%s" does not exist', $item, get_class($object)), -1, $this->getTemplateName());
|
||||
throw new Twig_Error_Runtime(sprintf('Method "%s" for object "%s" does not exist.', $item, get_class($object)), -1, $this->getTemplateName());
|
||||
}
|
||||
|
||||
if ($isDefinedTest) {
|
||||
@@ -1040,7 +1040,7 @@ PHP_FUNCTION(twig_template_get_attributes)
|
||||
efree(item);
|
||||
return;
|
||||
}
|
||||
TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Neither the property \"%s\" nor one of the methods \"%s()\", \"get%s()\"/\"is%s()\" or \"__call()\" exist and have public access in class \"%s\"", item, item, item, item, TWIG_GET_CLASS_NAME(object TSRMLS_CC));
|
||||
TWIG_RUNTIME_ERROR(template TSRMLS_CC, "Neither the property \"%s\" nor one of the methods \"%s()\", \"get%s()\"/\"is%s()\" or \"__call()\" exist and have public access in class \"%s\".", item, item, item, item, TWIG_GET_CLASS_NAME(object TSRMLS_CC));
|
||||
efree(item);
|
||||
return;
|
||||
}
|
||||
|
||||
+10
-10
@@ -477,25 +477,25 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
||||
}
|
||||
|
||||
if ($object instanceof ArrayAccess) {
|
||||
$message = sprintf('Key "%s" in object with ArrayAccess of class "%s" does not exist', $arrayItem, get_class($object));
|
||||
$message = sprintf('Key "%s" in object with ArrayAccess of class "%s" does not exist.', $arrayItem, get_class($object));
|
||||
} elseif (is_object($object)) {
|
||||
$message = sprintf('Impossible to access a key "%s" on an object of class "%s" that does not implement ArrayAccess interface', $item, get_class($object));
|
||||
$message = sprintf('Impossible to access a key "%s" on an object of class "%s" that does not implement ArrayAccess interface.', $item, get_class($object));
|
||||
} elseif (is_array($object)) {
|
||||
if (empty($object)) {
|
||||
$message = sprintf('Key "%s" does not exist as the array is empty', $arrayItem);
|
||||
$message = sprintf('Key "%s" does not exist as the array is empty.', $arrayItem);
|
||||
} else {
|
||||
$message = sprintf('Key "%s" for array with keys "%s" does not exist', $arrayItem, implode(', ', array_keys($object)));
|
||||
$message = sprintf('Key "%s" for array with keys "%s" does not exist.', $arrayItem, implode(', ', array_keys($object)));
|
||||
}
|
||||
} elseif (self::ARRAY_CALL === $type) {
|
||||
if (null === $object) {
|
||||
$message = sprintf('Impossible to access a key ("%s") on a null variable', $item);
|
||||
$message = sprintf('Impossible to access a key ("%s") on a null variable.', $item);
|
||||
} else {
|
||||
$message = sprintf('Impossible to access a key ("%s") on a %s variable ("%s")', $item, gettype($object), $object);
|
||||
$message = sprintf('Impossible to access a key ("%s") on a %s variable ("%s").', $item, gettype($object), $object);
|
||||
}
|
||||
} elseif (null === $object) {
|
||||
$message = sprintf('Impossible to access an attribute ("%s") on a null variable', $item);
|
||||
$message = sprintf('Impossible to access an attribute ("%s") on a null variable.', $item);
|
||||
} else {
|
||||
$message = sprintf('Impossible to access an attribute ("%s") on a %s variable ("%s")', $item, gettype($object), $object);
|
||||
$message = sprintf('Impossible to access an attribute ("%s") on a %s variable ("%s").', $item, gettype($object), $object);
|
||||
}
|
||||
|
||||
throw new Twig_Error_Runtime($message, -1, $this->getTemplateName());
|
||||
@@ -512,9 +512,9 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
||||
}
|
||||
|
||||
if (null === $object) {
|
||||
$message = sprintf('Impossible to invoke a method ("%s") on a null variable', $item);
|
||||
$message = sprintf('Impossible to invoke a method ("%s") on a null variable.', $item);
|
||||
} else {
|
||||
$message = sprintf('Impossible to invoke a method ("%s") on a %s variable ("%s")', $item, gettype($object), $object);
|
||||
$message = sprintf('Impossible to invoke a method ("%s") on a %s variable ("%s").', $item, gettype($object), $object);
|
||||
}
|
||||
|
||||
throw new Twig_Error_Runtime($message, -1, $this->getTemplateName());
|
||||
|
||||
@@ -38,7 +38,7 @@ class Twig_Tests_ErrorTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
$this->fail();
|
||||
} catch (Twig_Error_Runtime $e) {
|
||||
$this->assertEquals('Variable "foo" does not exist in "index.html" at line 3', $e->getMessage());
|
||||
$this->assertEquals('Variable "foo" does not exist in "index.html" at line 3.', $e->getMessage());
|
||||
$this->assertEquals(3, $e->getTemplateLine());
|
||||
$this->assertEquals('index.html', $e->getTemplateFile());
|
||||
}
|
||||
@@ -69,7 +69,7 @@ class Twig_Tests_ErrorTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
$this->fail();
|
||||
} catch (Twig_Error_Runtime $e) {
|
||||
$this->assertEquals(sprintf('Variable "foo" does not exist in "%s" at line %d', $name, $line), $e->getMessage());
|
||||
$this->assertEquals(sprintf('Variable "foo" does not exist in "%s" at line %d.', $name, $line), $e->getMessage());
|
||||
$this->assertEquals($line, $e->getTemplateLine());
|
||||
$this->assertEquals($name, $e->getTemplateFile());
|
||||
}
|
||||
|
||||
@@ -15,4 +15,4 @@ Exception for multiline array with undefined variable
|
||||
--DATA--
|
||||
return array('foobar' => 'foobar')
|
||||
--EXCEPTION--
|
||||
Twig_Error_Runtime: Variable "foo2" does not exist in "index.twig" at line 11
|
||||
Twig_Error_Runtime: Variable "foo2" does not exist in "index.twig" at line 11.
|
||||
|
||||
+1
-1
@@ -15,4 +15,4 @@ Exception for multiline array with undefined variable
|
||||
--DATA--
|
||||
return array()
|
||||
--EXCEPTION--
|
||||
Twig_Error_Runtime: Variable "foobar" does not exist in "index.twig" at line 7
|
||||
Twig_Error_Runtime: Variable "foobar" does not exist in "index.twig" at line 7.
|
||||
|
||||
@@ -9,4 +9,4 @@ Foo
|
||||
--DATA--
|
||||
return array()
|
||||
--EXCEPTION--
|
||||
Twig_Error_Runtime: Variable "with_context" does not exist in "index.twig" at line 3
|
||||
Twig_Error_Runtime: Variable "with_context" does not exist in "index.twig" at line 3.
|
||||
|
||||
@@ -9,4 +9,4 @@ Foo
|
||||
--DATA--
|
||||
return array()
|
||||
--EXCEPTION--
|
||||
Twig_Error_Runtime: Variable "vars" does not exist in "index.twig" at line 3
|
||||
Twig_Error_Runtime: Variable "vars" does not exist in "index.twig" at line 3.
|
||||
|
||||
@@ -5,4 +5,3 @@ macro with varargs argument
|
||||
{% endmacro %}
|
||||
--EXCEPTION--
|
||||
Twig_Error_Syntax: The argument "varargs" in macro "test" cannot be defined because the variable "varargs" is reserved for arbitrary arguments in "index.twig" at line 2.
|
||||
|
||||
|
||||
@@ -12,4 +12,4 @@ foo
|
||||
--DATA--
|
||||
return array('foo' => 'foo');
|
||||
--EXCEPTION--
|
||||
Twig_Error_Runtime: Impossible to access an attribute ("bar") on a string variable ("foo") in "foo" at line 3
|
||||
Twig_Error_Runtime: Impossible to access an attribute ("bar") on a string variable ("foo") in "foo" at line 3.
|
||||
|
||||
@@ -13,4 +13,4 @@ BAR
|
||||
--DATA--
|
||||
return array()
|
||||
--EXCEPTION--
|
||||
Twig_Error_Runtime: Variable "nothing" does not exist in "index.twig" at line 5
|
||||
Twig_Error_Runtime: Variable "nothing" does not exist in "index.twig" at line 5.
|
||||
|
||||
@@ -56,22 +56,22 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
||||
public function getAttributeExceptions()
|
||||
{
|
||||
$tests = array(
|
||||
array('{{ string["a"] }}', 'Impossible to access a key ("a") on a string variable ("foo") in "%s" at line 1', false),
|
||||
array('{{ null["a"] }}', 'Impossible to access a key ("a") on a null variable in "%s" at line 1', false),
|
||||
array('{{ empty_array["a"] }}', 'Key "a" does not exist as the array is empty in "%s" at line 1', false),
|
||||
array('{{ array["a"] }}', 'Key "a" for array with keys "foo" does not exist in "%s" at line 1', false),
|
||||
array('{{ array_access["a"] }}', 'Key "a" in object with ArrayAccess of class "Twig_TemplateArrayAccessObject" does not exist in "%s" at line 1', false),
|
||||
array('{{ string.a }}', 'Impossible to access an attribute ("a") on a string variable ("foo") in "%s" at line 1', false),
|
||||
array('{{ string.a() }}', 'Impossible to invoke a method ("a") on a string variable ("foo") in "%s" at line 1', false),
|
||||
array('{{ null.a }}', 'Impossible to access an attribute ("a") on a null variable in "%s" at line 1', false),
|
||||
array('{{ null.a() }}', 'Impossible to invoke a method ("a") on a null variable in "%s" at line 1', false),
|
||||
array('{{ empty_array.a }}', 'Key "a" does not exist as the array is empty in "%s" at line 1', false),
|
||||
array('{{ array.a }}', 'Key "a" for array with keys "foo" does not exist in "%s" at line 1', false),
|
||||
array('{{ attribute(array, -10) }}', 'Key "-10" for array with keys "foo" does not exist in "%s" at line 1', false),
|
||||
array('{{ array_access.a }}', 'Neither the property "a" nor one of the methods "a()", "geta()"/"isa()" or "__call()" exist and have public access in class "Twig_TemplateArrayAccessObject" in "%s" at line 1', false),
|
||||
array('{% from _self import foo %}{% macro foo(obj) %}{{ obj.missing_method() }}{% endmacro %}{{ foo(array_access) }}', 'Neither the property "missing_method" nor one of the methods "missing_method()", "getmissing_method()"/"ismissing_method()" or "__call()" exist and have public access in class "Twig_TemplateArrayAccessObject" in "%s" at line 1', false),
|
||||
array('{{ string["a"] }}', 'Impossible to access a key ("a") on a string variable ("foo") in "%s" at line 1.', false),
|
||||
array('{{ null["a"] }}', 'Impossible to access a key ("a") on a null variable in "%s" at line 1.', false),
|
||||
array('{{ empty_array["a"] }}', 'Key "a" does not exist as the array is empty in "%s" at line 1.', false),
|
||||
array('{{ array["a"] }}', 'Key "a" for array with keys "foo" does not exist in "%s" at line 1.', false),
|
||||
array('{{ array_access["a"] }}', 'Key "a" in object with ArrayAccess of class "Twig_TemplateArrayAccessObject" does not exist in "%s" at line 1.', false),
|
||||
array('{{ string.a }}', 'Impossible to access an attribute ("a") on a string variable ("foo") in "%s" at line 1.', false),
|
||||
array('{{ string.a() }}', 'Impossible to invoke a method ("a") on a string variable ("foo") in "%s" at line 1.', false),
|
||||
array('{{ null.a }}', 'Impossible to access an attribute ("a") on a null variable in "%s" at line 1.', false),
|
||||
array('{{ null.a() }}', 'Impossible to invoke a method ("a") on a null variable in "%s" at line 1.', false),
|
||||
array('{{ empty_array.a }}', 'Key "a" does not exist as the array is empty in "%s" at line 1.', false),
|
||||
array('{{ array.a }}', 'Key "a" for array with keys "foo" does not exist in "%s" at line 1.', false),
|
||||
array('{{ attribute(array, -10) }}', 'Key "-10" for array with keys "foo" does not exist in "%s" at line 1.', false),
|
||||
array('{{ array_access.a }}', 'Neither the property "a" nor one of the methods "a()", "geta()"/"isa()" or "__call()" exist and have public access in class "Twig_TemplateArrayAccessObject" in "%s" at line 1.', false),
|
||||
array('{% from _self import foo %}{% macro foo(obj) %}{{ obj.missing_method() }}{% endmacro %}{{ foo(array_access) }}', 'Neither the property "missing_method" nor one of the methods "missing_method()", "getmissing_method()"/"ismissing_method()" or "__call()" exist and have public access in class "Twig_TemplateArrayAccessObject" in "%s" at line 1.', false),
|
||||
array('{{ magic_exception.test }}', 'An exception has been thrown during the rendering of a template ("Hey! Don\'t try to isset me!") in "%s" at line 1.', false),
|
||||
array('{{ object["a"] }}', 'Impossible to access a key "a" on an object of class "stdClass" that does not implement ArrayAccess interface in "%s" at line 1', false),
|
||||
array('{{ object["a"] }}', 'Impossible to access a key "a" on an object of class "stdClass" that does not implement ArrayAccess interface in "%s" at line 1.', false),
|
||||
);
|
||||
|
||||
if (function_exists('twig_template_get_attributes')) {
|
||||
@@ -387,9 +387,9 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
// tests when input is not an array or object
|
||||
$tests = array_merge($tests, array(
|
||||
array(false, null, 42, 'a', array(), $anyType, false, 'Impossible to access an attribute ("a") on a integer variable ("42")'),
|
||||
array(false, null, 'string', 'a', array(), $anyType, false, 'Impossible to access an attribute ("a") on a string variable ("string")'),
|
||||
array(false, null, array(), 'a', array(), $anyType, false, 'Key "a" does not exist as the array is empty'),
|
||||
array(false, null, 42, 'a', array(), $anyType, false, 'Impossible to access an attribute ("a") on a integer variable ("42").'),
|
||||
array(false, null, 'string', 'a', array(), $anyType, false, 'Impossible to access an attribute ("a") on a string variable ("string").'),
|
||||
array(false, null, array(), 'a', array(), $anyType, false, 'Key "a" does not exist as the array is empty.'),
|
||||
));
|
||||
|
||||
// add twig_template_get_attributes tests
|
||||
|
||||
Reference in New Issue
Block a user