From 2db3cbdebe8437ef2187e8eccffc223b117429a7 Mon Sep 17 00:00:00 2001 From: Jake Hotson Date: Wed, 28 Feb 2024 18:31:17 +0000 Subject: [PATCH 1/2] [CLEANUP] Use common ancestor `Value` in type specifications Replace the list of various possible sub-types with the common ancestor. Update the class diagram to indicate that `ValueList::$aComponents` no longer has a dependency on the sub-types definitions. Resolves #499. Supersedes and closes #506. --- README.md | 6 ------ src/Value/CSSFunction.php | 4 ++-- src/Value/Color.php | 6 +++--- src/Value/LineName.php | 2 +- src/Value/Value.php | 4 ++-- src/Value/ValueList.php | 11 +++++------ 6 files changed, 13 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 309b99d0..225d1e43 100644 --- a/README.md +++ b/README.md @@ -813,12 +813,6 @@ classDiagram RuleSet --> "*" Comment : aComments RuleSet --> "*" Rule : aRules URL --> "1" CSSString : oURL - ValueList --> "*" CSSFunction : aComponents - ValueList --> "*" CSSString : aComponents - ValueList --> "*" LineName : aComponents - ValueList --> "*" RuleValueList : aComponents - ValueList --> "*" Size : aComponents - ValueList --> "*" URL : aComponents ``` ## Contributors/Thanks to diff --git a/src/Value/CSSFunction.php b/src/Value/CSSFunction.php index 300dc3ec..e3235c81 100644 --- a/src/Value/CSSFunction.php +++ b/src/Value/CSSFunction.php @@ -18,7 +18,7 @@ class CSSFunction extends ValueList /** * @param string $sName - * @param RuleValueList|array $aArguments + * @param RuleValueList|array $aArguments * @param string $sSeparator * @param int $iLineNo */ @@ -72,7 +72,7 @@ public function setName($sName) } /** - * @return array + * @return array */ public function getArguments() { diff --git a/src/Value/Color.php b/src/Value/Color.php index 5daad412..55acdaaa 100644 --- a/src/Value/Color.php +++ b/src/Value/Color.php @@ -14,7 +14,7 @@ class Color extends CSSFunction { /** - * @param array $aColor + * @param array $aColor * @param int $iLineNo */ public function __construct(array $aColor, $iLineNo = 0) @@ -125,7 +125,7 @@ private static function mapRange($fVal, $fFromMin, $fFromMax, $fToMin, $fToMax) } /** - * @return array + * @return array */ public function getColor() { @@ -133,7 +133,7 @@ public function getColor() } /** - * @param array $aColor + * @param array $aColor * * @return void */ diff --git a/src/Value/LineName.php b/src/Value/LineName.php index e231ce38..6eaf7620 100644 --- a/src/Value/LineName.php +++ b/src/Value/LineName.php @@ -10,7 +10,7 @@ class LineName extends ValueList { /** - * @param array $aComponents + * @param array $aComponents * @param int $iLineNo */ public function __construct(array $aComponents = [], $iLineNo = 0) diff --git a/src/Value/Value.php b/src/Value/Value.php index 6be2110c..5b52a22d 100644 --- a/src/Value/Value.php +++ b/src/Value/Value.php @@ -30,14 +30,14 @@ public function __construct($iLineNo = 0) /** * @param array $aListDelimiters * - * @return RuleValueList|CSSFunction|CSSString|LineName|Size|URL|string + * @return Value|string * * @throws UnexpectedTokenException * @throws UnexpectedEOFException */ public static function parseValue(ParserState $oParserState, array $aListDelimiters = []) { - /** @var array $aStack */ + /** @var array $aStack */ $aStack = []; $oParserState->consumeWhiteSpace(); //Build a list of delimiters and parsed values diff --git a/src/Value/ValueList.php b/src/Value/ValueList.php index a93acc7b..382c3baa 100644 --- a/src/Value/ValueList.php +++ b/src/Value/ValueList.php @@ -13,7 +13,7 @@ abstract class ValueList extends Value { /** - * @var array + * @var array */ protected $aComponents; @@ -23,8 +23,7 @@ abstract class ValueList extends Value protected $sSeparator; /** - * phpcs:ignore Generic.Files.LineLength - * @param array|RuleValueList|CSSFunction|CSSString|LineName|Size|URL|string $aComponents + * @param array|Value|string $aComponents * @param string $sSeparator * @param int $iLineNo */ @@ -39,7 +38,7 @@ public function __construct($aComponents = [], $sSeparator = ',', $iLineNo = 0) } /** - * @param RuleValueList|CSSFunction|CSSString|LineName|Size|URL|string $mComponent + * @param Value|string $mComponent * * @return void */ @@ -49,7 +48,7 @@ public function addListComponent($mComponent) } /** - * @return array + * @return array */ public function getListComponents() { @@ -57,7 +56,7 @@ public function getListComponents() } /** - * @param array $aComponents + * @param array $aComponents * * @return void */ From 9619927bed0a847a7eaa4ac6a771ed0faf855602 Mon Sep 17 00:00:00 2001 From: Jake Hotson Date: Thu, 29 Feb 2024 18:30:59 +0000 Subject: [PATCH 2/2] Add class diagram reference from `ValueList::$aComponents` to `Value` --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 225d1e43..fbb03327 100644 --- a/README.md +++ b/README.md @@ -813,6 +813,7 @@ classDiagram RuleSet --> "*" Comment : aComments RuleSet --> "*" Rule : aRules URL --> "1" CSSString : oURL + ValueList --> "*" Value : aComponents ``` ## Contributors/Thanks to