1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-11 00:24:11 +02:00

do some trivial codestyle fixes

unix newlines, trailing spaces
This commit is contained in:
Elan Ruusamäe
2016-01-22 00:30:38 +02:00
parent 90bf31f53b
commit 379feaba99
40 changed files with 1424 additions and 1327 deletions

View File

@@ -38,7 +38,7 @@ class DooDigestAuth{
* @param string $fail_url URL to be redirect if the User cancel the login * @param string $fail_url URL to be redirect if the User cancel the login
* @return string The username if login success. * @return string The username if login success.
*/ */
public static function http_auth($realm, $users, $fail_msg=NULL, $fail_url=NULL){ public static function http_auth($realm, $users, $fail_msg=NULL, $fail_url=NULL) {
$realm = "Restricted area - $realm"; $realm = "Restricted area - $realm";
//user => password //user => password
@@ -114,8 +114,8 @@ class DooDigestAuth{
$data['uri'] = $match[1]; $data['uri'] = $match[1];
$res = preg_match('/response=\"([^\"]+)\"/i', $txt, $match); $res = preg_match('/response=\"([^\"]+)\"/i', $txt, $match);
$data['response'] = $match[1]; $data['response'] = $match[1];
return $data; return $data;
} }
} }

View File

@@ -246,7 +246,6 @@ class HTTP_ConditionalGet {
} }
} }
/** /**
* Get a GMT formatted date for use in HTTP headers * Get a GMT formatted date for use in HTTP headers
* *
@@ -305,6 +304,7 @@ class HTTP_ConditionalGet {
if ($isValid) { if ($isValid) {
$this->_headers['_responseCode'] = 'HTTP/1.0 304 Not Modified'; $this->_headers['_responseCode'] = 'HTTP/1.0 304 Not Modified';
} }
return $isValid; return $isValid;
} }
@@ -327,9 +327,11 @@ class HTTP_ConditionalGet {
// respond with the client's matched ETag, even if it's not what // respond with the client's matched ETag, even if it's not what
// we would've sent by default // we would've sent by default
$this->_headers['ETag'] = trim($clientEtag); $this->_headers['ETag'] = trim($clientEtag);
return true; return true;
} }
} }
return false; return false;
} }
@@ -340,6 +342,7 @@ class HTTP_ConditionalGet {
*/ */
protected function normalizeEtag($etag) { protected function normalizeEtag($etag) {
$etag = trim($etag); $etag = trim($etag);
return $this->_stripEtag return $this->_stripEtag
? preg_replace('/;\\w\\w"$/', '"', $etag) ? preg_replace('/;\\w\\w"$/', '"', $etag)
: $etag; : $etag;
@@ -359,8 +362,10 @@ class HTTP_ConditionalGet {
// Apache 2.2's behavior. If there was no ETag match, send the // Apache 2.2's behavior. If there was no ETag match, send the
// non-encoded version of the ETag value. // non-encoded version of the ETag value.
$this->_headers['ETag'] = $this->normalizeEtag($this->_etag); $this->_headers['ETag'] = $this->normalizeEtag($this->_etag);
return true; return true;
} }
return false; return false;
} }
} }

View File

