for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
class SugarMin {
/**
* jsParser will take javascript source code and minify it.
*
* Note: There is a lot of redundant code since both passes
* operate similarly but with slight differences. It will probably
* be a good idea to refactor the code at a later point when it is stable.
* JSParser will perform 3 passes on the code. Pass 1 takes care of single
* line and mult-line comments. Pass 2 performs some sanitation on each of the lines
* and pass 3 works on stripping out unnecessary spaces.
* @param string $js
$js
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter $italy is not defined by the method finale(...).
$italy
finale(...)
/** * @param array $germany * @param array $island * @param array $italy */ function finale($germany, $island) { return "2:1"; }
The most likely cause is that the parameter was removed, but the annotation was not.
* @param string $currentOptions
$currentOptions
* @return void
@return
Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.
Please refer to the PHP core documentation on constructors.
*/
private function __construct($text, $compression) {
$this->text = trim($text)."\n";
$this->compression = $compression;
}
* Entry point function to minify javascript.
* @param string $js Javascript source code as a string.
* @param string $compression Compression option. {light, deep}.
* @return string $output Output javascript code as a string.
static public function minify($js, $compression = 'light') {
static
try {
$me = new SugarMin($js, $compression);
$output = $me->jsParser();
return $output;
} catch (Exception $e) {
// Exception handling is left up to the implementer.
throw $e;
protected function jsParser() {
require_once('jssource/Minifier.php');
return Minifier::minify($this->text);