1 | <?php |
||
25 | class StreamMetaData |
||
26 | { |
||
27 | /** |
||
28 | * Mapping between array keys and properties |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | private static $propertyMap = [ |
||
33 | 'stream_type' => 'streamType', |
||
34 | 'wrapper_type' => 'wrapperType', |
||
35 | 'wrapper_data' => 'wrapperData', |
||
36 | 'filters' => 'filterList', |
||
37 | 'uri' => 'uri', |
||
38 | ]; |
||
39 | |||
40 | /** |
||
41 | * A label describing the underlying implementation of the stream. |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | public $streamType; |
||
46 | |||
47 | /** |
||
48 | * A label describing the protocol wrapper implementation layered over the stream. |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | public $wrapperType; |
||
53 | |||
54 | /** |
||
55 | * Wrapper-specific data attached to this stream. |
||
56 | * |
||
57 | * @var mixed |
||
58 | */ |
||
59 | public $wrapperData; |
||
60 | |||
61 | /** |
||
62 | * Array containing the names of any filters that have been stacked onto this stream. |
||
63 | * |
||
64 | * @var array |
||
65 | */ |
||
66 | public $filterList; |
||
67 | |||
68 | /** |
||
69 | * The URI/filename associated with this stream. |
||
70 | * |
||
71 | * @var string |
||
72 | */ |
||
73 | public $uri; |
||
74 | |||
75 | /** |
||
76 | * Information about syntax tree |
||
77 | * |
||
78 | * @var Node[] |
||
79 | */ |
||
80 | public $syntaxTree; |
||
81 | |||
82 | /** |
||
83 | * List of source tokens |
||
84 | * |
||
85 | * @var array |
||
86 | */ |
||
87 | public $tokenStream = []; |
||
88 | |||
89 | /** |
||
90 | * Creates metadata object from stream |
||
91 | * |
||
92 | * @param resource $stream Instance of stream |
||
93 | * @param string $source Source code or null |
||
94 | * @throws \InvalidArgumentException for invalid stream |
||
95 | */ |
||
96 | 34 | public function __construct($stream, string $source = null) |
|
115 | |||
116 | /** |
||
117 | * @inheritDoc |
||
118 | */ |
||
119 | 34 | public function __get($name) |
|
127 | |||
128 | /** |
||
129 | * @inheritDoc |
||
130 | */ |
||
131 | public function __set($name, $value) |
||
138 | |||
139 | /** |
||
140 | * Returns source code directly from tokens |
||
141 | */ |
||
142 | 34 | private function getSource(): string |
|
151 | |||
152 | /** |
||
153 | * Sets the new source for this file |
||
154 | * |
||
155 | * @TODO: Unfortunately, AST won't be changed, so please be accurate during transformation |
||
156 | * |
||
157 | * @param string $newSource |
||
158 | */ |
||
159 | 34 | private function setSource(string $newSource): void |
|
164 | |||
165 | 34 | /** |
|
166 | * Sets an array of token identifiers for this file |
||
167 | * |
||
168 | * @param array $rawTokens |
||
169 | */ |
||
170 | public function setTokenStreamFromRawTokens($rawTokens): void |
||
176 | } |
||
177 |