diff --git a/min/lib/Minify/HTML/Helper.php b/min/lib/Minify/HTML/Helper.php index 807fdc9..5c2bd8c 100644 --- a/min/lib/Minify/HTML/Helper.php +++ b/min/lib/Minify/HTML/Helper.php @@ -15,10 +15,10 @@ class Minify_HTML_Helper { public $minAppUri = '/min'; public $groupsConfigFile = ''; - /* + /** * Get an HTML-escaped Minify URI for a group or set of files * - * @param mixed $keyOrFiles a group key or array of filepaths/URIs + * @param string|array $keyOrFiles a group key or array of filepaths/URIs * @param array $opts options: * 'farExpires' : (default true) append a modified timestamp for cache revving * 'debug' : (default false) append debug flag @@ -51,8 +51,12 @@ class Minify_HTML_Helper { return htmlspecialchars($uri, ENT_QUOTES, $opts['charset']); } - /* + /** * Get non-HTML-escaped URI to minify the specified files + * + * @param bool $farExpires + * @param bool $debug + * @return string */ public function getRawUri($farExpires = true, $debug = false) { @@ -74,6 +78,12 @@ class Minify_HTML_Helper { return $path; } + /** + * Set the files that will comprise the URI we're building + * + * @param array $files + * @param bool $checkLastModified + */ public function setFiles($files, $checkLastModified = true) { $this->_groupKey = null; @@ -94,6 +104,12 @@ class Minify_HTML_Helper { $this->_filePaths = $files; } + /** + * Set the group of files that will comprise the URI we're building + * + * @param string $key + * @param bool $checkLastModified + */ public function setGroup($key, $checkLastModified = true) { $this->_groupKey = $key; @@ -109,7 +125,14 @@ class Minify_HTML_Helper { } } } - + + /** + * Get the max(lastModified) of all files + * + * @param array|string $sources + * @param int $lastModified + * @return int + */ public static function getLastModified($sources, $lastModified = 0) { $max = $lastModified; @@ -142,13 +165,19 @@ class Minify_HTML_Helper { * @return mixed a common char or '' if any do not match */ protected static function _getCommonCharAtPos($arr, $pos) { - $l = count($arr); + if (!isset($arr[0][$pos])) { + return ''; + } $c = $arr[0][$pos]; - if ($c === '' || $l === 1) + $l = count($arr); + if ($l === 1) { return $c; - for ($i = 1; $i < $l; ++$i) - if ($arr[$i][$pos] !== $c) + } + for ($i = 1; $i < $l; ++$i) { + if ($arr[$i][$pos] !== $c) { return ''; + } + } return $c; } @@ -157,11 +186,11 @@ class Minify_HTML_Helper { * * @param array $paths root-relative URIs of files * @param string $minRoot root-relative URI of the "min" application + * @return string */ protected static function _getShortestUri($paths, $minRoot = '/min/') { $pos = 0; $base = ''; - $c; while (true) { $c = self::_getCommonCharAtPos($paths, $pos); if ($c === '') {