| 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 declaration in a VariableDeclaration node. |
| 14 |
* For example "a=1" in: var a = 1 |
| 15 |
* |
| 16 |
* @author Marco Marchiò <[email protected]> |
| 17 |
*/ |
| 18 |
class VariableDeclarator extends Node |
| 19 |
{ |
| 20 |
/** |
| 21 |
* Map of node properties |
| 22 |
* |
| 23 |
* @var array |
| 24 |
*/ |
| 25 |
protected $propertiesMap = array( |
| 26 |
"id" => true, |
| 27 |
"init" => true |
| 28 |
); |
| 29 |
|
| 30 |
/** |
| 31 |
* Declaration identifier or pattern |
| 32 |
* |
| 33 |
* @var Pattern |
| 34 |
*/ |
| 35 |
protected $id; |
| 36 |
|
| 37 |
/** |
| 38 |
* Optional initializer |
| 39 |
* |
| 40 |
* @var Expression |
| 41 |
*/ |
| 42 |
protected $init; |
| 43 |
|
| 44 |
/** |
| 45 |
* Returns the declaration identifier or pattern |
| 46 |
* |
| 47 |
* @return Pattern |
| 48 |
*/ |
| 49 |
public function getId() |
| 50 |
{ |
| 51 |
return $this->id; |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Sets the declaration identifier or pattern |
| 56 |
* |
| 57 |
* @param Pattern $id Declaration identifier or pattern |
| 58 |
* |
| 59 |
* @return $this |
| 60 |
*/ |
| 61 |
public function setId(Pattern $id) |
| 62 |
{ |
| 63 |
$this->id = $id; |
| 64 |
return $this; |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* Returns the initializer |
| 69 |
* |
| 70 |
* @return Expression |
| 71 |
*/ |
| 72 |
public function getInit() |
| 73 |
{ |
| 74 |
return $this->init; |
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* Sets the initializer |
| 79 |
* |
| 80 |
* @param Expression $init Initializer |
| 81 |
* |
| 82 |
* @return $this |
| 83 |
*/ |
| 84 |
public function setInit($init) |
| 85 |
{ |
| 86 |
$this->assertType($init, "Expression", true); |
| 87 |
$this->init = $init; |
| 88 |
return $this; |
| 89 |
} |
| 90 |
} |