@@ -61,7 +61,6 @@ class HTTP_Encoder {
*/ */
public static $encodeToIe6 = true; public static $encodeToIe6 = true;
/** /**
* Default compression level for zlib operations * Default compression level for zlib operations
* *
@@ -71,7 +70,6 @@ class HTTP_Encoder {
*/ */
public static $compressionLevel = 6; public static $compressionLevel = 6;
/** /**
* Get an HTTP Encoder object * Get an HTTP Encoder object
* *
@@ -230,6 +228,7 @@ class HTTP_Encoder {
,$m)) { ,$m)) {
return array('compress', $m[1]); return array('compress', $m[1]);
} }
return array('', ''); return array('', '');
} }
@@ -279,6 +278,7 @@ class HTTP_Encoder {
: (string)strlen($encoded); : (string)strlen($encoded);
$this->_headers['Content-Encoding'] = $this->_encodeMethod[1]; $this->_headers['Content-Encoding'] = $this->_encodeMethod[1];
$this->_content = $encoded; $this->_content = $encoded;
return true; return true;
} }
@@ -302,6 +302,7 @@ class HTTP_Encoder {
$he = new HTTP_Encoder(array('content' => $content)); $he = new HTTP_Encoder(array('content' => $content));
$ret = $he->encode($compressionLevel); $ret = $he->encode($compressionLevel);
$he->sendAll(); $he->sendAll();
return $ret; return $ret;
} }
@@ -323,6 +324,7 @@ class HTTP_Encoder {
} }
// no regex = faaast // no regex = faaast
$version = (float)substr($ua, 30); $version = (float)substr($ua, 30);
return self::$encodeToIe6 return self::$encodeToIe6
? ($version < 6 || ($version == 6 && false === strpos($ua, 'SV1'))) ? ($version < 6 || ($version == 6 && false === strpos($ua, 'SV1')))
: ($version < 7); : ($version < 7);

View File

@@ -216,6 +216,7 @@ class Minify {
$this->errorExit($this->options['badRequestHeader'], self::URL_DEBUG); $this->errorExit($this->options['badRequestHeader'], self::URL_DEBUG);
} else { } else {
list(,$statusCode) = explode(' ', $this->options['badRequestHeader']); list(,$statusCode) = explode(' ', $this->options['badRequestHeader']);
return array( return array(
'success' => false, 'success' => false,
'statusCode' => (int)$statusCode, 'statusCode' => (int)$statusCode,
@@ -268,6 +269,7 @@ class Minify {
// client's cache is valid // client's cache is valid
if (! $this->options['quiet']) { if (! $this->options['quiet']) {
$cg->sendHeaders(); $cg->sendHeaders();
return; return;
} else { } else {
return array( return array(
@@ -422,6 +424,7 @@ class Minify {
$out = $this->serve($controller, $options); $out = $this->serve($controller, $options);
$this->cache = $tmpCache; $this->cache = $tmpCache;
return $out['content']; return $out['content'];
} }
@@ -585,6 +588,7 @@ class Minify {
if ($this->options['postprocessor']) { if ($this->options['postprocessor']) {
$content = call_user_func($this->options['postprocessor'], $content, $type); $content = call_user_func($this->options['postprocessor'], $content, $type);
} }
return $content; return $content;
} }
@@ -610,6 +614,7 @@ class Minify {
$this->options['bubbleCssImports'], $this->options['bubbleCssImports'],
Minify::VERSION, Minify::VERSION,
))); )));
return "{$prefix}_{$name}_{$md5}"; return "{$prefix}_{$name}_{$md5}";
} }
@@ -626,6 +631,7 @@ class Minify {
// bubble CSS imports // bubble CSS imports
preg_match_all('/@import.*?;/', $css, $imports); preg_match_all('/@import.*?;/', $css, $imports);
$css = implode('', $imports[0]) . preg_replace('/@import.*?;/', '', $css); $css = implode('', $imports[0]) . preg_replace('/@import.*?;/', '', $css);
return $css; return $css;
} }
@@ -644,6 +650,7 @@ class Minify {
// { appears before @import : prepend warning // { appears before @import : prepend warning
$css = $this->options['importWarning'] . $css; $css = $this->options['importWarning'] . $css;
} }
return $css; return $css;
} }
@@ -672,6 +679,7 @@ class Minify {
Minify_Logger::log('ContentType mismatch'); Minify_Logger::log('ContentType mismatch');
$this->sources = array(); $this->sources = array();
return $options; return $options;
} }
@@ -686,6 +694,7 @@ class Minify {
Minify_Logger::log('ContentType mismatch'); Minify_Logger::log('ContentType mismatch');
$this->sources = array(); $this->sources = array();
return $options; return $options;
} }
} }

View File

@@ -71,6 +71,7 @@ class Minify_Build {
$sep = ($forceAmpersand || strpos($uri, '?') !== false) $sep = ($forceAmpersand || strpos($uri, '?') !== false)
? self::$ampersand ? self::$ampersand
: '?'; : '?';
return "{$uri}{$sep}{$this->lastModified}"; return "{$uri}{$sep}{$this->lastModified}";
} }

View File

@@ -40,6 +40,7 @@ class Minify_CSS_Compressor {
public static function process($css, $options = array()) public static function process($css, $options = array())
{ {
$obj = new Minify_CSS_Compressor($options); $obj = new Minify_CSS_Compressor($options);
return $obj->_process($css); return $obj->_process($css);
} }
@@ -55,7 +56,6 @@ class Minify_CSS_Compressor {
*/ */
protected $_inHack = false; protected $_inHack = false;
/** /**
* Constructor * Constructor
* *
@@ -208,22 +208,26 @@ class Minify_CSS_Compressor {
@x', $m, $n)) { @x', $m, $n)) {
// end hack mode after this comment, but preserve the hack and comment content // end hack mode after this comment, but preserve the hack and comment content
$this->_inHack = false; $this->_inHack = false;
return "/*/{$n[1]}/**/"; return "/*/{$n[1]}/**/";
} }
} }
if (substr($m, -1) === '\\') { // comment ends like \*/ if (substr($m, -1) === '\\') { // comment ends like \*/
// begin hack mode and preserve hack // begin hack mode and preserve hack
$this->_inHack = true; $this->_inHack = true;
return '/*\\*/'; return '/*\\*/';
} }
if ($m !== '' && $m[0] === '/') { // comment looks like /*/ foo */ if ($m !== '' && $m[0] === '/') { // comment looks like /*/ foo */
// begin hack mode and preserve hack // begin hack mode and preserve hack
$this->_inHack = true; $this->_inHack = true;
return '/*/*/'; return '/*/*/';
} }
if ($this->_inHack) { if ($this->_inHack) {
// a regular comment ends hack mode but should be preserved // a regular comment ends hack mode but should be preserved
$this->_inHack = false; $this->_inHack = false;
return '/**/'; return '/**/';
} }
// Issue 107: if there's any surrounding whitespace, it may be important, so // Issue 107: if there's any surrounding whitespace, it may be important, so
@@ -252,6 +256,7 @@ class Minify_CSS_Compressor {
} }
$out .= $piece; $out .= $piece;
} }
return $out . $m[2]; return $out . $m[2];
} }
} }

