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