예제 #1
0
 protected function transform(Node $node)
 {
     // if left node is variable (can be used as an isset argument)
     if ($node->left instanceof Variable || $node->left instanceof PropertyFetch || $node->left instanceof StaticPropertyFetch || $node->left instanceof ArrayDimFetch) {
         // isset(x)
         $condition = new Isset_([$node->left]);
     } else {
         // !is_null(x)
         $condition = new BooleanNot(new FuncCall(new Name('is_null'), [new Arg($node->left)]));
     }
     $node = new Ternary($condition, $node->left, $node->right, $node->getAttributes() + ['changed' => true]);
     return $node;
 }
예제 #2
0
 protected function transform(Node $node)
 {
     $node = new Ternary(new Greater($node->left, $node->right), new LNumber(1), new Ternary(new Smaller($node->left, $node->right), new LNumber(-1), new LNumber(0)), $node->getAttributes() + ['changed' => true]);
     return $node;
 }