View File

@@ -98,6 +98,7 @@ class Minify_CSS_UriRewriter {
,array(self::$className, '_processUriCB'), $css); ,array(self::$className, '_processUriCB'), $css);
self::$_prependPath = null; self::$_prependPath = null;
return $css; return $css;
} }
@@ -187,6 +188,7 @@ class Minify_CSS_UriRewriter {
do { do {
$uri = preg_replace('@/[^/]+/\\.\\./@', '/', $uri, 1, $changed); $uri = preg_replace('@/[^/]+/\\.\\./@', '/', $uri, 1, $changed);
} while ($changed); } while ($changed);
return $uri; return $uri;
} }
@@ -212,6 +214,7 @@ class Minify_CSS_UriRewriter {
if ($realPath !== false) { if ($realPath !== false) {
$path = $realPath; $path = $realPath;
} }
return rtrim($path, '/\\'); return rtrim($path, '/\\');
} }
@@ -300,6 +303,7 @@ class Minify_CSS_UriRewriter {
} }
} }
} }
return $isImport return $isImport
? "@import {$quoteChar}{$uri}{$quoteChar}" ? "@import {$quoteChar}{$uri}{$quoteChar}"
: "url({$quoteChar}{$uri}{$quoteChar})"; : "url({$quoteChar}{$uri}{$quoteChar})";

View File

@@ -57,6 +57,7 @@ class Minify_Cache_APC implements Minify_CacheInterface {
if (! $this->_fetch($id)) { if (! $this->_fetch($id)) {
return false; return false;
} }
return (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) return (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2))
? mb_strlen($this->_data, '8bit') ? mb_strlen($this->_data, '8bit')
: strlen($this->_data); : strlen($this->_data);
@@ -124,10 +125,12 @@ class Minify_Cache_APC implements Minify_CacheInterface {
$ret = apc_fetch($id); $ret = apc_fetch($id);
if (false === $ret) { if (false === $ret) {
$this->_id = null; $this->_id = null;
return false; return false;
} }
list($this->_lm, $this->_data) = explode('|', $ret, 2); list($this->_lm, $this->_data) = explode('|', $ret, 2);
$this->_id = $id; $this->_id = $id;
return true; return true;
} }
} }

View File

@@ -37,8 +37,10 @@ class Minify_Cache_File implements Minify_CacheInterface {
if ($data !== $this->fetch($id)) { if ($data !== $this->fetch($id)) {
@unlink($file); @unlink($file);
$this->_log("Minify_Cache_File: Post-write read failed for '$file'"); $this->_log("Minify_Cache_File: Post-write read failed for '$file'");
return false; return false;
} }
return true; return true;
} }
@@ -66,6 +68,7 @@ class Minify_Cache_File implements Minify_CacheInterface {
public function isValid($id, $srcMtime) public function isValid($id, $srcMtime)
{ {
$file = $this->_path . '/' . $id; $file = $this->_path . '/' . $id;
return (is_file($file) && (filemtime($file) >= $srcMtime)); return (is_file($file) && (filemtime($file) >= $srcMtime));
} }
@@ -105,6 +108,7 @@ class Minify_Cache_File implements Minify_CacheInterface {
$ret = stream_get_contents($fp); $ret = stream_get_contents($fp);
flock($fp, LOCK_UN); flock($fp, LOCK_UN);
fclose($fp); fclose($fp);
return $ret; return $ret;
} else { } else {
return file_get_contents($this->_path . '/' . $id); return file_get_contents($this->_path . '/' . $id);
@@ -140,6 +144,7 @@ class Minify_Cache_File implements Minify_CacheInterface {
: self::_tmp(); : self::_tmp();
$tmp = rtrim($tmp, DIRECTORY_SEPARATOR); $tmp = rtrim($tmp, DIRECTORY_SEPARATOR);
} }
return $tmp; return $tmp;
} }

View File

@@ -60,6 +60,7 @@ class Minify_Cache_Memcache implements Minify_CacheInterface {
if (! $this->_fetch($id)) { if (! $this->_fetch($id)) {
return false; return false;
} }
return (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) return (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2))
? mb_strlen($this->_data, '8bit') ? mb_strlen($this->_data, '8bit')
: strlen($this->_data); : strlen($this->_data);
@@ -128,10 +129,12 @@ class Minify_Cache_Memcache implements Minify_CacheInterface {
$ret = $this->_mc->get($id); $ret = $this->_mc->get($id);
if (false === $ret) { if (false === $ret) {
$this->_id = null; $this->_id = null;
return false; return false;
} }
list($this->_lm, $this->_data) = explode('|', $ret, 2); list($this->_lm, $this->_data) = explode('|', $ret, 2);
$this->_id = $id; $this->_id = $id;
return true; return true;
} }
} }

