Skip to content

Commit 215c199

Browse files
authored
[CLEANUP] Avoid Hungarian notation in Settings (#1008)
We'll change the direct accesses to use the accessors in a later chance. Part of #756
1 parent f661c96 commit 215c199

File tree

9 files changed

+31
-31
lines changed

9 files changed

+31
-31
lines changed

src/CSSList/CSSList.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public static function parseList(ParserState $parserState, CSSList $list): void
7474
if (\is_string($parserState)) {
7575
$parserState = new ParserState($parserState, Settings::create());
7676
}
77-
$usesLenientParsing = $parserState->getSettings()->bLenientParsing;
77+
$usesLenientParsing = $parserState->getSettings()->lenientParsing;
7878
$comments = [];
7979
while (!$parserState->isEnd()) {
8080
$comments = \array_merge($comments, $parserState->consumeWhiteSpace());
@@ -138,7 +138,7 @@ private static function parseListItem(ParserState $parserState, CSSList $list)
138138
return $atRule;
139139
} elseif ($parserState->comes('}')) {
140140
if ($isRoot) {
141-
if ($parserState->getSettings()->bLenientParsing) {
141+
if ($parserState->getSettings()->lenientParsing) {
142142
return DeclarationBlock::parse($parserState);
143143
} else {
144144
throw new SourceException('Unopened {', $parserState->currentLine());
@@ -215,7 +215,7 @@ private static function parseAtRule(ParserState $parserState)
215215
// Unknown other at rule (font-face or such)
216216
$arguments = \trim($parserState->consumeUntil('{', false, true));
217217
if (\substr_count($arguments, '(') != \substr_count($arguments, ')')) {
218-
if ($parserState->getSettings()->bLenientParsing) {
218+
if ($parserState->getSettings()->lenientParsing) {
219219
return null;
220220
} else {
221221
throw new SourceException('Unmatched brace count in media query', $parserState->currentLine());

src/Parsing/ParserState.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __construct($text, Settings $parserSettings, $lineNumber = 1)
5858
$this->parserSettings = $parserSettings;
5959
$this->text = $text;
6060
$this->lineNumber = $lineNumber;
61-
$this->setCharset($this->parserSettings->sDefaultCharset);
61+
$this->setCharset($this->parserSettings->defaultCharset);
6262
}
6363

6464
/**
@@ -151,7 +151,7 @@ public function parseCharacter($isForIdentifier)
151151
{
152152
if ($this->peek() === '\\') {
153153
if (
154-
$isForIdentifier && $this->parserSettings->bLenientParsing
154+
$isForIdentifier && $this->parserSettings->lenientParsing
155155
&& ($this->comes('\\0') || $this->comes('\\9'))
156156
) {
157157
// Non-strings can contain \0 or \9 which is an IE hack supported in lenient parsing.
@@ -215,7 +215,7 @@ public function consumeWhiteSpace(): array
215215
while (\preg_match('/\\s/isSu', $this->peek()) === 1) {
216216
$this->consume(1);
217217
}
218-
if ($this->parserSettings->bLenientParsing) {
218+
if ($this->parserSettings->lenientParsing) {
219219
try {
220220
$comment = $this->consumeComment();
221221
} catch (UnexpectedEOFException $e) {
@@ -416,7 +416,7 @@ public function backtrack($numberOfCharacters): void
416416
*/
417417
public function strlen($string): int
418418
{
419-
if ($this->parserSettings->bMultibyteSupport) {
419+
if ($this->parserSettings->multibyteSupport) {
420420
return \mb_strlen($string, $this->charset);
421421
} else {
422422
return \strlen($string);
@@ -449,7 +449,7 @@ private function substr($offset, $length): string
449449
*/
450450
private function strtolower($string): string
451451
{
452-
if ($this->parserSettings->bMultibyteSupport) {
452+
if ($this->parserSettings->multibyteSupport) {
453453
return \mb_strtolower($string, $this->charset);
454454
} else {
455455
return \strtolower($string);
@@ -465,7 +465,7 @@ private function strtolower($string): string
465465
*/
466466
private function strsplit($string)
467467
{
468-
if ($this->parserSettings->bMultibyteSupport) {
468+
if ($this->parserSettings->multibyteSupport) {
469469
if ($this->streql($this->charset, 'utf-8')) {
470470
$result = \preg_split('//u', $string, -1, PREG_SPLIT_NO_EMPTY);
471471
if (!\is_array($result)) {
@@ -498,7 +498,7 @@ private function strsplit($string)
498498
*/
499499
private function strpos($haystack, $needle, $offset)
500500
{
501-
if ($this->parserSettings->bMultibyteSupport) {
501+
if ($this->parserSettings->multibyteSupport) {
502502
return \mb_strpos($haystack, $needle, $offset, $this->charset);
503503
} else {
504504
return \strpos($haystack, $needle, $offset);

src/Rule/Rule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static function parse(ParserState $parserState): Rule
9191
$parserState->consume(':');
9292
$value = Value::parseValue($parserState, self::listDelimiterForRule($rule->getRule()));
9393
$rule->setValue($value);
94-
if ($parserState->getSettings()->bLenientParsing) {
94+
if ($parserState->getSettings()->lenientParsing) {
9595
while ($parserState->comes('\\')) {
9696
$parserState->consume('\\');
9797
$rule->addIeHack($parserState->consume());

src/RuleSet/DeclarationBlock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static function parse(ParserState $parserState, $list = null)
6161
$parserState->consume(1);
6262
}
6363
} catch (UnexpectedTokenException $e) {
64-
if ($parserState->getSettings()->bLenientParsing) {
64+
if ($parserState->getSettings()->lenientParsing) {
6565
if (!$parserState->comes('}')) {
6666
$parserState->consumeUntil('}', false, true);
6767
}

src/RuleSet/RuleSet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static function parseRuleSet(ParserState $parserState, RuleSet $ruleSet):
6464
}
6565
while (!$parserState->comes('}')) {
6666
$rule = null;
67-
if ($parserState->getSettings()->bLenientParsing) {
67+
if ($parserState->getSettings()->lenientParsing) {
6868
try {
6969
$rule = Rule::parse($parserState);
7070
} catch (UnexpectedTokenException $e) {

src/Settings.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Settings
2121
*
2222
* @internal since 8.8.0, will be made private in 9.0.0
2323
*/
24-
public $bMultibyteSupport;
24+
public $multibyteSupport;
2525

2626
/**
2727
* The default charset for the CSS if no `@charset` declaration is found. Defaults to utf-8.
@@ -30,7 +30,7 @@ class Settings
3030
*
3131
* @internal since 8.8.0, will be made private in 9.0.0
3232
*/
33-
public $sDefaultCharset = 'utf-8';
33+
public $defaultCharset = 'utf-8';
3434

3535
/**
3636
* Whether the parser silently ignore invalid rules instead of choking on them.
@@ -39,11 +39,11 @@ class Settings
3939
*
4040
* @internal since 8.8.0, will be made private in 9.0.0
4141
*/
42-
public $bLenientParsing = true;
42+
public $lenientParsing = true;
4343

4444
private function __construct()
4545
{
46-
$this->bMultibyteSupport = \extension_loaded('mbstring');
46+
$this->multibyteSupport = \extension_loaded('mbstring');
4747
}
4848

4949
public static function create(): self
@@ -59,9 +59,9 @@ public static function create(): self
5959
*
6060
* @return $this fluent interface
6161
*/
62-
public function withMultibyteSupport(bool $bMultibyteSupport = true): self
62+
public function withMultibyteSupport(bool $multibyteSupport = true): self
6363
{
64-
$this->bMultibyteSupport = $bMultibyteSupport;
64+
$this->multibyteSupport = $multibyteSupport;
6565
return $this;
6666
}
6767

@@ -70,9 +70,9 @@ public function withMultibyteSupport(bool $bMultibyteSupport = true): self
7070
*
7171
* @return $this fluent interface
7272
*/
73-
public function withDefaultCharset(string $sDefaultCharset): self
73+
public function withDefaultCharset(string $defaultCharset): self
7474
{
75-
$this->sDefaultCharset = $sDefaultCharset;
75+
$this->defaultCharset = $defaultCharset;
7676
return $this;
7777
}
7878

@@ -83,7 +83,7 @@ public function withDefaultCharset(string $sDefaultCharset): self
8383
*/
8484
public function withLenientParsing(bool $usesLenientParsing = true): self
8585
{
86-
$this->bLenientParsing = $usesLenientParsing;
86+
$this->lenientParsing = $usesLenientParsing;
8787
return $this;
8888
}
8989

src/Value/LineName.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static function parse(ParserState $parserState): LineName
3232
$parserState->consumeWhiteSpace();
3333
$aNames = [];
3434
do {
35-
if ($parserState->getSettings()->bLenientParsing) {
35+
if ($parserState->getSettings()->lenientParsing) {
3636
try {
3737
$aNames[] = $parserState->parseIdentifier();
3838
} catch (UnexpectedTokenException $e) {

src/Value/Value.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public static function parsePrimitiveValue(ParserState $parserState)
166166
$oValue = Color::parse($parserState);
167167
} elseif ($parserState->comes("'") || $parserState->comes('"')) {
168168
$oValue = CSSString::parse($parserState);
169-
} elseif ($parserState->comes('progid:') && $parserState->getSettings()->bLenientParsing) {
169+
} elseif ($parserState->comes('progid:') && $parserState->getSettings()->lenientParsing) {
170170
$oValue = self::parseMicrosoftFilter($parserState);
171171
} elseif ($parserState->comes('[')) {
172172
$oValue = LineName::parse($parserState);

tests/Unit/SettingsTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function createReturnsANewInstanceForEachCall(): void
4848
*/
4949
public function multibyteSupportByDefaultStateOfMbStringExtension(): void
5050
{
51-
self::assertSame(\extension_loaded('mbstring'), $this->subject->bMultibyteSupport);
51+
self::assertSame(\extension_loaded('mbstring'), $this->subject->multibyteSupport);
5252
}
5353

5454
/**
@@ -78,15 +78,15 @@ public function withMultibyteSupportSetsMultibyteSupport(bool $value): void
7878
{
7979
$this->subject->withMultibyteSupport($value);
8080

81-
self::assertSame($value, $this->subject->bMultibyteSupport);
81+
self::assertSame($value, $this->subject->multibyteSupport);
8282
}
8383

8484
/**
8585
* @test
8686
*/
8787
public function defaultCharsetByDefaultIsUtf8(): void
8888
{
89-
self::assertSame('utf-8', $this->subject->sDefaultCharset);
89+
self::assertSame('utf-8', $this->subject->defaultCharset);
9090
}
9191

9292
/**
@@ -105,15 +105,15 @@ public function withDefaultCharsetSetsDefaultCharset(): void
105105
$charset = 'ISO-8859-1';
106106
$this->subject->withDefaultCharset($charset);
107107

108-
self::assertSame($charset, $this->subject->sDefaultCharset);
108+
self::assertSame($charset, $this->subject->defaultCharset);
109109
}
110110

111111
/**
112112
* @test
113113
*/
114114
public function lenientParsingByDefaultIsTrue(): void
115115
{
116-
self::assertTrue($this->subject->bLenientParsing);
116+
self::assertTrue($this->subject->lenientParsing);
117117
}
118118

119119
/**
@@ -132,7 +132,7 @@ public function withLenientParsingSetsLenientParsing(bool $value): void
132132
{
133133
$this->subject->withLenientParsing($value);
134134

135-
self::assertSame($value, $this->subject->bLenientParsing);
135+
self::assertSame($value, $this->subject->lenientParsing);
136136
}
137137

138138
/**
@@ -150,6 +150,6 @@ public function beStrictSetsLenientParsingToFalse(): void
150150
{
151151
$this->subject->beStrict();
152152

153-
self::assertFalse($this->subject->bLenientParsing);
153+
self::assertFalse($this->subject->lenientParsing);
154154
}
155155
}

0 commit comments

Comments
 (0)