1414
1515class Source
1616{
17- const TYPE_OFFSET = 0 ;
18- const STRING_OFFSET = 1 ;
17+ public const TYPE_OFFSET = 0 ;
18+ public const STRING_OFFSET = 1 ;
1919
20- const PREPEND = 'PREPEND ' ;
21- const APPEND = 'APPEND ' ;
22- const OVERWRITE = 'OVERWRITE ' ;
20+ public const PREPEND = 'PREPEND ' ;
21+ public const APPEND = 'APPEND ' ;
22+ public const OVERWRITE = 'OVERWRITE ' ;
2323
24- const ANY = null ;
24+ public const ANY = null ;
2525
2626 public $ tokens ;
2727 public $ tokensByType ;
@@ -37,13 +37,13 @@ class Source
3737 public $ tokensByLevelAndType ;
3838 public $ cache ;
3939
40- function __construct ($ string )
40+ public function __construct ($ string )
4141 {
4242 $ this ->code = $ string ;
4343 $ this ->initialize ();
4444 }
4545
46- function initialize ()
46+ public function initialize ()
4747 {
4848 $ this ->tokens = Utils \tokenize ($ this ->code );
4949 $ this ->tokens [] = [T_WHITESPACE , "" ];
@@ -55,15 +55,15 @@ function initialize()
5555 $ this ->cache = [];
5656 }
5757
58- function indexTokensByType ()
58+ public function indexTokensByType ()
5959 {
6060 $ this ->tokensByType = [];
6161 foreach ($ this ->tokens as $ offset => $ token ) {
6262 $ this ->tokensByType [$ token [self ::TYPE_OFFSET ]][] = $ offset ;
6363 }
6464 }
6565
66- function collectBracketMatchings ()
66+ public function collectBracketMatchings ()
6767 {
6868 $ this ->matchingBrackets = [];
6969 $ stack = [];
@@ -89,7 +89,7 @@ function collectBracketMatchings()
8989 }
9090 }
9191
92- function collectLevelInfo ()
92+ public function collectLevelInfo ()
9393 {
9494 $ level = 0 ;
9595 $ this ->levels = [];
@@ -123,7 +123,7 @@ function collectLevelInfo()
123123 Utils \appendUnder ($ this ->levelEndings , 0 , count ($ this ->tokens ) - 1 );
124124 }
125125
126- function has ($ types )
126+ public function has ($ types )
127127 {
128128 foreach ((array ) $ types as $ type ) {
129129 if ($ this ->all ($ type ) !== []) {
@@ -133,7 +133,7 @@ function has($types)
133133 return false ;
134134 }
135135
136- function is ($ types , $ offset )
136+ public function is ($ types , $ offset )
137137 {
138138 foreach ((array ) $ types as $ type ) {
139139 if ($ this ->tokens [$ offset ][self ::TYPE_OFFSET ] === $ type ) {
@@ -143,7 +143,7 @@ function is($types, $offset)
143143 return false ;
144144 }
145145
146- function skip ($ types , $ offset , $ direction = 1 )
146+ public function skip ($ types , $ offset , $ direction = 1 )
147147 {
148148 $ offset += $ direction ;
149149 $ types = (array ) $ types ;
@@ -156,12 +156,12 @@ function skip($types, $offset, $direction = 1)
156156 return ($ direction > 0 ) ? INF : -1 ;
157157 }
158158
159- function skipBack ($ types , $ offset )
159+ public function skipBack ($ types , $ offset )
160160 {
161161 return $ this ->skip ($ types , $ offset , -1 );
162162 }
163163
164- function within ($ types , $ low , $ high )
164+ public function within ($ types , $ low , $ high )
165165 {
166166 $ result = [];
167167 foreach ((array ) $ types as $ type ) {
@@ -171,7 +171,7 @@ function within($types, $low, $high)
171171 return $ result ;
172172 }
173173
174- function read ($ offset , $ count = 1 )
174+ public function read ($ offset , $ count = 1 )
175175 {
176176 $ result = '' ;
177177 $ pos = $ offset ;
@@ -186,7 +186,7 @@ function read($offset, $count = 1)
186186 return $ result ;
187187 }
188188
189- function siblings ($ types , $ offset )
189+ public function siblings ($ types , $ offset )
190190 {
191191 $ level = $ this ->levels [$ offset ];
192192 $ begin = Utils \lastNotGreaterThan (Utils \access ($ this ->levelBeginnings , $ level , []), $ offset );
@@ -203,7 +203,7 @@ function siblings($types, $offset)
203203 }
204204 }
205205
206- function next ($ types , $ offset )
206+ public function next ($ types , $ offset )
207207 {
208208 if (!is_array ($ types )) {
209209 $ candidates = Utils \access ($ this ->tokensByType , $ types , []);
@@ -216,7 +216,7 @@ function next($types, $offset)
216216 return $ result ;
217217 }
218218
219- function all ($ types )
219+ public function all ($ types )
220220 {
221221 if (!is_array ($ types )) {
222222 return Utils \access ($ this ->tokensByType , $ types , []);
@@ -229,13 +229,13 @@ function all($types)
229229 return $ result ;
230230 }
231231
232- function match ($ offset )
232+ public function match ($ offset )
233233 {
234234 $ offset = (string ) $ offset ;
235235 return isset ($ this ->matchingBrackets [$ offset ]) ? $ this ->matchingBrackets [$ offset ] : INF ;
236236 }
237237
238- function splice ($ splice , $ offset , $ length = 0 , $ policy = self ::OVERWRITE )
238+ public function splice ($ splice , $ offset , $ length = 0 , $ policy = self ::OVERWRITE )
239239 {
240240 if ($ policy === self ::OVERWRITE ) {
241241 $ this ->splices [$ offset ] = $ splice ;
@@ -256,7 +256,7 @@ function splice($splice, $offset, $length = 0, $policy = self::OVERWRITE)
256256 $ this ->code = null ;
257257 }
258258
259- function createCodeFromTokens ()
259+ public function createCodeFromTokens ()
260260 {
261261 $ splices = $ this ->splices ;
262262 $ code = "" ;
@@ -274,28 +274,28 @@ function createCodeFromTokens()
274274 $ this ->code = $ code ;
275275 }
276276
277- static function junk ()
277+ public static function junk ()
278278 {
279279 return [T_WHITESPACE , T_COMMENT , T_DOC_COMMENT ];
280280 }
281281
282- function __toString ()
282+ public function __toString ()
283283 {
284284 if ($ this ->code === null ) {
285285 $ this ->createCodeFromTokens ();
286286 }
287287 return (string ) $ this ->code ;
288288 }
289289
290- function flush ()
290+ public function flush ()
291291 {
292292 $ this ->initialize (Utils \tokenize ($ this ));
293293 }
294294
295295 /**
296296 * @since 2.1.0
297297 */
298- function cache (array $ args , \Closure $ function )
298+ public function cache (array $ args , \Closure $ function )
299299 {
300300 $ found = true ;
301301 $ trace = debug_backtrace ()[1 ];
0 commit comments