View File

@@ -59,6 +59,7 @@ class Minify_Cache_WinCache implements Minify_CacheInterface
if (!$this->_fetch($id)) { if (!$this->_fetch($id)) {
return false; return false;
} }
return (function_exists('mb_strlen') && ((int) ini_get('mbstring.func_overload') & 2)) ? mb_strlen($this->_data, '8bit') : strlen($this->_data); return (function_exists('mb_strlen') && ((int) ini_get('mbstring.func_overload') & 2)) ? mb_strlen($this->_data, '8bit') : strlen($this->_data);
} }
@@ -121,10 +122,12 @@ class Minify_Cache_WinCache implements Minify_CacheInterface
$ret = wincache_ucache_get($id, $suc); $ret = wincache_ucache_get($id, $suc);
if (!$suc) { if (!$suc) {
$this->_id = NULL; $this->_id = NULL;
return false; return false;
} }
list($this->_lm, $this->_data) = explode('|', $ret, 2); list($this->_lm, $this->_data) = explode('|', $ret, 2);
$this->_id = $id; $this->_id = $id;
return true; return true;
} }
} }

View File

@@ -54,6 +54,7 @@ class Minify_Cache_XCache implements Minify_CacheInterface {
if (! $this->_fetch($id)) { if (! $this->_fetch($id)) {
return false; return false;
} }
return (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) return (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2))
? mb_strlen($this->_data, '8bit') ? mb_strlen($this->_data, '8bit')
: strlen($this->_data); : strlen($this->_data);
@@ -117,10 +118,12 @@ class Minify_Cache_XCache implements Minify_CacheInterface {
$ret = xcache_get($id); $ret = xcache_get($id);
if (false === $ret) { if (false === $ret) {
$this->_id = null; $this->_id = null;
return false; return false;
} }
list($this->_lm, $this->_data) = explode('|', $ret, 2); list($this->_lm, $this->_data) = explode('|', $ret, 2);
$this->_id = $id; $this->_id = $id;
return true; return true;
} }
} }

View File

