Rev 1042 | Rev 1469 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1042 | Rev 1308 | ||
---|---|---|---|
Line 630... | Line 630... | ||
630 | /** |
630 | /** |
631 | * Strip comments from source code. |
631 | * Strip comments from source code. |
632 | */ |
632 | */ |
633 | protected function stripComments() |
633 | protected function stripComments() |
634 | { |
634 | { |
635 | // PHP only supports $this inside anonymous functions since 5.4 |
- | |
636 | $minifier = $this; |
- | |
637 | $callback = function ($match) use ($minifier) { |
- | |
638 | $count = count($minifier->extracted); |
- | |
639 | $placeholder = '/*' . $count . '*/'; |
- | |
640 | $minifier->extracted[$placeholder] = $match[0]; |
- | |
641 | - | ||
642 | return $placeholder; |
- | |
643 | }; |
- | |
644 | $this->registerPattern('/\n?\/\*(!|.*?@license|.*?@preserve).*?\*\/\n?/s', $callback); |
- | |
645 | - | ||
646 | $this->registerPattern('/\/\*.*?\*\//s', ''); |
635 | $this->stripMultilineComments(); |
647 | } |
636 | } |
648 | 637 | ||
649 | /** |
638 | /** |
650 | * Strip whitespace. |
639 | * Strip whitespace. |
651 | * |
640 | * |