Skip to content

Commit 05369ac

Browse files
committed
refactor semi-colon stripping (again)
1 parent 69e4907 commit 05369ac

File tree

9 files changed

+46
-49
lines changed

9 files changed

+46
-49
lines changed

scss.inc.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
include_once __DIR__ . '/src/Formatter/Expanded.php';
2121
include_once __DIR__ . '/src/Formatter/Nested.php';
2222
include_once __DIR__ . '/src/Formatter/OutputBlock.php';
23-
include_once __DIR__ . '/src/Formatter/StripSemiColons.php';
2423
include_once __DIR__ . '/src/Node.php';
2524
include_once __DIR__ . '/src/Node/Number.php';
2625
include_once __DIR__ . '/src/Parser.php';

src/Formatter.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ abstract class Formatter
5555
*/
5656
public $assignSeparator;
5757

58+
/**
59+
* @var boolea
60+
*/
61+
public $keepSemicolons;
62+
5863
/**
5964
* Initialize formatter
6065
*
@@ -96,6 +101,15 @@ public function property($name, $value)
96101
*/
97102
public function stripSemicolon(&$lines)
98103
{
104+
if ($this->keepSemicolons) {
105+
return;
106+
}
107+
108+
if (($count = count($lines))
109+
&& substr($lines[$count - 1], -1) === ';'
110+
) {
111+
$lines[$count - 1] = substr($lines[$count - 1], 0, -1);
112+
}
99113
}
100114

101115
/**

src/Formatter/Compact.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function __construct()
3232
$this->close = "}\n\n";
3333
$this->tagSeparator = ',';
3434
$this->assignSeparator = ':';
35+
$this->keepSemicolons = true;
3536
}
3637

3738
/**

src/Formatter/Compressed.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,20 @@
2121
*/
2222
class Compressed extends Formatter
2323
{
24-
use StripSemiColons;
24+
/**
25+
* {@inheritdoc}
26+
*/
27+
public function __construct()
28+
{
29+
$this->indentLevel = 0;
30+
$this->indentChar = ' ';
31+
$this->break = '';
32+
$this->open = '{';
33+
$this->close = '}';
34+
$this->tagSeparator = ',';
35+
$this->assignSeparator = ':';
36+
$this->keepSemicolons = false;
37+
}
2538

2639
/**
2740
* {@inheritdoc}

src/Formatter/Crunched.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,20 @@
2121
*/
2222
class Crunched extends Formatter
2323
{
24-
use StripSemiColons;
24+
/**
25+
* {@inheritdoc}
26+
*/
27+
public function __construct()
28+
{
29+
$this->indentLevel = 0;
30+
$this->indentChar = ' ';
31+
$this->break = '';
32+
$this->open = '{';
33+
$this->close = '}';
34+
$this->tagSeparator = ',';
35+
$this->assignSeparator = ':';
36+
$this->keepSemicolons = false;
37+
}
2538

2639
/**
2740
* {@inheritdoc}

src/Formatter/Debug.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function __construct()
3333
$this->close = ' }';
3434
$this->tagSeparator = ', ';
3535
$this->assignSeparator = ': ';
36+
$this->keepSemicolons = true;
3637
}
3738

3839
/**

src/Formatter/Expanded.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function __construct()
3333
$this->close = '}';
3434
$this->tagSeparator = ', ';
3535
$this->assignSeparator = ': ';
36+
$this->keepSemicolons = true;
3637
}
3738

3839
/**

src/Formatter/Nested.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function __construct()
3838
$this->close = ' }';
3939
$this->tagSeparator = ', ';
4040
$this->assignSeparator = ': ';
41+
$this->keepSemicolons = true;
4142
}
4243

4344
/**

src/Formatter/StripSemiColons.php

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)