Skip to content

Commit

Permalink
whitespace and camelCase
Browse files Browse the repository at this point in the history
  • Loading branch information
robocoder committed May 9, 2019
1 parent fe75475 commit 1cad1c8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
21 changes: 13 additions & 8 deletions src/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,8 @@ protected function glueFunctionSelectors($parts)
*/
protected function matchExtends($selector, &$out, $from = 0, $initial = true)
{

$selector = $this->glueFunctionSelectors($selector);

foreach ($selector as $i => $part) {
if ($i < $from) {
continue;
Expand Down Expand Up @@ -501,6 +501,7 @@ protected function matchExtends($selector, &$out, $from = 0, $initial = true)
$slice[] = $chunk;
}
}

array_unshift($replacement, $slice);

if (! $this->isImmediateRelationshipCombinator(end($slice))) {
Expand Down Expand Up @@ -1123,14 +1124,16 @@ protected function compileNestedBlock(Block $block, $selectors)
// wrap assign children in a block
// except for @font-face
if ($block->type !== Type::T_DIRECTIVE || $block->name !== "font-face") {
// need wraping?
// need wrapping?
$needWrapping = false;

foreach ($block->children as $child) {
if ($child[0] === Type::T_ASSIGN) {
$needWrapping = true;
break;
}
}

if ($needWrapping) {
$wrapped = new Block;
$wrapped->sourceName = $block->sourceName;
Expand Down Expand Up @@ -1561,6 +1564,7 @@ protected function evaluateMediaQuery($queryList)
}
}
}

return $queryList;
}

Expand Down Expand Up @@ -2144,10 +2148,10 @@ protected function compileChild($child, OutputBlock $out)
// clone the stored content to not have its scope spoiled by a further call to the same mixin
// i.e., recursive @include of the same mixin
if (isset($content)) {
$copy_content = clone $content;
$copy_content->scope = $callingScope;
$copyContent = clone $content;
$copyContent->scope = $callingScope;

$this->setRaw(static::$namespaces['special'] . 'content', $copy_content, $this->env);
$this->setRaw(static::$namespaces['special'] . 'content', $copyContent, $this->env);
}

if (isset($mixin->args)) {
Expand Down Expand Up @@ -3503,9 +3507,10 @@ public function get($name, $shouldThrow = true, Environment $env = null, $unredu
$nextIsRoot = false;
$hasNamespace = $normalizedName[0] === '^' || $normalizedName[0] === '@' || $normalizedName[0] === '%';

$max_depth = 10000;
$maxDepth = 10000;

for (;;) {
if ($max_depth-- <= 0) {
if ($maxDepth-- <= 0) {
break;
}
if (array_key_exists($normalizedName, $env->store)) {
Expand Down Expand Up @@ -3534,7 +3539,7 @@ public function get($name, $shouldThrow = true, Environment $env = null, $unredu
}

if ($shouldThrow) {
$this->throwError("Undefined variable \$$name" . ($max_depth<=0 ? " (infinite recursion)" : ""));
$this->throwError("Undefined variable \$$name" . ($maxDepth<=0 ? " (infinite recursion)" : ""));
}

// found nothing
Expand Down
14 changes: 7 additions & 7 deletions src/SourceMap/SourceMapGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class SourceMapGenerator
* @var array
*/
protected $sources = [];
protected $source_keys = [];
protected $sourceKeys = [];

/**
* @var array
Expand Down Expand Up @@ -181,8 +181,8 @@ public function generateJson()
// A list of original sources used by the 'mappings' entry.
$sourceMap['sources'] = [];

foreach ($this->sources as $source_uri => $source_filename) {
$sourceMap['sources'][] = $this->normalizeFilename($source_filename);
foreach ($this->sources as $sourceUri => $sourceFilename) {
$sourceMap['sources'][] = $this->normalizeFilename($sourceFilename);
}

// A list of symbol names used by the 'mappings' entry.
Expand Down Expand Up @@ -237,7 +237,7 @@ public function generateMappings()
return '';
}

$this->source_keys = array_flip(array_keys($this->sources));
$this->sourceKeys = array_flip(array_keys($this->sources));

// group mappings by generated line number.
$groupedMap = $groupedMapEncoded = [];
Expand All @@ -249,15 +249,15 @@ public function generateMappings()
ksort($groupedMap);
$lastGeneratedLine = $lastOriginalIndex = $lastOriginalLine = $lastOriginalColumn = 0;

foreach ($groupedMap as $lineNumber => $line_map) {
foreach ($groupedMap as $lineNumber => $lineMap) {
while (++$lastGeneratedLine < $lineNumber) {
$groupedMapEncoded[] = ';';
}

$lineMapEncoded = [];
$lastGeneratedColumn = 0;

foreach ($line_map as $m) {
foreach ($lineMap as $m) {
$mapEncoded = $this->encoder->encode($m['generated_column'] - $lastGeneratedColumn);
$lastGeneratedColumn = $m['generated_column'];

Expand Down Expand Up @@ -294,7 +294,7 @@ public function generateMappings()
*/
protected function findFileIndex($filename)
{
return $this->source_keys[$filename];
return $this->sourceKeys[$filename];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/FrameworkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public function testFramework($frameworkVerion, $inputdirectory, $inputfiles)
$this->scss->addImportPath($inputdirectory);

$input = file_get_contents($inputdirectory . $inputfiles);
//Test if no exeption are raised for the given framwork

// Test if no exceptions are raised for the given framework
$e = null;

try {
Expand Down
1 change: 0 additions & 1 deletion tests/inputs/extends.scss
Original file line number Diff line number Diff line change
Expand Up @@ -387,4 +387,3 @@ embed.bar {
.class3:not(:last-child) {
@extend .class1;
}

0 comments on commit 1cad1c8

Please sign in to comment.