| 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 export named declaration. |
| 14 |
* For example: export {foo} from "bar" |
| 15 |
* |
| 16 |
* @author Marco Marchiò <[email protected]> |
| 17 |
*/ |
| 18 |
class ExportNamedDeclaration extends Node implements ModuleDeclaration |
| 19 |
{ |
| 20 |
/** |
| 21 |
* Map of node properties |
| 22 |
* |
| 23 |
* @var array |
| 24 |
*/ |
| 25 |
protected $propertiesMap = array( |
| 26 |
"declaration" => true, |
| 27 |
"specifiers" => true, |
| 28 |
"source" => true, |
| 29 |
"attributes" => true |
| 30 |
); |
| 31 |
|
| 32 |
/** |
| 33 |
* Exported declaration |
| 34 |
* |
| 35 |
* @var Declaration |
| 36 |
*/ |
| 37 |
protected $declaration; |
| 38 |
|
| 39 |
/** |
| 40 |
* Exported specifiers |
| 41 |
* |
| 42 |
* @var ExportSpecifier[] |
| 43 |
*/ |
| 44 |
protected $specifiers = array(); |
| 45 |
|
| 46 |
/** |
| 47 |
* Attributes array |
| 48 |
* |
| 49 |
* @var array |
| 50 |
*/ |
| 51 |
protected $attributes = array(); |
| 52 |
|
| 53 |
/** |
| 54 |
* The export source |
| 55 |
* |
| 56 |
* @var Literal |
| 57 |
*/ |
| 58 |
protected $source; |
| 59 |
|
| 60 |
/** |
| 61 |
* Returns the exported declaration |
| 62 |
* |
| 63 |
* @return Declaration |
| 64 |
*/ |
| 65 |
public function getDeclaration() |
| 66 |
{ |
| 67 |
return $this->declaration; |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* Sets the exported declaration |
| 72 |
* |
| 73 |
* @param Declaration $declaration Exported declaration |
| 74 |
* |
| 75 |
* @return $this |
| 76 |
*/ |
| 77 |
public function setDeclaration($declaration) |
| 78 |
{ |
| 79 |
$this->assertType($declaration, "Declaration", true); |
| 80 |
$this->declaration = $declaration; |
| 81 |
return $this; |
| 82 |
} |
| 83 |
|
| 84 |
/** |
| 85 |
* Return the exported specifiers |
| 86 |
* |
| 87 |
* @return ExportSpecifier[] |
| 88 |
*/ |
| 89 |
public function getSpecifiers() |
| 90 |
{ |
| 91 |
return $this->specifiers; |
| 92 |
} |
| 93 |
|
| 94 |
/** |
| 95 |
* Sets the exported specifiers |
| 96 |
* |
| 97 |
* @param ExportSpecifier[] $specifiers Exported specifiers |
| 98 |
* |
| 99 |
* @return $this |
| 100 |
*/ |
| 101 |
public function setSpecifiers($specifiers) |
| 102 |
{ |
| 103 |
$this->assertArrayOf($specifiers, "ExportSpecifier"); |
| 104 |
$this->specifiers = $specifiers; |
| 105 |
return $this; |
| 106 |
} |
| 107 |
|
| 108 |
/** |
| 109 |
* Returns the export source |
| 110 |
* |
| 111 |
* @return Literal |
| 112 |
*/ |
| 113 |
public function getSource() |
| 114 |
{ |
| 115 |
return $this->source; |
| 116 |
} |
| 117 |
|
| 118 |
/** |
| 119 |
* Sets the export source |
| 120 |
* |
| 121 |
* @param Literal $source Export source |
| 122 |
* |
| 123 |
* @return $this |
| 124 |
*/ |
| 125 |
public function setSource($source) |
| 126 |
{ |
| 127 |
$this->assertType($source, "Literal", true); |
| 128 |
$this->source = $source; |
| 129 |
return $this; |
| 130 |
} |
| 131 |
|
| 132 |
/** |
| 133 |
* Returns the attributes array |
| 134 |
* |
| 135 |
* @return array |
| 136 |
*/ |
| 137 |
public function getAttributes() |
| 138 |
{ |
| 139 |
return $this->attributes; |
| 140 |
} |
| 141 |
|
| 142 |
/** |
| 143 |
* Sets the attributes array |
| 144 |
* |
| 145 |
* @param array $attributes Attributes array |
| 146 |
* |
| 147 |
* @return $this |
| 148 |
*/ |
| 149 |
public function setAttributes($attributes) |
| 150 |
{ |
| 151 |
$this->assertArrayOf($attributes, "ImportAttribute"); |
| 152 |
$this->attributes = $attributes; |
| 153 |
return $this; |
| 154 |
} |
| 155 |
} |