@@ -4,7 +4,6 @@
* @package Minify * @package Minify
*/ */
/** /**
* ZendPlatform-based cache class for Minify * ZendPlatform-based cache class for Minify
* *
@@ -19,7 +18,6 @@
*/ */
class Minify_Cache_ZendPlatform implements Minify_CacheInterface { class Minify_Cache_ZendPlatform implements Minify_CacheInterface {
/** /**
* Create a Minify_Cache_ZendPlatform object, to be passed to * Create a Minify_Cache_ZendPlatform object, to be passed to
* Minify::setCache(). * Minify::setCache().
@@ -33,7 +31,6 @@ class Minify_Cache_ZendPlatform implements Minify_CacheInterface {
$this->_exp = $expire; $this->_exp = $expire;
} }
/** /**
* Write data to cache. * Write data to cache.
* *
@@ -48,7 +45,6 @@ class Minify_Cache_ZendPlatform implements Minify_CacheInterface {
return output_cache_put($id, "{$_SERVER['REQUEST_TIME']}|{$data}"); return output_cache_put($id, "{$_SERVER['REQUEST_TIME']}|{$data}");
} }
/** /**
* Get the size of a cache entry * Get the size of a cache entry
* *
@@ -75,6 +71,7 @@ class Minify_Cache_ZendPlatform implements Minify_CacheInterface {
public function isValid($id, $srcMtime) public function isValid($id, $srcMtime)
{ {
$ret = ($this->_fetch($id) && ($this->_lm >= $srcMtime)); $ret = ($this->_fetch($id) && ($this->_lm >= $srcMtime));
return $ret; return $ret;
} }
@@ -90,7 +87,6 @@ class Minify_Cache_ZendPlatform implements Minify_CacheInterface {
: ''; : '';
} }
/** /**
* Fetch the cached content * Fetch the cached content
* *
@@ -127,10 +123,12 @@ class Minify_Cache_ZendPlatform implements Minify_CacheInterface {
$ret = output_cache_get($id, $this->_exp); $ret = output_cache_get($id, $this->_exp);
if (false === $ret) { if (false === $ret) {
$this->_id = null; $this->_id = null;
return false; return false;
} }
list($this->_lm, $this->_data) = explode('|', $ret, 2); list($this->_lm, $this->_data) = explode('|', $ret, 2);
$this->_id = $id; $this->_id = $id;
return true; return true;
} }
} }

View File

@@ -4,7 +4,6 @@
* @package Minify * @package Minify
*/ */
/** /**
* Interface for Minify cache adapters * Interface for Minify cache adapters
* *

View File

@@ -73,6 +73,7 @@ class Minify_ClosureCompiler
public static function minify($js, $options = array()) public static function minify($js, $options = array())
{ {
$min = new static(); $min = new static();
return $min->process($js, $options); return $min->process($js, $options);
} }
@@ -123,6 +124,7 @@ class Minify_ClosureCompiler
$this->getCompilerCommandLine(), $this->getCompilerCommandLine(),
$this->getOptionsCommandLine($userOptions) $this->getOptionsCommandLine($userOptions)
); );
return join(' ', $args) . ' ' . escapeshellarg($tmpFile); return join(' ', $args) . ' ' . escapeshellarg($tmpFile);
} }
@@ -137,6 +139,7 @@ class Minify_ClosureCompiler
self::$javaExecutable, self::$javaExecutable,
'-jar', escapeshellarg(self::$jarFile) '-jar', escapeshellarg(self::$jarFile)
); );
return $server; return $server;
} }
@@ -215,6 +218,7 @@ class Minify_ClosureCompiler
throw new Minify_ClosureCompiler_Exception('Could not create temp file in "' . $dir . '".'); throw new Minify_ClosureCompiler_Exception('Could not create temp file in "' . $dir . '".');
} }
file_put_contents($tmpFile, $content); file_put_contents($tmpFile, $content);
return $tmpFile; return $tmpFile;
} }
@@ -232,6 +236,7 @@ class Minify_ClosureCompiler
if (!in_array($result_code, $expectedCodes)) { if (!in_array($result_code, $expectedCodes)) {
throw new Minify_ClosureCompiler_Exception("Unpexpected return code: $result_code"); throw new Minify_ClosureCompiler_Exception("Unpexpected return code: $result_code");
} }
return $output; return $output;
} }
} }

View File

@@ -55,6 +55,7 @@ class Minify_CommentPreserver {
$ret .= $comment; $ret .= $comment;
$content = $afterComment; $content = $afterComment;
} }
return $ret; return $ret;
} }
@@ -84,6 +85,7 @@ class Minify_CommentPreserver {
$ret[] = (0 === $endChars) $ret[] = (0 === $endChars)
? '' ? ''
: substr($in, -$endChars); : substr($in, -$endChars);
return $ret; return $ret;
} }
} }

View File

@@ -72,9 +72,11 @@ class Minify_Controller_Files extends Minify_Controller_Base {
)); ));
} catch (Minify_Source_FactoryException $e) { } catch (Minify_Source_FactoryException $e) {
$this->log($e->getMessage()); $this->log($e->getMessage());
return new Minify_ServeConfiguration($options); return new Minify_ServeConfiguration($options);
} }
} }
return new Minify_ServeConfiguration($options, $sources); return new Minify_ServeConfiguration($options, $sources);
} }
} }

View File

@@ -52,6 +52,7 @@ class Minify_Controller_Groups extends Minify_Controller_Files {
if (false === $pathInfo || ! isset($groups[$pathInfo])) { if (false === $pathInfo || ! isset($groups[$pathInfo])) {
// no PATH_INFO or not a valid group // no PATH_INFO or not a valid group
$this->log("Missing PATH_INFO or no group set for \"$pathInfo\""); $this->log("Missing PATH_INFO or no group set for \"$pathInfo\"");
return new Minify_ServeConfiguration($options); return new Minify_ServeConfiguration($options);
} }

View File

@@ -59,11 +59,13 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
$keys = explode(',', $get['g']); $keys = explode(',', $get['g']);
if ($keys != array_unique($keys)) { if ($keys != array_unique($keys)) {
$this->log("Duplicate group key found."); $this->log("Duplicate group key found.");
return new Minify_ServeConfiguration($options); return new Minify_ServeConfiguration($options);
} }
foreach ($keys as $key) { foreach ($keys as $key) {
if (! isset($localOptions['groups'][$key])) { if (! isset($localOptions['groups'][$key])) {
$this->log("A group configuration for \"{$key}\" was not found"); $this->log("A group configuration for \"{$key}\" was not found");
return new Minify_ServeConfiguration($options); return new Minify_ServeConfiguration($options);
} }
$files = $localOptions['groups'][$key]; $files = $localOptions['groups'][$key];
@@ -91,6 +93,7 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
} else { } else {
$secondMissingResource = basename($file); $secondMissingResource = basename($file);
$this->log("More than one file was missing: '$firstMissingResource', '$secondMissingResource'"); $this->log("More than one file was missing: '$firstMissingResource', '$secondMissingResource'");
return new Minify_ServeConfiguration($options); return new Minify_ServeConfiguration($options);
} }
} }
@@ -110,12 +113,14 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
|| strpos($get['f'], '\\') !== false || strpos($get['f'], '\\') !== false
) { ) {
$this->log("GET param 'f' was invalid"); $this->log("GET param 'f' was invalid");
return new Minify_ServeConfiguration($options); return new Minify_ServeConfiguration($options);
} }
$ext = ".{$m[1]}"; $ext = ".{$m[1]}";
$files = explode(',', $get['f']); $files = explode(',', $get['f']);
if ($files != array_unique($files)) { if ($files != array_unique($files)) {
$this->log("Duplicate files were specified"); $this->log("Duplicate files were specified");
return new Minify_ServeConfiguration($options); return new Minify_ServeConfiguration($options);
} }
if (isset($get['b'])) { if (isset($get['b'])) {
@@ -127,6 +132,7 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
$base = "/{$get['b']}/"; $base = "/{$get['b']}/";
} else { } else {
$this->log("GET param 'b' was invalid"); $this->log("GET param 'b' was invalid");
return new Minify_ServeConfiguration($options); return new Minify_ServeConfiguration($options);
} }
} else { } else {
@@ -160,6 +166,7 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
} else { } else {
$secondMissingResource = $uri; $secondMissingResource = $uri;
$this->log("More than one file was missing: '$firstMissingResource', '$secondMissingResource`'"); $this->log("More than one file was missing: '$firstMissingResource', '$secondMissingResource`'");
return new Minify_ServeConfiguration($options); return new Minify_ServeConfiguration($options);
} }
} }
@@ -172,6 +179,7 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
if (!$sources) { if (!$sources) {
$this->log("No sources to serve"); $this->log("No sources to serve");
return new Minify_ServeConfiguration($options); return new Minify_ServeConfiguration($options);
} }

View File

@@ -22,6 +22,7 @@ class Minify_DebugDetector {
} }
} }
} }
return false; return false;
} }
} }

View File

@@ -41,6 +41,7 @@ class Minify_Env {
if (null === $key) { if (null === $key) {
return $this->server; return $this->server;
} }
return isset($this->server[$key]) return isset($this->server[$key])
? $this->server[$key] ? $this->server[$key]
: null; : null;
@@ -51,6 +52,7 @@ class Minify_Env {
if (null === $key) { if (null === $key) {
return $this->cookie; return $this->cookie;
} }
return isset($this->cookie[$key]) return isset($this->cookie[$key])
? $this->cookie[$key] ? $this->cookie[$key]
: null; : null;
@@ -61,6 +63,7 @@ class Minify_Env {
if (null === $key) { if (null === $key) {
return $this->get; return $this->get;
} }
return isset($this->get[$key]) return isset($this->get[$key])
? $this->get[$key] ? $this->get[$key]
: null; : null;
@@ -87,6 +90,7 @@ class Minify_Env {
,0 ,0
,strlen($server['SCRIPT_FILENAME']) - strlen($server['SCRIPT_NAME']) ,strlen($server['SCRIPT_FILENAME']) - strlen($server['SCRIPT_NAME'])
); );
return rtrim($docRoot, '\\'); return rtrim($docRoot, '\\');
} }
} }

View File

@@ -42,10 +42,10 @@ class Minify_HTML {
*/ */
public static function minify($html, $options = array()) { public static function minify($html, $options = array()) {
$min = new self($html, $options); $min = new self($html, $options);
return $min->process(); return $min->process();
} }
/** /**
* Create a minifier object * Create a minifier object
* *
@@ -81,7 +81,6 @@ class Minify_HTML {
} }
} }
/** /**
* Minify the markeup given in the constructor * Minify the markeup given in the constructor
* *
@@ -157,6 +156,7 @@ class Minify_HTML {
,array_values($this->_placeholders) ,array_values($this->_placeholders)
,$this->_html ,$this->_html
); );
return $this->_html; return $this->_html;
} }
@@ -171,6 +171,7 @@ class Minify_HTML {
{ {
$placeholder = '%' . $this->_replacementHash . count($this->_placeholders) . '%'; $placeholder = '%' . $this->_replacementHash . count($this->_placeholders) . '%';
$this->_placeholders[$placeholder] = $content; $this->_placeholders[$placeholder] = $content;
return $placeholder; return $placeholder;
} }

View File

@@ -48,6 +48,7 @@ class Minify_HTML_Helper {
$h->setGroup($keyOrFiles, $opts['farExpires']); $h->setGroup($keyOrFiles, $opts['farExpires']);
} }
$uri = $h->getRawUri($opts['farExpires'], $opts['debug']); $uri = $h->getRawUri($opts['farExpires'], $opts['debug']);
return htmlspecialchars($uri, ENT_QUOTES, $opts['charset']); return htmlspecialchars($uri, ENT_QUOTES, $opts['charset']);
} }
@@ -75,6 +76,7 @@ class Minify_HTML_Helper {
} elseif ($farExpires && $this->_lastModified) { } elseif ($farExpires && $this->_lastModified) {
$path .= "&" . $this->_lastModified; $path .= "&" . $this->_lastModified;
} }
return $path; return $path;
} }
@@ -156,6 +158,7 @@ class Minify_HTML_Helper {
} }
} }
} }
return $max; return $max;
} }
@@ -163,7 +166,6 @@ class Minify_HTML_Helper {
protected $_filePaths = array(); protected $_filePaths = array();
protected $_lastModified = null; protected $_lastModified = null;
/** /**
* In a given array of strings, find the character they all have at * In a given array of strings, find the character they all have at
* a particular index * a particular index
@@ -186,6 +188,7 @@ class Minify_HTML_Helper {
return ''; return '';
} }
} }
return $c; return $c;
} }
@@ -225,6 +228,7 @@ class Minify_HTML_Helper {
? $uri ? $uri
: $bUri; : $bUri;
} }
return $uri; return $uri;
} }
} }

View File

@@ -27,6 +27,7 @@ class Minify_ImportProcessor {
self::$filesIncluded = array(); self::$filesIncluded = array();
self::$_isCss = (strtolower(substr($file, -4)) === '.css'); self::$_isCss = (strtolower(substr($file, -4)) === '.css');
$obj = new Minify_ImportProcessor(dirname($file)); $obj = new Minify_ImportProcessor(dirname($file));
return $obj->_getContent($file); return $obj->_getContent($file);
} }
@@ -129,6 +130,7 @@ class Minify_ImportProcessor {
? $m[0] ? $m[0]
: "/* Minify_ImportProcessor could not fetch '{$file}' */"; : "/* Minify_ImportProcessor could not fetch '{$file}' */";
} }
return (!self::$_isCss || preg_match('@(?:^$|\\ball\\b)@', $mediaList)) return (!self::$_isCss || preg_match('@(?:^$|\\ball\\b)@', $mediaList))
? $content ? $content
: "@media {$mediaList} {\n{$content}\n}\n"; : "@media {$mediaList} {\n{$content}\n}\n";
@@ -154,6 +156,7 @@ class Minify_ImportProcessor {
$url = self::getPathDiff(realpath($this->_previewsDir), $path); $url = self::getPathDiff(realpath($this->_previewsDir), $path);
} }
} }
return "url({$quote}{$url}{$quote})"; return "url({$quote}{$url}{$quote})";
} }
@@ -175,6 +178,7 @@ class Minify_ImportProcessor {
array_shift($arFrom); array_shift($arFrom);
array_shift($arTo); array_shift($arTo);
} }
return str_pad("", count($arFrom) * 3, '..' . $ps) . implode($ps, $arTo); return str_pad("", count($arFrom) * 3, '..' . $ps) . implode($ps, $arTo);
} }
@@ -184,7 +188,7 @@ class Minify_ImportProcessor {
* @return string The resolved path, it might not exist. * @return string The resolved path, it might not exist.
* @see http://stackoverflow.com/questions/4049856/replace-phps-realpath * @see http://stackoverflow.com/questions/4049856/replace-phps-realpath
*/ */
function truepath($path) public function truepath($path)
{ {
// whether $path is unix or not // whether $path is unix or not
$unipath = strlen($path) == 0 || $path{0} != '/'; $unipath = strlen($path) == 0 || $path{0} != '/';
@@ -211,6 +215,7 @@ class Minify_ImportProcessor {
$path = readlink($path); $path = readlink($path);
// put initial separator that could have been lost // put initial separator that could have been lost
$path = !$unipath ? '/' . $path : $path; $path = !$unipath ? '/' . $path : $path;
return $path; return $path;
} }
} }

