diff --git a/src/Server.php b/src/Server.php index d677259..77959ec 100644 --- a/src/Server.php +++ b/src/Server.php @@ -1,5 +1,4 @@ scss->compileString(file_get_contents($in), $in); $css = $result->getCss(); - $elapsed = round((microtime(true) - $start), 4); $v = Version::VERSION; @@ -234,7 +232,6 @@ protected function compile($in, $out) return [$css, $etag]; } - /** * Adds to list of parsed files * @@ -257,7 +254,6 @@ protected function makeParsedFilesFromIncludeFiles($paths) return $parsedFiles; } - /** * Format error as a pseudo-element in CSS * @@ -321,7 +317,11 @@ public function compileFile($in, $out = null) $compiled = $result->getCss(); if (is_null($out)) { - return array('compiled' => $compiled, 'files' => $this->makeParsedFilesFromIncludeFiles(array_merge([$in], $result->getIncludedFiles())),); + return array( + 'compiled' => $compiled, + 'files' => $this->makeParsedFilesFromIncludeFiles(array_merge([$in], $result->getIncludedFiles())), + 'map' => $result->getSourceMap() + ); } return file_put_contents($out, $compiled); @@ -334,6 +334,8 @@ public function compileFile($in, $out = null) * @param string $out Output file (.css) * * @return bool + * + * @throws \ScssPhp\Server\ServerException */ public function checkedCompile($in, $out) { @@ -431,7 +433,7 @@ public function serve($salt = '') * * @return string Compiled CSS results * - * @throws \ScssPhp\ScssPhp\Exception\ServerException + * @throws \ScssPhp\Server\ServerException */ public function checkedCachedCompile($in, $out, $force = false) { @@ -472,6 +474,8 @@ public function checkedCachedCompile($in, $out, $force = false) * @param boolean $force Force rebuild? * * @return array scssphp cache structure + * + * @throws \ScssPhp\Server\ServerException */ public function cachedCompile($in, $force = false) { @@ -495,10 +499,14 @@ public function cachedCompile($in, $force = false) break; } } +// if (!file_exists($in['root']) or filemtime($in['root']) > $in['updated']) { +// // The main file has changed so we should compile. +// $root = $in['root']; +// } } } else { // TODO: Throw an exception? We got neither a string nor something - // that looks like a compatible lessphp cache structure. + // that looks like a compatible scssphp cache structure. return null; } @@ -522,6 +530,8 @@ public function cachedCompile($in, $force = false) * @param string $dir Root directory to .scss files * @param string $cacheDir Cache directory * @param \ScssPhp\ScssPhp\Compiler|null $scss SCSS compiler instance + * + * @throws \ScssPhp\Server\ServerException */ public function __construct($dir, $cacheDir = null, $scss = null) { @@ -545,6 +555,8 @@ public function __construct($dir, $cacheDir = null, $scss = null) $this->scss = $scss; $this->showErrorsAsCSS = false; - date_default_timezone_set('UTC'); + if (!ini_get('date.timezone') && function_exists('date_default_timezone_set')) { // PHP >= 5.1.0 + date_default_timezone_set('UTC'); + } } }