Skip to content

Commit

Permalink
php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasmullie committed Oct 13, 2016
1 parent 099f5ec commit de4bcf2
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 51 deletions.
36 changes: 18 additions & 18 deletions src/CSS.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -83,7 +83,7 @@ protected function moveImportsToTop($content)

// add to top
$content = implode('', $matches[0]).$content;
};
}

return $content;
}
Expand All @@ -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
*
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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())
{
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand All @@ -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);
Expand All @@ -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
*/
Expand Down Expand Up @@ -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%)
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down
8 changes: 4 additions & 4 deletions src/JS.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
*/
Expand Down
50 changes: 25 additions & 25 deletions src/Minify.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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
*/
Expand All @@ -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
*/
Expand All @@ -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 = '')
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand All @@ -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
*/
Expand Down
7 changes: 3 additions & 4 deletions tests/js/JSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ protected function tearDown()
*/
public function minify($input, $expected)
{

$this->minifier->add($input);
$result = $this->minifier->minify();

Expand All @@ -60,7 +59,7 @@ public function dataProvider()
$tests[] = array(
[
__DIR__.'/sample/source/script1.js',
__DIR__.'/sample/source/script2.js'
__DIR__.'/sample/source/script2.js',
],
'var test=1;var test=2',
);
Expand All @@ -70,7 +69,7 @@ public function dataProvider()
[
__DIR__.'/sample/source/script1.js',
'console.log(test)',
__DIR__.'/sample/source/script2.js'
__DIR__.'/sample/source/script2.js',
],
'var test=1;console.log(test);var test=2',
);
Expand Down Expand Up @@ -425,7 +424,7 @@ public function dataProvider()
'array["a","b","c"]',
'array["a","b","c"]',
);
//

$tests[] = array(
"['loader']",
"['loader']",
Expand Down

0 comments on commit de4bcf2

Please sign in to comment.