Debian Codegraph @

vendor/mck89/peast/lib/Peast/Syntax/Node/VariableDeclaration.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 a "var", "const" or "let" declaration.
14 * For example: var a = 1
15 *
16 * @author Marco Marchiò <[email protected]>
17 */
18 class VariableDeclaration extends Node implements Declaration
19 {
20 /**
21 * Map of node properties
22 *
23 * @var array
24 */
25 protected $propertiesMap = array(
26 "declarations" => true,
27 "kind" => false
28 );
29
30 //Kind constants
31 /**
32 * "var" kind
33 */
34 const KIND_VAR = "var";
35
36 /**
37 * "let" kind
38 */
39 const KIND_LET = "let";
40
41 /**
42 * "const" kind
43 */
44 const KIND_CONST = "const";
45
46 /**
47 * Declarations array
48 *
49 * @var VariableDeclarator[]
50 */
51 protected $declarations = array();
52
53 /**
54 * Declaration kind that is one of the kind constants
55 *
56 * @var string
57 */
58 protected $kind = self::KIND_VAR;
59
60 /**
61 * Returns the declarations array
62 *
63 * @return VariableDeclarator[]
64 */
65 public function getDeclarations()
66 {
67 return $this->declarations;
68 }
69
70 /**
71 * Sets the declarations array
72 *
73 * @param VariableDeclarator[] $declarations Declarations array
74 *
75 * @return $this
76 */
77 public function setDeclarations($declarations)
78 {
79 $this->assertArrayOf($declarations, "VariableDeclarator");
80 $this->declarations = $declarations;
81 return $this;
82 }
83
84 /**
85 * Returns the declaration kind that is one of the kind constants
86 *
87 * @return string
88 */
89 public function getKind()
90 {
91 return $this->kind;
92 }
93
94 /**
95 * Sets the declaration kind that is one of the kind constants
96 *
97 * @param string $kind Declaration kind
98 *
99 * @return $this
100 */
101 public function setKind($kind)
102 {
103 $this->kind = $kind;
104 return $this;
105 }
106 }