Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions example/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

namespace Leafo\ScssPhp;

use Leafo\ScssPhp\Compiler;
use Leafo\ScssPhp\Exception\ServerException;
use Leafo\ScssPhp\Version;

/**
* Server
Expand Down Expand Up @@ -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();
Expand Down
32 changes: 15 additions & 17 deletions src/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
{
Expand All @@ -1319,6 +1313,7 @@ protected function compileChildren($stms, OutputBlock $out)
return $ret;
}
}
return null;
}

/**
Expand Down Expand Up @@ -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]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't just a code smell. It looks like a bug.

return $this->shouldEval($value[2]);
}

// fall-thru
Expand Down Expand Up @@ -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)
{
Expand All @@ -2389,6 +2384,7 @@ protected function opAdd($left, $right)

return $strRight;
}
return null;
}

/**
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -3200,6 +3196,7 @@ public function get($name, $shouldThrow = true, Environment $env = null)
}

// found nothing
return null;
}

/**
Expand Down Expand Up @@ -3528,6 +3525,7 @@ public function setEncoding($encoding)
public function setIgnoreErrors($ignoreErrors)
{
$this->ignoreErrors = $ignoreErrors;
return $this;
}

/**
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -5163,7 +5161,7 @@ protected function libComparable($args)
) {
$this->throwError('Invalid argument(s) for "comparable"');

return;
return null;
}

$number1 = $number1->normalize();
Expand Down Expand Up @@ -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), '');
Expand Down
1 change: 0 additions & 1 deletion src/Formatter/Compressed.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Leafo\ScssPhp\Formatter;

use Leafo\ScssPhp\Formatter;
use Leafo\ScssPhp\Formatter\OutputBlock;

/**
* Compressed formatter
Expand Down
1 change: 0 additions & 1 deletion src/Formatter/Crunched.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Leafo\ScssPhp\Formatter;

use Leafo\ScssPhp\Formatter;
use Leafo\ScssPhp\Formatter\OutputBlock;

/**
* Crunched formatter
Expand Down
1 change: 0 additions & 1 deletion src/Formatter/Debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Leafo\ScssPhp\Formatter;

use Leafo\ScssPhp\Formatter;
use Leafo\ScssPhp\Formatter\OutputBlock;

/**
* Debug formatter
Expand Down
1 change: 0 additions & 1 deletion src/Formatter/Expanded.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Leafo\ScssPhp\Formatter;

use Leafo\ScssPhp\Formatter;
use Leafo\ScssPhp\Formatter\OutputBlock;

/**
* Expanded formatter
Expand Down
1 change: 0 additions & 1 deletion src/Formatter/Nested.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Leafo\ScssPhp\Formatter;

use Leafo\ScssPhp\Formatter;
use Leafo\ScssPhp\Formatter\OutputBlock;

/**
* Nested formatter
Expand Down
6 changes: 1 addition & 5 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1174,7 +1170,7 @@ protected function genericList(&$out, $parseItem, $delim = '', $flatten = true)
{
$s = $this->seek();
$items = [];

$value = null;
while ($this->$parseItem($value)) {
$items[] = $value;

Expand Down
8 changes: 4 additions & 4 deletions src/SourceMap/Base64.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Base64
/**
* @var array
*/
private static $encodingMap = array (
private static $encodingMap = [
0 => 'A',
1 => 'B',
2 => 'C',
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -156,7 +156,7 @@ class Base64
9 => 61,
'+' => 62,
'/' => 63,
);
];

/**
* Convert to base64
Expand Down
2 changes: 0 additions & 2 deletions src/SourceMap/Base64VLQ.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace Leafo\ScssPhp\SourceMap;

use Leafo\ScssPhp\SourceMap\Base64;

/**
* Base 64 VLQ
*
Expand Down
8 changes: 4 additions & 4 deletions src/SourceMap/Base64VLQEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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',
Expand All @@ -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
Expand Down
Loading