return $values < 0 ? mt_rand($values, 0) : mt_rand(0, $values);
}
- if ($values instanceof Traversable) {
+ if (is_object($values) && $values instanceof Traversable) {
$values = iterator_to_array($values);
} elseif (is_string($values)) {
if ('' === $values) {
*/
function twig_slice(Twig_Environment $env, $item, $start, $length = null, $preserveKeys = false)
{
- if ($item instanceof Traversable) {
+ if (is_object($item) && $item instanceof Traversable) {
$item = iterator_to_array($item, false);
}
*/
function twig_join_filter($value, $glue = '')
{
- if ($value instanceof Traversable) {
+ if (is_object($value) && $value instanceof Traversable) {
$value = iterator_to_array($value, false);
}
}
return false !== strpos($compare, (string) $value);
- } elseif ($compare instanceof Traversable) {
+ } elseif (is_object($compare) && $compare instanceof Traversable) {
return in_array($value, iterator_to_array($compare, false), is_object($value));
}
*/
function twig_array_batch($items, $size, $fill = null)
{
- if ($items instanceof Traversable) {
+ if (is_object($items) && $items instanceof Traversable) {
$items = iterator_to_array($items, false);
}