mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-10 09:26:29 +00:00
bug #2749 Fixed ArrayObject access with a null value (yceruto)
This PR was merged into the 1.x branch.
Discussion
----------
Fixed ArrayObject access with a null value
fixes https://github.com/twigphp/Twig/issues/2744
Commits
-------
80e65b4c fixed ArrayObject access with a null value
This commit is contained in:
@@ -508,9 +508,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
||||
if (self::METHOD_CALL !== $type) {
|
||||
$arrayItem = is_bool($item) || is_float($item) ? (int) $item : $item;
|
||||
|
||||
if ((is_array($object) && (isset($object[$arrayItem]) || array_key_exists($arrayItem, $object)))
|
||||
|| ($object instanceof ArrayAccess && isset($object[$arrayItem]))
|
||||
) {
|
||||
if ((is_array($object) || $object instanceof ArrayAccess) && (isset($object[$arrayItem]) || array_key_exists($arrayItem, $object))) {
|
||||
if ($isDefinedTest) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -315,6 +315,7 @@ class Twig_Tests_TemplateTest extends \PHPUnit\Framework\TestCase
|
||||
];
|
||||
|
||||
$objectArray = new Twig_TemplateArrayAccessObject();
|
||||
$arrayObject = new ArrayObject($array);
|
||||
$stdObject = (object) $array;
|
||||
$magicPropertyObject = new Twig_TemplateMagicPropertyObject();
|
||||
$propertyObject = new Twig_TemplatePropertyObject();
|
||||
@@ -346,6 +347,7 @@ class Twig_Tests_TemplateTest extends \PHPUnit\Framework\TestCase
|
||||
// array(object, type of fetch)
|
||||
[$array, $arrayType],
|
||||
[$objectArray, $arrayType],
|
||||
[$arrayObject, $anyType],
|
||||
[$stdObject, $anyType],
|
||||
[$magicPropertyObject, $anyType],
|
||||
[$methodObject, $methodType],
|
||||
|
||||
Reference in New Issue
Block a user