View File

@@ -81,6 +81,7 @@ class Minify_JS_ClosureCompiler {
public static function minify($js, array $options = array()) public static function minify($js, array $options = array())
{ {
$obj = new self($options); $obj = new self($options);
return $obj->min($js); return $obj->min($js);
} }

View File

@@ -35,6 +35,7 @@ class Minify_LessCssSource extends Minify_Source {
$lastModified = max($lastModified, $mtime); $lastModified = max($lastModified, $mtime);
} }
return $lastModified; return $lastModified;
} }
@@ -90,6 +91,7 @@ class Minify_LessCssSource extends Minify_Source {
*/ */
private function getCacheId($prefix = 'minify') { private function getCacheId($prefix = 'minify') {
$md5 = md5($this->filepath); $md5 = md5($this->filepath);
return "{$prefix}_less_{$md5}"; return "{$prefix}_less_{$md5}";
} }
@@ -102,6 +104,7 @@ class Minify_LessCssSource extends Minify_Source {
$less = new lessc(); $less = new lessc();
// do not spend CPU time letting less doing minify // do not spend CPU time letting less doing minify
$less->setPreserveComments(true); $less->setPreserveComments(true);
return $less; return $less;
} }
} }

View File

@@ -117,6 +117,7 @@ class Minify_Lines {
$line = substr($line, $pos + 2); $line = substr($line, $pos + 2);
} }
} }
return $inComment; return $inComment;
} }

