From b597d16a8c8e09495980feb2ea84a7ad83050e40 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Sun, 16 Feb 2025 11:57:57 +0100 Subject: [PATCH 1/2] [CLEANUP] Avoid Hungarian notation for `text`/`texts` Part of #756 --- src/Parser.php | 6 +++--- src/Parsing/ParserState.php | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Parser.php b/src/Parser.php index 7f3a9229..eae809a5 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -19,15 +19,15 @@ class Parser private $parserState; /** - * @param string $sText the complete CSS as text (i.e., usually the contents of a CSS file) + * @param string $text the complete CSS as text (i.e., usually the contents of a CSS file) * @param int<0, max> $lineNumber the line number (starting from 1, not from 0) */ - public function __construct($sText, ?Settings $parserSettings = null, $lineNumber = 1) + public function __construct($text, ?Settings $parserSettings = null, $lineNumber = 1) { if ($parserSettings === null) { $parserSettings = Settings::create(); } - $this->parserState = new ParserState($sText, $parserSettings, $lineNumber); + $this->parserState = new ParserState($text, $parserSettings, $lineNumber); } /** diff --git a/src/Parsing/ParserState.php b/src/Parsing/ParserState.php index 9ffd65e0..6b0de3c2 100644 --- a/src/Parsing/ParserState.php +++ b/src/Parsing/ParserState.php @@ -27,12 +27,12 @@ class ParserState /** * @var string */ - private $sText; + private $text; /** * @var array */ - private $aText; + private $texts; /** * @var int @@ -57,13 +57,13 @@ class ParserState private $lineNumber; /** - * @param string $sText the complete CSS as text (i.e., usually the contents of a CSS file) + * @param string $text the complete CSS as text (i.e., usually the contents of a CSS file) * @param int<0, max> $lineNumber */ - public function __construct($sText, Settings $parserSettings, $lineNumber = 1) + public function __construct($text, Settings $parserSettings, $lineNumber = 1) { $this->parserSettings = $parserSettings; - $this->sText = $sText; + $this->text = $text; $this->lineNumber = $lineNumber; $this->setCharset($this->parserSettings->sDefaultCharset); } @@ -76,9 +76,9 @@ public function __construct($sText, Settings $parserSettings, $lineNumber = 1) public function setCharset($sCharset): void { $this->sCharset = $sCharset; - $this->aText = $this->strsplit($this->sText); - if (\is_array($this->aText)) { - $this->iLength = \count($this->aText); + $this->texts = $this->strsplit($this->text); + if (\is_array($this->texts)) { + $this->iLength = \count($this->texts); } } @@ -451,7 +451,7 @@ private function substr($iStart, $iLength): string } $result = ''; while ($iLength > 0) { - $result .= $this->aText[$iStart]; + $result .= $this->texts[$iStart]; $iStart++; $iLength--; } From 990e79bf58d1e650257225e9f6fc16373d8d80ca Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Mon, 17 Feb 2025 19:08:15 +0100 Subject: [PATCH 2/2] Changes suggested in code review --- src/Parsing/ParserState.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Parsing/ParserState.php b/src/Parsing/ParserState.php index 6b0de3c2..261c3995 100644 --- a/src/Parsing/ParserState.php +++ b/src/Parsing/ParserState.php @@ -32,7 +32,7 @@ class ParserState /** * @var array */ - private $texts; + private $characters; /** * @var int @@ -76,9 +76,9 @@ public function __construct($text, Settings $parserSettings, $lineNumber = 1) public function setCharset($sCharset): void { $this->sCharset = $sCharset; - $this->texts = $this->strsplit($this->text); - if (\is_array($this->texts)) { - $this->iLength = \count($this->texts); + $this->characters = $this->strsplit($this->text); + if (\is_array($this->characters)) { + $this->iLength = \count($this->characters); } } @@ -451,7 +451,7 @@ private function substr($iStart, $iLength): string } $result = ''; while ($iLength > 0) { - $result .= $this->texts[$iStart]; + $result .= $this->characters[$iStart]; $iStart++; $iLength--; }