@@ -120,9 +120,7 @@ public static function minify($js, $options = array())
120
120
unset($ jshrink );
121
121
122
122
return $ js ;
123
-
124
123
} catch (\Exception $ e ) {
125
-
126
124
if (isset ($ jshrink )) {
127
125
// Since the breakdownScript function probably wasn't finished
128
126
// we clean it out before discarding it.
@@ -181,7 +179,6 @@ protected function initialize($js, $options)
181
179
protected function loop ()
182
180
{
183
181
while ($ this ->a !== false && !is_null ($ this ->a ) && $ this ->a !== '' ) {
184
-
185
182
switch ($ this ->a ) {
186
183
// new lines
187
184
case "\n" :
@@ -194,14 +191,17 @@ protected function loop()
194
191
195
192
// if B is a space we skip the rest of the switch block and go down to the
196
193
// string/regex check below, resetting $this->b with getReal
197
- if ($ this ->b === ' ' )
194
+ if ($ this ->b === ' ' ) {
198
195
break ;
196
+ }
199
197
200
198
// otherwise we treat the newline like a space
201
199
200
+ // no break
202
201
case ' ' :
203
- if (static ::isAlphaNumeric ($ this ->b ))
202
+ if (static ::isAlphaNumeric ($ this ->b )) {
204
203
echo $ this ->a ;
204
+ }
205
205
206
206
$ this ->saveString ();
207
207
break ;
@@ -222,9 +222,11 @@ protected function loop()
222
222
break ;
223
223
224
224
case ' ' :
225
- if (!static ::isAlphaNumeric ($ this ->a ))
225
+ if (!static ::isAlphaNumeric ($ this ->a )) {
226
226
break ;
227
+ }
227
228
229
+ // no break
228
230
default :
229
231
// check for some regex that breaks stuff
230
232
if ($ this ->a === '/ ' && ($ this ->b === '\'' || $ this ->b === '" ' )) {
@@ -241,8 +243,9 @@ protected function loop()
241
243
// do reg check of doom
242
244
$ this ->b = $ this ->getReal ();
243
245
244
- if (($ this ->b == '/ ' && strpos ('(,=:[!&|? ' , $ this ->a ) !== false ))
246
+ if (($ this ->b == '/ ' && strpos ('(,=:[!&|? ' , $ this ->a ) !== false )) {
245
247
$ this ->saveRegex ();
248
+ }
246
249
}
247
250
}
248
251
@@ -272,7 +275,7 @@ protected function getChar()
272
275
$ char = $ this ->c ;
273
276
unset($ this ->c );
274
277
275
- // Otherwise we start pulling from the input.
278
+ // Otherwise we start pulling from the input.
276
279
} else {
277
280
$ char = substr ($ this ->input , $ this ->index , 1 );
278
281
@@ -287,9 +290,9 @@ protected function getChar()
287
290
288
291
// Normalize all whitespace except for the newline character into a
289
292
// standard space.
290
- if ($ char !== "\n" && ord ($ char ) < 32 )
291
-
293
+ if ($ char !== "\n" && ord ($ char ) < 32 ) {
292
294
return ' ' ;
295
+ }
293
296
294
297
return $ char ;
295
298
}
@@ -320,7 +323,6 @@ protected function getReal()
320
323
$ this ->processOneLineComments ($ startIndex );
321
324
322
325
return $ this ->getReal ();
323
-
324
326
} elseif ($ this ->c === '* ' ) {
325
327
$ this ->processMultiLineComments ($ startIndex );
326
328
@@ -367,14 +369,13 @@ protected function processMultiLineComments($startIndex)
367
369
368
370
// kill everything up to the next */ if it's there
369
371
if ($ this ->getNext ('*/ ' )) {
370
-
371
372
$ this ->getChar (); // get *
372
373
$ this ->getChar (); // get /
373
374
$ char = $ this ->getChar (); // get next real character
374
375
375
376
// Now we reinsert conditional comments and YUI-style licensing comments
376
377
if (($ this ->options ['flaggedComments ' ] && $ thirdCommentString === '! ' )
377
- || ($ thirdCommentString === '@ ' ) ) {
378
+ || ($ thirdCommentString === '@ ' )) {
378
379
379
380
// If conditional comments or flagged comments are not the first thing in the script
380
381
// we need to echo a and fill it with a space before moving on.
@@ -395,13 +396,13 @@ protected function processMultiLineComments($startIndex)
395
396
396
397
return ;
397
398
}
398
-
399
399
} else {
400
400
$ char = false ;
401
401
}
402
402
403
- if ($ char === false )
403
+ if ($ char === false ) {
404
404
throw new \RuntimeException ('Unclosed multiline comment at position: ' . ($ this ->index - 2 ));
405
+ }
405
406
406
407
// if we're here c is part of the comment and therefore tossed
407
408
$ this ->c = $ char ;
@@ -421,9 +422,9 @@ protected function getNext($string)
421
422
$ pos = strpos ($ this ->input , $ string , $ this ->index );
422
423
423
424
// If it's not there return false.
424
- if ($ pos === false )
425
-
425
+ if ($ pos === false ) {
426
426
return false ;
427
+ }
427
428
428
429
// Adjust position of index to jump ahead to the asked for string
429
430
$ this ->index = $ pos ;
@@ -479,7 +480,7 @@ protected function saveString()
479
480
if ($ stringType === '` ' ) {
480
481
echo $ this ->a ;
481
482
} else {
482
- throw new \RuntimeException ('Unclosed string at position: ' . $ startpos );
483
+ throw new \RuntimeException ('Unclosed string at position: ' . $ startpos );
483
484
}
484
485
break ;
485
486
@@ -520,16 +521,18 @@ protected function saveRegex()
520
521
echo $ this ->a . $ this ->b ;
521
522
522
523
while (($ this ->a = $ this ->getChar ()) !== false ) {
523
- if ($ this ->a === '/ ' )
524
+ if ($ this ->a === '/ ' ) {
524
525
break ;
526
+ }
525
527
526
528
if ($ this ->a === '\\' ) {
527
529
echo $ this ->a ;
528
530
$ this ->a = $ this ->getChar ();
529
531
}
530
532
531
- if ($ this ->a === "\n" )
533
+ if ($ this ->a === "\n" ) {
532
534
throw new \RuntimeException ('Unclosed regex pattern at position: ' . $ this ->index );
535
+ }
533
536
534
537
echo $ this ->a ;
535
538
}
@@ -590,5 +593,4 @@ protected function unlock($js)
590
593
591
594
return $ js ;
592
595
}
593
-
594
596
}
0 commit comments