View File

@@ -18,6 +18,7 @@ class Minify_Loader {
$file .= strtr($class, "\\_", DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR) . '.php'; $file .= strtr($class, "\\_", DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR) . '.php';
if (is_readable($file)) { if (is_readable($file)) {
require $file; require $file;
return; return;
} }
@@ -36,6 +37,7 @@ class Minify_Loader {
{ {
$inst = new self(); $inst = new self();
spl_autoload_register(array($inst, 'loadClass')); spl_autoload_register(array($inst, 'loadClass'));
return $inst; return $inst;
} }
} }

View File

@@ -24,6 +24,7 @@ class Minify_Packer {
{ {
// @todo: set encoding options based on $options :) // @todo: set encoding options based on $options :)
$packer = new JavascriptPacker($code, 'Normal', true, false); $packer = new JavascriptPacker($code, 'Normal', true, false);
return trim($packer->pack()); return trim($packer->pack());
} }
} }

View File

@@ -31,7 +31,7 @@ class Minify_ServeConfiguration {
* @param Minify_SourceInterface[] $sources * @param Minify_SourceInterface[] $sources
* @param string $selectionId * @param string $selectionId
*/ */
function __construct(array $options, array $sources = array(), $selectionId = '') public function __construct(array $options, array $sources = array(), $selectionId = '')
{ {
$this->options = $options; $this->options = $options;
$this->sources = $sources; $this->sources = $sources;

View File

@@ -24,6 +24,7 @@ class Minify_SourceSet {
$source->getId(), $source->getMinifier(), $source->getMinifierOptions() $source->getId(), $source->getMinifier(), $source->getMinifierOptions()
); );
} }
return md5(serialize($info)); return md5(serialize($info));
} }
} }

