From 1cad1c8fa3e0ecb29973ec25612455c6480d12b6 Mon Sep 17 00:00:00 2001 From: Anthon Pang Date: Thu, 9 May 2019 12:55:07 -0400 Subject: [PATCH] whitespace and camelCase --- src/Compiler.php | 21 +++++++++++++-------- src/SourceMap/SourceMapGenerator.php | 14 +++++++------- tests/FrameworkTest.php | 4 ++-- tests/inputs/extends.scss | 1 - 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/Compiler.php b/src/Compiler.php index 720e6f1e..75accf8e 100644 --- a/src/Compiler.php +++ b/src/Compiler.php @@ -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; @@ -501,6 +501,7 @@ protected function matchExtends($selector, &$out, $from = 0, $initial = true) $slice[] = $chunk; } } + array_unshift($replacement, $slice); if (! $this->isImmediateRelationshipCombinator(end($slice))) { @@ -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; @@ -1561,6 +1564,7 @@ protected function evaluateMediaQuery($queryList) } } } + return $queryList; } @@ -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)) { @@ -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)) { @@ -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 diff --git a/src/SourceMap/SourceMapGenerator.php b/src/SourceMap/SourceMapGenerator.php index 279a0214..d2001462 100644 --- a/src/SourceMap/SourceMapGenerator.php +++ b/src/SourceMap/SourceMapGenerator.php @@ -85,7 +85,7 @@ class SourceMapGenerator * @var array */ protected $sources = []; - protected $source_keys = []; + protected $sourceKeys = []; /** * @var array @@ -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. @@ -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 = []; @@ -249,7 +249,7 @@ 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[] = ';'; } @@ -257,7 +257,7 @@ public function generateMappings() $lineMapEncoded = []; $lastGeneratedColumn = 0; - foreach ($line_map as $m) { + foreach ($lineMap as $m) { $mapEncoded = $this->encoder->encode($m['generated_column'] - $lastGeneratedColumn); $lastGeneratedColumn = $m['generated_column']; @@ -294,7 +294,7 @@ public function generateMappings() */ protected function findFileIndex($filename) { - return $this->source_keys[$filename]; + return $this->sourceKeys[$filename]; } /** diff --git a/tests/FrameworkTest.php b/tests/FrameworkTest.php index 3be524dc..f4317e27 100644 --- a/tests/FrameworkTest.php +++ b/tests/FrameworkTest.php @@ -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 { diff --git a/tests/inputs/extends.scss b/tests/inputs/extends.scss index 609d0292..bd0ed959 100644 --- a/tests/inputs/extends.scss +++ b/tests/inputs/extends.scss @@ -387,4 +387,3 @@ embed.bar { .class3:not(:last-child) { @extend .class1; } -