-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #191 from ConnectThink/sb-scss-php-1.2.1
Updating to version 1.2.1 of ScssPhp
- Loading branch information
Showing
31 changed files
with
4,253 additions
and
1,567 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,36 @@ | ||
<?php | ||
|
||
if (version_compare(PHP_VERSION, '5.6') < 0) { | ||
throw new \Exception('scssphp requires PHP 5.6 or above'); | ||
throw new \Exception('scssphp requires PHP 5.6 or above'); | ||
} | ||
|
||
if (! class_exists('ScssPhp\ScssPhp\Version', false)) { | ||
include_once __DIR__ . '/src/Base/Range.php'; | ||
include_once __DIR__ . '/src/Block.php'; | ||
include_once __DIR__ . '/src/Cache.php'; | ||
include_once __DIR__ . '/src/Colors.php'; | ||
include_once __DIR__ . '/src/Compiler.php'; | ||
include_once __DIR__ . '/src/Compiler/Environment.php'; | ||
include_once __DIR__ . '/src/Exception/CompilerException.php'; | ||
include_once __DIR__ . '/src/Exception/ParserException.php'; | ||
include_once __DIR__ . '/src/Exception/RangeException.php'; | ||
include_once __DIR__ . '/src/Exception/ServerException.php'; | ||
include_once __DIR__ . '/src/Formatter.php'; | ||
include_once __DIR__ . '/src/Formatter/Compact.php'; | ||
include_once __DIR__ . '/src/Formatter/Compressed.php'; | ||
include_once __DIR__ . '/src/Formatter/Crunched.php'; | ||
include_once __DIR__ . '/src/Formatter/Debug.php'; | ||
include_once __DIR__ . '/src/Formatter/Expanded.php'; | ||
include_once __DIR__ . '/src/Formatter/Nested.php'; | ||
include_once __DIR__ . '/src/Formatter/OutputBlock.php'; | ||
include_once __DIR__ . '/src/Node.php'; | ||
include_once __DIR__ . '/src/Node/Number.php'; | ||
include_once __DIR__ . '/src/Parser.php'; | ||
include_once __DIR__ . '/src/SourceMap/Base64.php'; | ||
include_once __DIR__ . '/src/SourceMap/Base64VLQ.php'; | ||
include_once __DIR__ . '/src/SourceMap/SourceMapGenerator.php'; | ||
include_once __DIR__ . '/src/Type.php'; | ||
include_once __DIR__ . '/src/Util.php'; | ||
include_once __DIR__ . '/src/Version.php'; | ||
include_once __DIR__ . '/src/Base/Range.php'; | ||
include_once __DIR__ . '/src/Block.php'; | ||
include_once __DIR__ . '/src/Cache.php'; | ||
include_once __DIR__ . '/src/Colors.php'; | ||
include_once __DIR__ . '/src/Compiler.php'; | ||
include_once __DIR__ . '/src/Compiler/Environment.php'; | ||
include_once __DIR__ . '/src/Exception/SassException.php'; | ||
include_once __DIR__ . '/src/Exception/CompilerException.php'; | ||
include_once __DIR__ . '/src/Exception/ParserException.php'; | ||
include_once __DIR__ . '/src/Exception/RangeException.php'; | ||
include_once __DIR__ . '/src/Exception/ServerException.php'; | ||
include_once __DIR__ . '/src/Formatter.php'; | ||
include_once __DIR__ . '/src/Formatter/Compact.php'; | ||
include_once __DIR__ . '/src/Formatter/Compressed.php'; | ||
include_once __DIR__ . '/src/Formatter/Crunched.php'; | ||
include_once __DIR__ . '/src/Formatter/Debug.php'; | ||
include_once __DIR__ . '/src/Formatter/Expanded.php'; | ||
include_once __DIR__ . '/src/Formatter/Nested.php'; | ||
include_once __DIR__ . '/src/Formatter/OutputBlock.php'; | ||
include_once __DIR__ . '/src/Node.php'; | ||
include_once __DIR__ . '/src/Node/Number.php'; | ||
include_once __DIR__ . '/src/Parser.php'; | ||
include_once __DIR__ . '/src/SourceMap/Base64.php'; | ||
include_once __DIR__ . '/src/SourceMap/Base64VLQ.php'; | ||
include_once __DIR__ . '/src/SourceMap/SourceMapGenerator.php'; | ||
include_once __DIR__ . '/src/Type.php'; | ||
include_once __DIR__ . '/src/Util.php'; | ||
include_once __DIR__ . '/src/Version.php'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
<?php | ||
|
||
/** | ||
* SCSSPHP | ||
* | ||
* @copyright 2012-2019 Leaf Corcoran | ||
* @copyright 2012-2020 Leaf Corcoran | ||
* | ||
* @license http://opensource.org/licenses/MIT MIT | ||
* | ||
|
@@ -22,13 +23,12 @@ | |
* taking in account options that affects the result | ||
* | ||
* The cache manager is agnostic about data format and only the operation is expected to be described by string | ||
* | ||
*/ | ||
|
||
/** | ||
* SCSS cache | ||
* | ||
* @author Cedric Morin | ||
* @author Cedric Morin <[email protected]> | ||
*/ | ||
class Cache | ||
{ | ||
|
@@ -57,12 +57,12 @@ class Cache | |
public function __construct($options) | ||
{ | ||
// check $cacheDir | ||
if (isset($options['cache_dir'])) { | ||
self::$cacheDir = $options['cache_dir']; | ||
if (isset($options['cacheDir'])) { | ||
self::$cacheDir = $options['cacheDir']; | ||
} | ||
|
||
if (empty(self::$cacheDir)) { | ||
throw new Exception('cache_dir not set'); | ||
throw new Exception('cacheDir not set'); | ||
} | ||
|
||
if (isset($options['prefix'])) { | ||
|
@@ -74,7 +74,7 @@ public function __construct($options) | |
} | ||
|
||
if (isset($options['forceRefresh'])) { | ||
self::$forceRefresh = $options['force_refresh']; | ||
self::$forceRefresh = $options['forceRefresh']; | ||
} | ||
|
||
self::checkCacheDir(); | ||
|
@@ -97,18 +97,20 @@ public function getCache($operation, $what, $options = [], $lastModified = null) | |
{ | ||
$fileCache = self::$cacheDir . self::cacheName($operation, $what, $options); | ||
|
||
if ((! self::$forceRefresh || (self::$forceRefresh === 'once' && | ||
if ( | ||
((self::$forceRefresh === false) || (self::$forceRefresh === 'once' && | ||
isset(self::$refreshed[$fileCache]))) && file_exists($fileCache) | ||
) { | ||
$cacheTime = filemtime($fileCache); | ||
|
||
if ((is_null($lastModified) || $cacheTime > $lastModified) && | ||
if ( | ||
(\is_null($lastModified) || $cacheTime > $lastModified) && | ||
$cacheTime + self::$gcLifetime > time() | ||
) { | ||
$c = file_get_contents($fileCache); | ||
$c = unserialize($c); | ||
|
||
if (is_array($c) && isset($c['value'])) { | ||
if (\is_array($c) && isset($c['value'])) { | ||
return $c['value']; | ||
} | ||
} | ||
|
@@ -132,6 +134,7 @@ public function setCache($operation, $what, $value, $options = []) | |
|
||
$c = ['value' => $value]; | ||
$c = serialize($c); | ||
|
||
file_put_contents($fileCache, $c); | ||
|
||
if (self::$forceRefresh === 'once') { | ||
|
@@ -176,13 +179,11 @@ public static function checkCacheDir() | |
self::$cacheDir = str_replace('\\', '/', self::$cacheDir); | ||
self::$cacheDir = rtrim(self::$cacheDir, '/') . '/'; | ||
|
||
if (! file_exists(self::$cacheDir)) { | ||
if (! mkdir(self::$cacheDir)) { | ||
throw new Exception('Cache directory couldn\'t be created: ' . self::$cacheDir); | ||
} | ||
} elseif (! is_dir(self::$cacheDir)) { | ||
if (! is_dir(self::$cacheDir)) { | ||
throw new Exception('Cache directory doesn\'t exist: ' . self::$cacheDir); | ||
} elseif (! is_writable(self::$cacheDir)) { | ||
} | ||
|
||
if (! is_writable(self::$cacheDir)) { | ||
throw new Exception('Cache directory isn\'t writable: ' . self::$cacheDir); | ||
} | ||
} | ||
|
Oops, something went wrong.