Class Minify
Abstract minifier class.
Please report bugs on https://github.com/matthiasmullie/minify/issues
Namespace: MatthiasMullie\Minify
Copyright: Copyright (c) 2012, Matthias Mullie. All rights reserved
License: License
Author: Matthias Mullie minify@mullie.eu
Located at Sources/minify/src/Minify.php
public
|
|
public
|
|
public
string
|
|
public
string
|
|
public
Psr\Cache\CacheItemInterface
|
|
abstract public
string
|
|
protected
string
|
|
protected
|
|
protected
|
#
registerPattern( string $pattern, string|callable $replacement = '' )
Register a pattern to execute against the source content. |
protected
string
|
#
replace( string $content )
We can't "just" run some regular expressions against JavaScript: it's a complex language. E.g. having an occurrence of // xyz would be a comment, unless it's used within a string. Of you could have something that looks like a 'string', but inside a comment. The only way to accurately replace these pieces is to traverse the JS one character at a time and try to find whatever starts first. |
protected
string
|
#
replacePattern( string $pattern, string|callable $replacement, string $content )
This is where a pattern is matched against $content and the matches are replaced by their respective value. This function will be called plenty of times, where $content will always move up 1 character. |
protected
|
#
extractStrings( string[optional] $chars = '\'"' )
Strings are a pattern we need to match, in order to ignore potential code-like content inside them, but we just want all of the string content to remain untouched. |
protected
string
|
#
restoreExtractedData( string $content )
This method will restore all extracted data (strings, regexes) that were replaced with placeholder text in extract*(). The original content was saved in $this->extracted. |
protected
boolean
|
|
protected
resource
|
|
protected
|
#
writeToFile( resource $handler, string $content, string $path = '' )
Attempts to write $content to the file specified by $handler. $path is used for printing exceptions. |
protected
string[]
|
$data
The data to be minified. |
#
array()
|
protected
string[]
|
$patterns
Array of patterns to match. |
#
array()
|
public
string[]
|
$extracted
This array will hold content of strings and regular expressions that have been extracted from the JS source code, so we can reliably match "code", without having to worry about potential "code-like" characters inside. |
#
array()
|