diff --git a/example/Server.php b/example/Server.php index 6ea97018..eaf9d7ea 100644 --- a/example/Server.php +++ b/example/Server.php @@ -11,9 +11,7 @@ namespace Leafo\ScssPhp; -use Leafo\ScssPhp\Compiler; use Leafo\ScssPhp\Exception\ServerException; -use Leafo\ScssPhp\Version; /** * Server @@ -468,7 +466,7 @@ public function cachedCompile($in, $force = false) if ($root !== null) { // If we have a root value which means we should rebuild. - $out = array(); + $out = []; $out['root'] = $root; $out['compiled'] = $this->compileFile($root); $out['files'] = $this->scss->getParsedFiles(); diff --git a/src/Compiler.php b/src/Compiler.php index 637f1c1c..56b463ec 100644 --- a/src/Compiler.php +++ b/src/Compiler.php @@ -12,16 +12,10 @@ namespace Leafo\ScssPhp; use Leafo\ScssPhp\Base\Range; -use Leafo\ScssPhp\Block; -use Leafo\ScssPhp\Colors; use Leafo\ScssPhp\Compiler\Environment; use Leafo\ScssPhp\Exception\CompilerException; use Leafo\ScssPhp\Formatter\OutputBlock; -use Leafo\ScssPhp\Node; use Leafo\ScssPhp\SourceMap\SourceMapGenerator; -use Leafo\ScssPhp\Type; -use Leafo\ScssPhp\Parser; -use Leafo\ScssPhp\Util; /** * The scss compiler and parser. @@ -1308,7 +1302,7 @@ protected function hasSelectorPlaceholder($selector) * @param array $stms * @param \Leafo\ScssPhp\Formatter\OutputBlock $out * - * @return array + * @return array|null */ protected function compileChildren($stms, OutputBlock $out) { @@ -1319,6 +1313,7 @@ protected function compileChildren($stms, OutputBlock $out) return $ret; } } + return null; } /** @@ -2004,7 +1999,7 @@ protected function shouldEval($value) switch ($value[0]) { case Type::T_EXPRESSION: if ($value[1] === '/') { - return $this->shouldEval($value[2], $value[3]); + return $this->shouldEval($value[2]); } // fall-thru @@ -2366,7 +2361,7 @@ protected function opModNumberNumber($left, $right) * @param array $left * @param array $right * - * @return array + * @return array|null */ protected function opAdd($left, $right) { @@ -2389,6 +2384,7 @@ protected function opAdd($left, $right) return $strRight; } + return null; } /** @@ -2398,12 +2394,12 @@ protected function opAdd($left, $right) * @param array $right * @param boolean $shouldEval * - * @return array + * @return array|null */ protected function opAnd($left, $right, $shouldEval) { if (! $shouldEval) { - return; + return null; } if ($left !== static::$false and $left !== static::$null) { @@ -2420,12 +2416,12 @@ protected function opAnd($left, $right, $shouldEval) * @param array $right * @param boolean $shouldEval * - * @return array + * @return array|null */ protected function opOr($left, $right, $shouldEval) { if (! $shouldEval) { - return; + return null; } if ($left !== static::$false and $left !== static::$null) { @@ -3158,7 +3154,7 @@ protected function setRaw($name, $value, Environment $env) * @param boolean $shouldThrow * @param \Leafo\ScssPhp\Compiler\Environment $env * - * @return mixed + * @return mixed|null */ public function get($name, $shouldThrow = true, Environment $env = null) { @@ -3200,6 +3196,7 @@ public function get($name, $shouldThrow = true, Environment $env = null) } // found nothing + return null; } /** @@ -3528,6 +3525,7 @@ public function setEncoding($encoding) public function setIgnoreErrors($ignoreErrors) { $this->ignoreErrors = $ignoreErrors; + return $this; } /** @@ -4925,7 +4923,7 @@ protected function libSetNth($args) if (! isset($list[2][$n])) { $this->throwError('Invalid argument for "n"'); - return; + return null; } $list[2][$n] = $args[2]; @@ -5163,7 +5161,7 @@ protected function libComparable($args) ) { $this->throwError('Invalid argument(s) for "comparable"'); - return; + return null; } $number1 = $number1->normalize(); @@ -5343,7 +5341,7 @@ protected function libRandom($args) if ($n < 1) { $this->throwError("limit must be greater than or equal to 1"); - return; + return null; } return new Node\Number(mt_rand(1, $n), ''); diff --git a/src/Formatter/Compressed.php b/src/Formatter/Compressed.php index 1faa7e11..8d86210c 100644 --- a/src/Formatter/Compressed.php +++ b/src/Formatter/Compressed.php @@ -12,7 +12,6 @@ namespace Leafo\ScssPhp\Formatter; use Leafo\ScssPhp\Formatter; -use Leafo\ScssPhp\Formatter\OutputBlock; /** * Compressed formatter diff --git a/src/Formatter/Crunched.php b/src/Formatter/Crunched.php index 42d77b5f..4569b4e2 100644 --- a/src/Formatter/Crunched.php +++ b/src/Formatter/Crunched.php @@ -12,7 +12,6 @@ namespace Leafo\ScssPhp\Formatter; use Leafo\ScssPhp\Formatter; -use Leafo\ScssPhp\Formatter\OutputBlock; /** * Crunched formatter diff --git a/src/Formatter/Debug.php b/src/Formatter/Debug.php index bfcbf41a..089c7987 100644 --- a/src/Formatter/Debug.php +++ b/src/Formatter/Debug.php @@ -12,7 +12,6 @@ namespace Leafo\ScssPhp\Formatter; use Leafo\ScssPhp\Formatter; -use Leafo\ScssPhp\Formatter\OutputBlock; /** * Debug formatter diff --git a/src/Formatter/Expanded.php b/src/Formatter/Expanded.php index d8c1e887..10e4225d 100644 --- a/src/Formatter/Expanded.php +++ b/src/Formatter/Expanded.php @@ -12,7 +12,6 @@ namespace Leafo\ScssPhp\Formatter; use Leafo\ScssPhp\Formatter; -use Leafo\ScssPhp\Formatter\OutputBlock; /** * Expanded formatter diff --git a/src/Formatter/Nested.php b/src/Formatter/Nested.php index 8f72206f..d43cb4fd 100644 --- a/src/Formatter/Nested.php +++ b/src/Formatter/Nested.php @@ -12,7 +12,6 @@ namespace Leafo\ScssPhp\Formatter; use Leafo\ScssPhp\Formatter; -use Leafo\ScssPhp\Formatter\OutputBlock; /** * Nested formatter diff --git a/src/Parser.php b/src/Parser.php index 748d38ae..c3f63c91 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -11,11 +11,7 @@ namespace Leafo\ScssPhp; -use Leafo\ScssPhp\Block; -use Leafo\ScssPhp\Compiler; use Leafo\ScssPhp\Exception\ParserException; -use Leafo\ScssPhp\Node; -use Leafo\ScssPhp\Type; /** * Parser @@ -1174,7 +1170,7 @@ protected function genericList(&$out, $parseItem, $delim = '', $flatten = true) { $s = $this->seek(); $items = []; - + $value = null; while ($this->$parseItem($value)) { $items[] = $value; diff --git a/src/SourceMap/Base64.php b/src/SourceMap/Base64.php index 9d17e6f0..54015bb9 100644 --- a/src/SourceMap/Base64.php +++ b/src/SourceMap/Base64.php @@ -21,7 +21,7 @@ class Base64 /** * @var array */ - private static $encodingMap = array ( + private static $encodingMap = [ 0 => 'A', 1 => 'B', 2 => 'C', @@ -86,12 +86,12 @@ class Base64 61 => '9', 62 => '+', 63 => '/', - ); + ]; /** * @var array */ - private static $decodingMap = array( + private static $decodingMap = [ 'A' => 0, 'B' => 1, 'C' => 2, @@ -156,7 +156,7 @@ class Base64 9 => 61, '+' => 62, '/' => 63, - ); + ]; /** * Convert to base64 diff --git a/src/SourceMap/Base64VLQ.php b/src/SourceMap/Base64VLQ.php index 6de3b5ee..9f617f7b 100644 --- a/src/SourceMap/Base64VLQ.php +++ b/src/SourceMap/Base64VLQ.php @@ -11,8 +11,6 @@ namespace Leafo\ScssPhp\SourceMap; -use Leafo\ScssPhp\SourceMap\Base64; - /** * Base 64 VLQ * diff --git a/src/SourceMap/Base64VLQEncoder.php b/src/SourceMap/Base64VLQEncoder.php index 1189ce0e..caf56c77 100644 --- a/src/SourceMap/Base64VLQEncoder.php +++ b/src/SourceMap/Base64VLQEncoder.php @@ -47,7 +47,7 @@ class Base64VLQEncoder * * @var array */ - private $charToIntMap = array( + private $charToIntMap = [ 'A' => 0, 'B' => 1, 'C' => 2, 'D' => 3, 'E' => 4, 'F' => 5, 'G' => 6, 'H' => 7, 'I' => 8, 'J' => 9, 'K' => 10, 'L' => 11, 'M' => 12, 'N' => 13, 'O' => 14, 'P' => 15, 'Q' => 16, 'R' => 17, 'S' => 18, 'T' => 19, 'U' => 20, 'V' => 21, 'W' => 22, 'X' => 23, @@ -56,14 +56,14 @@ class Base64VLQEncoder 'o' => 40, 'p' => 41, 'q' => 42, 'r' => 43, 's' => 44, 't' => 45, 'u' => 46, 'v' => 47, 'w' => 48, 'x' => 49, 'y' => 50, 'z' => 51, 0 => 52, 1 => 53, 2 => 54, 3 => 55, 4 => 56, 5 => 57, 6 => 58, 7 => 59, 8 => 60, 9 => 61, '+' => 62, '/' => 63, - ); + ]; /** * Integer to char map * * @var array */ - private $intToCharMap = array( + private $intToCharMap = [ 0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D', 4 => 'E', 5 => 'F', 6 => 'G', 7 => 'H', 8 => 'I', 9 => 'J', 10 => 'K', 11 => 'L', 12 => 'M', 13 => 'N', 14 => 'O', 15 => 'P', 16 => 'Q', 17 => 'R', 18 => 'S', 19 => 'T', 20 => 'U', 21 => 'V', 22 => 'W', 23 => 'X', @@ -72,7 +72,7 @@ class Base64VLQEncoder 40 => 'o', 41 => 'p', 42 => 'q', 43 => 'r', 44 => 's', 45 => 't', 46 => 'u', 47 => 'v', 48 => 'w', 49 => 'x', 50 => 'y', 51 => 'z', 52 => '0', 53 => '1', 54 => '2', 55 => '3', 56 => '4', 57 => '5', 58 => '6', 59 => '7', 60 => '8', 61 => '9', 62 => '+', 63 => '/', - ); + ]; /** * Constructor diff --git a/src/SourceMap/SourceMapGenerator.php b/src/SourceMap/SourceMapGenerator.php index 6e969cae..3f446aa4 100644 --- a/src/SourceMap/SourceMapGenerator.php +++ b/src/SourceMap/SourceMapGenerator.php @@ -33,7 +33,7 @@ class SourceMapGenerator * * @var array */ - protected $defaultOptions = array( + protected $defaultOptions = [ // an optional source root, useful for relocating source files // on a server or removing repeated values in the 'sources' entry. // This value is prepended to the individual entries in the 'source' field. @@ -56,7 +56,7 @@ class SourceMapGenerator // base path for filename normalization 'sourceMapBasepath' => '' - ); + ]; /** * The base64 VLQ encoder @@ -70,22 +70,22 @@ class SourceMapGenerator * * @var array */ - protected $mappings = array(); + protected $mappings = []; /** * Array of contents map * * @var array */ - protected $contentsMap = array(); + protected $contentsMap = []; /** * File to content map * * @var array */ - protected $sources = array(); - protected $source_keys = array(); + protected $sources = []; + protected $source_keys = []; /** * @var array @@ -109,13 +109,13 @@ public function __construct(array $options = []) */ public function addMapping($generatedLine, $generatedColumn, $originalLine, $originalColumn, $sourceFile) { - $this->mappings[] = array( + $this->mappings[] = [ 'generated_line' => $generatedLine, 'generated_column' => $generatedColumn, 'original_line' => $originalLine, 'original_column' => $originalColumn, 'source_file' => $sourceFile - ); + ]; $this->sources[$sourceFile] = $sourceFile; } @@ -156,7 +156,7 @@ public function saveMap($content) */ public function generateJson() { - $sourceMap = array(); + $sourceMap = []; $mappings = $this->generateMappings(); // File version (always the first entry in the object) and must be a positive integer. @@ -178,14 +178,14 @@ public function generateJson() } // A list of original sources used by the 'mappings' entry. - $sourceMap['sources'] = array(); + $sourceMap['sources'] = []; foreach ($this->sources as $source_uri => $source_filename) { $sourceMap['sources'][] = $this->normalizeFilename($source_filename); } // A list of symbol names used by the 'mappings' entry. - $sourceMap['names'] = array(); + $sourceMap['names'] = []; // A string with the encoded mapping data. $sourceMap['mappings'] = $mappings; @@ -216,7 +216,7 @@ protected function getSourcesContent() return null; } - $content = array(); + $content = []; foreach ($this->sources as $sourceFile) { $content[] = file_get_contents($sourceFile); @@ -239,7 +239,7 @@ public function generateMappings() $this->source_keys = array_flip(array_keys($this->sources)); // group mappings by generated line number. - $groupedMap = $groupedMapEncoded = array(); + $groupedMap = $groupedMapEncoded = []; foreach ($this->mappings as $m) { $groupedMap[$m['generated_line']][] = $m; @@ -253,7 +253,7 @@ public function generateMappings() $groupedMapEncoded[] = ';'; } - $lineMapEncoded = array(); + $lineMapEncoded = []; $lastGeneratedColumn = 0; foreach ($line_map as $m) { diff --git a/src/Util.php b/src/Util.php index 7526e020..a1e50658 100644 --- a/src/Util.php +++ b/src/Util.php @@ -63,7 +63,7 @@ public static function checkRange($name, Range $range, $value, $unit = '') */ public static function encodeURIComponent($string) { - $revert = array('%21' => '!', '%2A' => '*', '%27' => "'", '%28' => '(', '%29' => ')'); + $revert = ['%21' => '!', '%2A' => '*', '%27' => "'", '%28' => '(', '%29' => ')']; return strtr(rawurlencode($string), $revert); }