From a1f03abc05624e9a63e8e357f77681ab8eabcef9 Mon Sep 17 00:00:00 2001 From: Jake Hotson Date: Tue, 27 Feb 2024 17:45:30 +0000 Subject: [PATCH] [CLEANUP] Add an interface for components of a property value Resolves #499. --- src/Value/CSSFunction.php | 6 +++--- src/Value/CSSString.php | 2 +- src/Value/Color.php | 8 ++++---- src/Value/Component.php | 11 +++++++++++ src/Value/LineName.php | 4 ++-- src/Value/RuleValueList.php | 2 +- src/Value/Size.php | 2 +- src/Value/URL.php | 2 +- src/Value/Value.php | 4 ++-- src/Value/ValueList.php | 8 ++++---- 10 files changed, 30 insertions(+), 19 deletions(-) create mode 100644 src/Value/Component.php diff --git a/src/Value/CSSFunction.php b/src/Value/CSSFunction.php index 300dc3ec..1aeffe13 100644 --- a/src/Value/CSSFunction.php +++ b/src/Value/CSSFunction.php @@ -9,7 +9,7 @@ * A `CSSFunction` represents a special kind of value that also contains a function name and where the values are the * function’s arguments. It also handles equals-sign-separated argument lists like `filter: alpha(opacity=90);`. */ -class CSSFunction extends ValueList +class CSSFunction extends ValueList implements Component { /** * @var string @@ -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/CSSString.php b/src/Value/CSSString.php index da498d41..9a5b559d 100644 --- a/src/Value/CSSString.php +++ b/src/Value/CSSString.php @@ -13,7 +13,7 @@ * * `CSSString`s always output with double quotes. */ -class CSSString extends PrimitiveValue +class CSSString extends PrimitiveValue implements Component { /** * @var string diff --git a/src/Value/Color.php b/src/Value/Color.php index 5daad412..1a6ec813 100644 --- a/src/Value/Color.php +++ b/src/Value/Color.php @@ -11,10 +11,10 @@ * `Color's can be input in the form #rrggbb, #rgb or schema(val1, val2, …) but are always stored as an array of * ('s' => val1, 'c' => val2, 'h' => val3, …) and output in the second form. */ -class Color extends CSSFunction +class Color extends CSSFunction implements Component { /** - * @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/Component.php b/src/Value/Component.php new file mode 100644 index 00000000..3a9a7270 --- /dev/null +++ b/src/Value/Component.php @@ -0,0 +1,11 @@ + $aComponents + * @param array $aComponents * @param int $iLineNo */ public function __construct(array $aComponents = [], $iLineNo = 0) diff --git a/src/Value/RuleValueList.php b/src/Value/RuleValueList.php index 8fe88b61..0d7ce12f 100644 --- a/src/Value/RuleValueList.php +++ b/src/Value/RuleValueList.php @@ -7,7 +7,7 @@ * (where the value would be a whitespace-separated list of the primitive value `bold`, a slash-separated list * and a comma-separated list). */ -class RuleValueList extends ValueList +class RuleValueList extends ValueList implements Component { /** * @param string $sSeparator diff --git a/src/Value/Size.php b/src/Value/Size.php index f8336b1f..b3de0b41 100644 --- a/src/Value/Size.php +++ b/src/Value/Size.php @@ -10,7 +10,7 @@ /** * A `Size` consists of a numeric `size` value and a unit. */ -class Size extends PrimitiveValue +class Size extends PrimitiveValue implements Component { /** * vh/vw/vm(ax)/vmin/rem are absolute insofar as they don’t scale to the immediate parent (only the viewport) diff --git a/src/Value/URL.php b/src/Value/URL.php index cdb911c3..cbe2eea8 100644 --- a/src/Value/URL.php +++ b/src/Value/URL.php @@ -11,7 +11,7 @@ /** * This class represents URLs in CSS. `URL`s always output in `URL("")` notation. */ -class URL extends PrimitiveValue +class URL extends PrimitiveValue implements Component { /** * @var CSSString diff --git a/src/Value/Value.php b/src/Value/Value.php index 6be2110c..884d02d8 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 Component|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..1dc7cde4 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; @@ -24,7 +24,7 @@ abstract class ValueList extends Value /** * phpcs:ignore Generic.Files.LineLength - * @param array|RuleValueList|CSSFunction|CSSString|LineName|Size|URL|string $aComponents + * @param array|Component|string $aComponents * @param string $sSeparator * @param int $iLineNo */ @@ -49,7 +49,7 @@ public function addListComponent($mComponent) } /** - * @return array + * @return array */ public function getListComponents() { @@ -57,7 +57,7 @@ public function getListComponents() } /** - * @param array $aComponents + * @param array $aComponents * * @return void */