]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blobdiff - vendor/wikimedia/css-sanitizer/src/Objects/ComponentValueList.php
MediaWiki 1.30.2
[autoinstalls/mediawiki.git] / vendor / wikimedia / css-sanitizer / src / Objects / ComponentValueList.php
diff --git a/vendor/wikimedia/css-sanitizer/src/Objects/ComponentValueList.php b/vendor/wikimedia/css-sanitizer/src/Objects/ComponentValueList.php
new file mode 100644 (file)
index 0000000..b149eaf
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+/**
+ * @file
+ * @license https://opensource.org/licenses/Apache-2.0 Apache-2.0
+ */
+
+namespace Wikimedia\CSS\Objects;
+
+/**
+ * Represent a list of CSS declarations
+ */
+class ComponentValueList extends CSSObjectList {
+       protected static $objectType = ComponentValue::class;
+
+       protected static function testObjects( array $objects ) {
+               foreach ( $objects as $object ) {
+                       $type = $object instanceof Token ? $object->type() : 'n/a';
+                       switch ( $type ) {
+                               case Token::T_FUNCTION:
+                               case Token::T_LEFT_BRACKET:
+                               case Token::T_LEFT_PAREN:
+                               case Token::T_LEFT_BRACE:
+                                       throw new \InvalidArgumentException(
+                                               static::class . " may not contain tokens of type \"$type\"."
+                                       );
+                       }
+               }
+       }
+
+       // Much simpler
+       public function toComponentValueArray() {
+               return $this->objects;
+       }
+}