Debian Codegraph @

vendor/mck89/peast/lib/Peast/Syntax/Node/ArrowFunctionExpression.php

raw
1 <?php
2 /**
3 * This file is part of the Peast package
4 *
5 * (c) Marco Marchiò <[email protected]>
6 *
7 * For the full copyright and license information refer to the LICENSE file
8 * distributed with this source code
9 */
10 namespace Peast\Syntax\Node;
11
12 /**
13 * A node that represents an arrow function.
14 * For example: var fn = (a, b) => console.log(a, b)
15 *
16 * @author Marco Marchiò <[email protected]>
17 */
18 class ArrowFunctionExpression extends Function_ implements Expression
19 {
20 /**
21 * Map of node properties
22 *
23 * @var array
24 */
25 protected $propertiesMap = array(
26 "expression" => false
27 );
28
29 /**
30 * This flag is true when function body is wrapped in curly braces
31 *
32 * @var bool
33 */
34 protected $expression = false;
35
36 /**
37 * Sets the function body
38 *
39 * @param BlockStatement|Expression $body Function body
40 *
41 * @return $this
42 */
43 public function setBody($body)
44 {
45 $this->assertType($body, array("BlockStatement", "Expression"));
46 $this->body = $body;
47 return $this;
48 }
49
50 /**
51 * Returns the expression flag
52 *
53 * @return bool
54 */
55 public function getExpression()
56 {
57 return $this->expression;
58 }
59
60 /**
61 * Sets the expression flag
62 *
63 * @param bool $expression Expression flag
64 *
65 * @return $this
66 */
67 public function setExpression($expression)
68 {
69 $this->expression = (bool) $expression;
70 return $this;
71 }
72 }