Skip to content

Commit 7bddf75

Browse files
committed
Fix PHP 7.0 compatibility, is_iterable() doesn't exist there
1 parent b72f4e4 commit 7bddf75

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/php/lang/ast/syntax/php/IsOperator.class.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,17 @@ public function setup($language, $emitter) {
3030
'bool' => true,
3131
'array' => true,
3232
'object' => true,
33-
'iterable' => true,
3433
'callable' => true
3534
];
3635

37-
if (isset($is[$literal])) {
36+
// PHP 7.0 compatibility, is_iterable() doesn't exist there
37+
if ('iterable' === $literal) {
38+
return new BinaryExpression(
39+
new InstanceOfExpression($expr, '\Traversable'),
40+
'||',
41+
new InvokeExpression(new Literal('is_array'), [$expr])
42+
);
43+
} else if (isset($is[$literal])) {
3844
return new InvokeExpression(new Literal('is_'.$literal), [$expr]);
3945
} else {
4046
return new InstanceOfExpression($expr, new Literal($literal));

0 commit comments

Comments
 (0)