-
-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
099f5ec
commit de4bcf2
Showing
4 changed files
with
50 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
* | ||
* @author Matthias Mullie <[email protected]> | ||
* @author Tijs Verkoyen <[email protected]> | ||
* @copyright Copyright (c) 2012, Matthias Mullie. All rights reserved. | ||
* @copyright Copyright (c) 2012, Matthias Mullie. All rights reserved | ||
* @license MIT License | ||
*/ | ||
class CSS extends Minify | ||
|
@@ -83,7 +83,7 @@ protected function moveImportsToTop($content) | |
|
||
// add to top | ||
$content = implode('', $matches[0]).$content; | ||
}; | ||
} | ||
|
||
return $content; | ||
} | ||
|
@@ -94,9 +94,9 @@ protected function moveImportsToTop($content) | |
* @import's will be loaded and their content merged into the original file, | ||
* to save HTTP requests. | ||
* | ||
* @param string $source The file to combine imports for. | ||
* @param string $content The CSS content to combine imports for. | ||
* @param string[] $parents Parent paths, for circular reference checks. | ||
* @param string $source The file to combine imports for | ||
* @param string $content The CSS content to combine imports for | ||
* @param string[] $parents Parent paths, for circular reference checks | ||
* | ||
* @return string | ||
* | ||
|
@@ -246,8 +246,8 @@ protected function combineImports($source, $content, $parents) | |
* @url(image.jpg) images will be loaded and their content merged into the | ||
* original file, to save HTTP requests. | ||
* | ||
* @param string $source The file to import files for. | ||
* @param string $content The CSS content to import files for. | ||
* @param string $source The file to import files for | ||
* @param string $content The CSS content to import files for | ||
* | ||
* @return string | ||
*/ | ||
|
@@ -290,10 +290,10 @@ protected function importFiles($source, $content) | |
* Minify the data. | ||
* Perform CSS optimizations. | ||
* | ||
* @param string[optional] $path Path to write the data to. | ||
* @param string[] $parents Parent paths, for circular reference checks. | ||
* @param string[optional] $path Path to write the data to | ||
* @param string[] $parents Parent paths, for circular reference checks | ||
* | ||
* @return string The minified data. | ||
* @return string The minified data | ||
*/ | ||
public function execute($path = null, $parents = array()) | ||
{ | ||
|
@@ -351,7 +351,7 @@ public function execute($path = null, $parents = array()) | |
* (e.g. ../../images/image.gif, if the new CSS file is 1 folder deeper). | ||
* | ||
* @param Converter $converter Relative path converter | ||
* @param string $content The CSS content to update relative urls for. | ||
* @param string $content The CSS content to update relative urls for | ||
* | ||
* @return string | ||
*/ | ||
|
@@ -479,7 +479,7 @@ protected function move(Converter $converter, $content) | |
* Shorthand hex color codes. | ||
* #FF0000 -> #F00. | ||
* | ||
* @param string $content The CSS content to shorten the hex color codes for. | ||
* @param string $content The CSS content to shorten the hex color codes for | ||
* | ||
* @return string | ||
*/ | ||
|
@@ -524,7 +524,7 @@ protected function shortenHex($content) | |
/** | ||
* Shorten CSS font weights. | ||
* | ||
* @param string $content The CSS content to shorten the font weights for. | ||
* @param string $content The CSS content to shorten the font weights for | ||
* | ||
* @return string | ||
*/ | ||
|
@@ -536,7 +536,7 @@ protected function shortenFontWeights($content) | |
); | ||
|
||
$callback = function ($match) use ($weights) { | ||
return $match[1] . $weights[$match[2]]; | ||
return $match[1].$weights[$match[2]]; | ||
}; | ||
|
||
return preg_replace_callback('/(font-weight\s*:\s*)('.implode('|', array_keys($weights)).')(?=[;}])/', $callback, $content); | ||
|
@@ -545,7 +545,7 @@ protected function shortenFontWeights($content) | |
/** | ||
* Shorthand 0 values to plain 0, instead of e.g. -0em. | ||
* | ||
* @param string $content The CSS content to shorten the zero values for. | ||
* @param string $content The CSS content to shorten the zero values for | ||
* | ||
* @return string | ||
*/ | ||
|
@@ -586,7 +586,7 @@ protected function shortenZeroes($content) | |
do { | ||
$previous = $content; | ||
$content = preg_replace('/\(([^\(\)]+)\s+[\+\-]\s+0(\s+[^\(\)]+)?\)/', '(\\1\\2)', $content); | ||
} while ( $content !== $previous ); | ||
} while ($content !== $previous); | ||
// strip all `0 +` occurrences: calc(0 + 10%) -> calc(10%) | ||
$content = preg_replace('/\(\s*0\s+\+\s+([^\(\)]+)\)/', '(\\1)', $content); | ||
// strip all `0 -` occurrences: calc(0 - 10%) -> calc(-10%) | ||
|
@@ -623,7 +623,7 @@ protected function stripComments() | |
/** | ||
* Strip whitespace. | ||
* | ||
* @param string $content The CSS content to strip the whitespace for. | ||
* @param string $content The CSS content to strip the whitespace for | ||
* | ||
* @return string | ||
*/ | ||
|
@@ -657,7 +657,7 @@ protected function stripWhitespace($content) | |
/** | ||
* Check if file is small enough to be imported. | ||
* | ||
* @param string $path The path to the file. | ||
* @param string $path The path to the file | ||
* | ||
* @return bool | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
* | ||
* @author Matthias Mullie <[email protected]> | ||
* @author Tijs Verkoyen <[email protected]> | ||
* @copyright Copyright (c) 2012, Matthias Mullie. All rights reserved. | ||
* @copyright Copyright (c) 2012, Matthias Mullie. All rights reserved | ||
* @license MIT License | ||
*/ | ||
class JS extends Minify | ||
|
@@ -131,9 +131,9 @@ public function __construct() | |
* Minify the data. | ||
* Perform JS optimizations. | ||
* | ||
* @param string[optional] $path Path to write the data to. | ||
* @param string[optional] $path Path to write the data to | ||
* | ||
* @return string The minified data. | ||
* @return string The minified data | ||
*/ | ||
public function execute($path = null) | ||
{ | ||
|
@@ -252,7 +252,7 @@ protected function extractRegex() | |
* Because it's sometimes hard to tell if a newline is part of a statement | ||
* that should be terminated or not, we'll just leave some of them alone. | ||
* | ||
* @param string $content The content to strip the whitespace for. | ||
* @param string $content The content to strip the whitespace for | ||
* | ||
* @return string | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
* Please report bugs on https://github.com/matthiasmullie/minify/issues | ||
* | ||
* @author Matthias Mullie <[email protected]> | ||
* @copyright Copyright (c) 2012, Matthias Mullie. All rights reserved. | ||
* @copyright Copyright (c) 2012, Matthias Mullie. All rights reserved | ||
* @license MIT License | ||
*/ | ||
abstract class Minify | ||
|
@@ -85,9 +85,9 @@ public function add($data /* $data = null, ... */) | |
/** | ||
* Minify the data & (optionally) saves it to a file. | ||
* | ||
* @param string[optional] $path Path to write the data to. | ||
* @param string[optional] $path Path to write the data to | ||
* | ||
* @return string The minified data. | ||
* @return string The minified data | ||
*/ | ||
public function minify($path = null) | ||
{ | ||
|
@@ -104,10 +104,10 @@ public function minify($path = null) | |
/** | ||
* Minify & gzip the data & (optionally) saves it to a file. | ||
* | ||
* @param string[optional] $path Path to write the data to. | ||
* @param int[optional] $level Compression level, from 0 to 9. | ||
* @param string[optional] $path Path to write the data to | ||
* @param int[optional] $level Compression level, from 0 to 9 | ||
* | ||
* @return string The minified & gzipped data. | ||
* @return string The minified & gzipped data | ||
*/ | ||
public function gzip($path = null, $level = 9) | ||
{ | ||
|
@@ -125,9 +125,9 @@ public function gzip($path = null, $level = 9) | |
/** | ||
* Minify the data & write it to a CacheItemInterface object. | ||
* | ||
* @param CacheItemInterface $item Cache item to write the data to. | ||
* @param CacheItemInterface $item Cache item to write the data to | ||
* | ||
* @return CacheItemInterface Cache item with the minifier data. | ||
* @return CacheItemInterface Cache item with the minifier data | ||
*/ | ||
public function cache(CacheItemInterface $item) | ||
{ | ||
|
@@ -140,16 +140,16 @@ public function cache(CacheItemInterface $item) | |
/** | ||
* Minify the data. | ||
* | ||
* @param string[optional] $path Path to write the data to. | ||
* @param string[optional] $path Path to write the data to | ||
* | ||
* @return string The minified data. | ||
* @return string The minified data | ||
*/ | ||
abstract public function execute($path = null); | ||
|
||
/** | ||
* Load data. | ||
* | ||
* @param string $data Either a path to a file or the content itself. | ||
* @param string $data Either a path to a file or the content itself | ||
* | ||
* @return string | ||
*/ | ||
|
@@ -171,8 +171,8 @@ protected function load($data) | |
/** | ||
* Save to file. | ||
* | ||
* @param string $content The minified data. | ||
* @param string $path The path to save the minified data to. | ||
* @param string $content The minified data | ||
* @param string $path The path to save the minified data to | ||
* | ||
* @throws IOException | ||
*/ | ||
|
@@ -188,8 +188,8 @@ protected function save($content, $path) | |
/** | ||
* Register a pattern to execute against the source content. | ||
* | ||
* @param string $pattern PCRE pattern. | ||
* @param string|callable $replacement Replacement value for matched pattern. | ||
* @param string $pattern PCRE pattern | ||
* @param string|callable $replacement Replacement value for matched pattern | ||
*/ | ||
protected function registerPattern($pattern, $replacement = '') | ||
{ | ||
|
@@ -207,9 +207,9 @@ protected function registerPattern($pattern, $replacement = '') | |
* 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. | ||
* | ||
* @param string $content The content to replace patterns in. | ||
* @param string $content The content to replace patterns in | ||
* | ||
* @return string The (manipulated) content. | ||
* @return string The (manipulated) content | ||
*/ | ||
protected function replace($content) | ||
{ | ||
|
@@ -289,9 +289,9 @@ protected function replace($content) | |
* This function will be called plenty of times, where $content will always | ||
* move up 1 character. | ||
* | ||
* @param string $pattern Pattern to match. | ||
* @param string|callable $replacement Replacement value. | ||
* @param string $content Content to match pattern against. | ||
* @param string $pattern Pattern to match | ||
* @param string|callable $replacement Replacement value | ||
* @param string $content Content to match pattern against | ||
* | ||
* @return string | ||
*/ | ||
|
@@ -393,9 +393,9 @@ protected function canImportFile($path) | |
/** | ||
* Attempts to open file specified by $path for writing. | ||
* | ||
* @param string $path The path to the file. | ||
* @param string $path The path to the file | ||
* | ||
* @return resource Specifier for the target file. | ||
* @return resource Specifier for the target file | ||
* | ||
* @throws IOException | ||
*/ | ||
|
@@ -411,9 +411,9 @@ protected function openFileForWriting($path) | |
/** | ||
* Attempts to write $content to the file specified by $handler. $path is used for printing exceptions. | ||
* | ||
* @param resource $handler The resource to write to. | ||
* @param string $content The content to write. | ||
* @param string $path The path to the file (for exception printing only). | ||
* @param resource $handler The resource to write to | ||
* @param string $content The content to write | ||
* @param string $path The path to the file (for exception printing only) | ||
* | ||
* @throws IOException | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters