Update composer dependencies

This commit is contained in:
Kijin Sung 2016-03-22 11:26:00 +09:00
parent 06f5151f8f
commit 365d7cdba9
58 changed files with 1245 additions and 5987 deletions

View file

@ -12,10 +12,11 @@
namespace Leafo\ScssPhp;
use Leafo\ScssPhp\Compiler;
use Leafo\ScssPhp\Exception\ServerException;
use Leafo\ScssPhp\Version;
/**
* SCSS server
* Server
*
* @author Leaf Corcoran <leafot@gmail.com>
*/
@ -115,13 +116,12 @@ class Server
/**
* Determine whether .scss file needs to be re-compiled.
*
* @param string $in Input path
* @param string $out Output path
* @param string $etag ETag
*
* @return boolean True if compile required.
*/
protected function needsCompile($in, $out, &$etag)
protected function needsCompile($out, &$etag)
{
if (! is_file($out)) {
return true;
@ -207,21 +207,21 @@ class Server
$elapsed = round((microtime(true) - $start), 4);
$v = Version::VERSION;
$t = @date('r');
$t = date('r');
$css = "/* compiled by scssphp $v on $t (${elapsed}s) */\n\n" . $css;
$etag = md5($css);
file_put_contents($out, $css);
file_put_contents(
$this->metadataName($out),
serialize(array(
serialize([
'etag' => $etag,
'imports' => $this->scss->getParsedFiles(),
'vars' => crc32(serialize($this->scss->getVariables())),
))
])
);
return array($css, $etag);
return [$css, $etag];
}
/**
@ -231,11 +231,11 @@ class Server
*
* @return string
*/
protected function createErrorCSS($error)
protected function createErrorCSS(\Exception $error)
{
$message = str_replace(
array("'", "\n"),
array("\\'", "\\A"),
["'", "\n"],
["\\'", "\\A"],
$error->getfile() . ":\n\n" . $error->getMessage()
);
@ -269,11 +269,13 @@ class Server
* @param string $out Output file (.css) optional
*
* @return string|bool
*
* @throws \Leafo\ScssPhp\Exception\ServerException
*/
public function compileFile($in, $out = null)
{
if (! is_readable($in)) {
throw new \Exception('load error: failed to find ' . $in);
throw new ServerException('load error: failed to find ' . $in);
}
$pi = pathinfo($in);
@ -323,7 +325,7 @@ class Server
$output = $this->cacheName($salt . $input);
$etag = $noneMatch = trim($this->getIfNoneMatchHeader(), '"');
if ($this->needsCompile($input, $output, $etag)) {
if ($this->needsCompile($output, $etag)) {
try {
list($css, $etag) = $this->compile($input, $output);
@ -334,7 +336,6 @@ class Server
header('ETag: "' . $etag . '"');
echo $css;
} catch (\Exception $e) {
if ($this->showErrorsAsCSS) {
header('Content-type: text/css');
@ -346,7 +347,6 @@ class Server
echo 'Parse error: ' . $e->getMessage() . "\n";
}
}
return;
@ -365,7 +365,7 @@ class Server
$modifiedSince = $this->getIfModifiedSinceHeader();
$mtime = filemtime($output);
if (@strtotime($modifiedSince) === $mtime) {
if (strtotime($modifiedSince) === $mtime) {
header($protocol . ' 304 Not Modified');
return;
@ -395,19 +395,19 @@ class Server
*
* @return string Compiled CSS results
*
* @throws \Exception
* @throws \Leafo\ScssPhp\Exception\ServerException
*/
public function checkedCachedCompile($in, $out, $force = false)
{
if (! is_file($in) || ! is_readable($in)) {
throw new \Exception('Invalid or unreadable input file specified.');
throw new ServerException('Invalid or unreadable input file specified.');
}
if (is_dir($out) || ! is_writable(file_exists($out) ? $out : dirname($out))) {
throw new \Exception('Invalid or unwritable output file specified.');
throw new ServerException('Invalid or unwritable output file specified.');
}
if ($force || $this->needsCompile($in, $out, $etag)) {
if ($force || $this->needsCompile($out, $etag)) {
list($css, $etag) = $this->compile($in, $out);
} else {
$css = file_get_contents($out);
@ -444,6 +444,10 @@ class Server
$this->scss = $scss;
$this->showErrorsAsCSS = false;
if (! ini_get('date.timezone')) {
date_default_timezone_set('UTC');
}
}
/**