1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 * (c) Armin Ronacher
8 *
9 * For the full copyright and license information, please view the LICENSE
10 * file that was distributed with this source code.
11 */
12
13namespace Twig\Node\Expression;
14
15use Twig\Node\Node;
16
17/**
18 * Abstract class for all nodes that represents an expression.
19 *
20 * @author Fabien Potencier <fabien@symfony.com>
21 */
22abstract class AbstractExpression extends Node
23{
24    public function isGenerator(): bool
25    {
26        return $this->hasAttribute('is_generator') && $this->getAttribute('is_generator');
27    }
28
29    /**
30     * @return static
31     */
32    public function setExplicitParentheses(): self
33    {
34        $this->setAttribute('with_parentheses', true);
35
36        return $this;
37    }
38
39    public function hasExplicitParentheses(): bool
40    {
41        return $this->hasAttribute('with_parentheses') && $this->getAttribute('with_parentheses');
42    }
43}
44