View File

@@ -98,6 +98,7 @@ class Minify_YUICompressor {
if ($result_code != 0) { if ($result_code != 0) {
throw new Exception('Minify_YUICompressor : YUI compressor execution failed.'); throw new Exception('Minify_YUICompressor : YUI compressor execution failed.');
} }
return implode("\n", $output); return implode("\n", $output);
} }
@@ -134,6 +135,7 @@ class Minify_YUICompressor {
: ''; : '';
} }
} }
return $cmd . ' ' . escapeshellarg($tmpFile); return $cmd . ' ' . escapeshellarg($tmpFile);
} }

View File

@@ -116,6 +116,7 @@ class Cli {
$arg = new Arg($required); $arg = new Arg($required);
} }
$this->_args[$letter] = $arg; $this->_args[$letter] = $arg;
return $arg; return $arg;
} }
@@ -207,6 +208,7 @@ class Cli {
$pattern = "/^-[" . str_replace($letter, '', $lettersUsed) . "]/i"; $pattern = "/^-[" . str_replace($letter, '', $lettersUsed) . "]/i";
if (preg_match($pattern, $v)) { if (preg_match($pattern, $v)) {
$this->addError($letter, "Value was read as another option: %s", $v); $this->addError($letter, "Value was read as another option: %s", $v);
return false; return false;
} }
} }
@@ -249,6 +251,7 @@ class Cli {
} }
$this->moreArgs = $argvCopy; $this->moreArgs = $argvCopy;
reset($this->moreArgs); reset($this->moreArgs);
return empty($this->errors); return empty($this->errors);
} }
@@ -270,6 +273,7 @@ class Cli {
$r[$k] = $v; $r[$k] = $v;
} }
} }
return $r; return $r;
} }
@@ -288,6 +292,7 @@ class Cli {
$r .= " $letter : " . implode(', ', $arr) . "\n"; $r .= " $letter : " . implode(', ', $arr) . "\n";
} }
$r .= "\n"; $r .= "\n";
return $r; return $r;
} }
@@ -318,6 +323,7 @@ class Cli {
$desc = wordwrap($desc, 70); $desc = wordwrap($desc, 70);
$r .= $flag . str_replace("\n", "\n ", $desc) . "\n\n"; $r .= $flag . str_replace("\n", "\n ", $desc) . "\n\n";
} }
return $r; return $r;
} }
@@ -333,6 +339,7 @@ class Cli {
return STDIN; return STDIN;
} else { } else {
$this->_stdin = fopen($this->_stdin, 'rb'); $this->_stdin = fopen($this->_stdin, 'rb');
return $this->_stdin; return $this->_stdin;
} }
} }
@@ -357,6 +364,7 @@ class Cli {
return STDOUT; return STDOUT;
} else { } else {
$this->_stdout = fopen($this->_stdout, 'wb'); $this->_stdout = fopen($this->_stdout, 'wb');
return $this->_stdout; return $this->_stdout;
} }
} }

View File

@@ -97,6 +97,7 @@ class Arg {
public function useAsOutfile() public function useAsOutfile()
{ {
$this->spec['useAsOutfile'] = true; $this->spec['useAsOutfile'] = true;
return $this->assertFile()->assertWritable(); return $this->assertFile()->assertWritable();
} }
@@ -109,6 +110,7 @@ class Arg {
public function useAsInfile() public function useAsInfile()
{ {
$this->spec['useAsInfile'] = true; $this->spec['useAsInfile'] = true;
return $this->assertFile()->assertReadable(); return $this->assertFile()->assertReadable();
} }
@@ -127,6 +129,7 @@ class Arg {
public function setDescription($desc) public function setDescription($desc)
{ {
$this->description = $desc; $this->description = $desc;
return $this; return $this;
} }
@@ -164,6 +167,7 @@ class Arg {
} else { } else {
throw new BadMethodCallException('Method does not exist'); throw new BadMethodCallException('Method does not exist');
} }
return $this; return $this;
} }
@@ -178,6 +182,7 @@ class Arg {
if (array_key_exists($name, $this->spec)) { if (array_key_exists($name, $this->spec)) {
return $this->spec[$name]; return $this->spec[$name];
} }
return null; return null;
} }
} }