1: | <?php
|
2: | class MinifierException extends \RuntimeException {} ;
|
3: | abstract class Minifier {
|
4: | const TOKEN_NONE = 0 ;
|
5: | const TOKEN_SPACE = 1 ;
|
6: | const TOKEN_NEWLINE = 2 ;
|
7: | const TOKEN_STRING = 3 ;
|
8: | const TOKEN_ELEMENT = 4 ;
|
9: | const TOKEN_IDENTIFIER = 5 ;
|
10: | protected $SingleLineComments = [] ;
|
11: | protected $MultiLineComments = [] ;
|
12: | protected $QuotedStrings = [] ;
|
13: | protected $Continuation = false ;
|
14: | protected $Spaces = [ " " => " ", "\t" => "\t", "\v" => "\v", "\r" => "\r", "\xA0" => "\xA0" ] ;
|
15: | protected $IdentifierRegex = false ;
|
16: | protected $Tokens = [] ;
|
17: | protected $Content ;
|
18: | protected $ContentLength ;
|
19: | protected $CurrentLine ;
|
20: | protected $LastToken ;
|
21: | protected $LastTokenType ;
|
22: | protected function Finalize ( )
|
23: | {}
|
24: | protected function SetComments ( $single_comments, $multi_comments )
|
25: | {}
|
26: | protected function SetQuotedStrings ( $strings )
|
27: | {}
|
28: | protected function SetContinuation ( $string )
|
29: | {}
|
30: | protected function SetSpaces ( $spaces )
|
31: | {}
|
32: | protected function SetIdentifierRegex ( $re )
|
33: | {}
|
34: | protected function SetTokens ( $tokens )
|
35: | {}
|
36: | protected function Reset ( $data = '' )
|
37: | {}
|
38: | abstract protected function MinifyData ( ) ;
|
39: | |
40: | |
41: | |
42: |
|
43: | public function Minify ( $contents )
|
44: | {}
|
45: | public function MinifyFrom ( $input )
|
46: | {}
|
47: | public function MinifyTo ( $output, $contents )
|
48: | {}
|
49: | public function MinifyFileTo ( $output, $input )
|
50: | {}
|
51: | protected function GetNextToken ( &$offset, &$token, &$token_type )
|
52: | {}
|
53: | protected function ProcessContinuation ( $contents, $length, &$offset, $continuation )
|
54: | {}
|
55: | protected function ProcessSingleLineComments ( $contents, $length, &$offset )
|
56: | {}
|
57: | protected function ProcessSpaces ( $contents, $length, &$offset, &$token, &$token_type )
|
58: | {}
|
59: | protected function EatSpaces ( $contents, $length, &$offset )
|
60: | {}
|
61: | protected function ProcessNewlines ( $contents, $length, &$offset, &$token, &$token_type )
|
62: | {}
|
63: | protected function ProcessMultiLineComments ( $contents, $length, &$offset )
|
64: | {}
|
65: | protected function ProcessString ( $contents, $length, &$offset, &$token, &$token_type )
|
66: | {}
|
67: | protected function ProcessToken ( $contents, $length, &$offset, &$token, &$token_type )
|
68: | {}
|
69: | }
|
70: | |