diff --git a/core/lib/Drupal/Component/Attribute/Attribute.php b/core/lib/Drupal/Component/Attribute/Attribute.php index d83c4ac..66026cc 100644 --- a/core/lib/Drupal/Component/Attribute/Attribute.php +++ b/core/lib/Drupal/Component/Attribute/Attribute.php @@ -11,8 +11,8 @@ * To use, optionally pass in an associative array of defined attributes, or * add attributes using array syntax. For example: * @code - * $attributes = new Attribute(array('id' => 'socks')); - * $attributes['class'] = array('black-cat', 'white-cat'); + * $attributes = new Attribute(['id' => 'socks']); + * $attributes['class'] = ['black-cat', 'white-cat']; * $attributes['class'][] = 'black-white-cat'; * echo ''; * // Produces @@ -20,8 +20,8 @@ * * $attributes always prints out all the attributes. For example: * @code - * $attributes = new Attribute(array('id' => 'socks')); - * $attributes['class'] = array('black-cat', 'white-cat'); + * $attributes = new Attribute(['id' => 'socks']); + * $attributes['class'] = ['black-cat', 'white-cat']; * $attributes['class'][] = 'black-white-cat'; * echo ''; * // Produces @@ -43,7 +43,7 @@ * @code * $path = 'javascript:alert("xss");'; * $path = UrlHelper::stripDangerousProtocols($path); - * $attributes = new Attribute(array('href' => $path)); + * $attributes = new Attribute(['href' => $path]); * echo ''; * // Produces * @endcode @@ -69,7 +69,7 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface { * * @var \Drupal\Component\Attribute\AttributeValueBase[] */ - protected $storage = array(); + protected $storage = []; /** * Constructs a \Drupal\Component\Attribute\Attribute object. @@ -77,7 +77,7 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface { * @param array $attributes * An associative array of key-value pairs to be converted to attributes. */ - public function __construct($attributes = array()) { + public function __construct($attributes = []) { foreach ($attributes as $name => $value) { $this->offsetSet($name, $value); } @@ -170,7 +170,7 @@ public function offsetExists($name) { public function addClass() { $args = func_get_args(); if ($args) { - $classes = array(); + $classes = []; foreach ($args as $arg) { // Merge the values passed in from the classes array. // The argument is cast to an array to support comma separated single @@ -245,7 +245,7 @@ public function removeClass() { // With no class attribute, there is no need to remove. if (isset($this->storage['class']) && $this->storage['class'] instanceof AttributeArray) { $args = func_get_args(); - $classes = array(); + $classes = []; foreach ($args as $arg) { // Merge the values passed in from the classes array. // The argument is cast to an array to support comma separated single diff --git a/core/lib/Drupal/Component/Attribute/AttributeArray.php b/core/lib/Drupal/Component/Attribute/AttributeArray.php index ad0d5d6..a94f381 100644 --- a/core/lib/Drupal/Component/Attribute/AttributeArray.php +++ b/core/lib/Drupal/Component/Attribute/AttributeArray.php @@ -11,7 +11,7 @@ * Correct: * @code * $attributes = new Attribute(); - * $attributes['class'] = array(); + * $attributes['class'] = []; * $attributes['class'][] = 'cat'; * @endcode * Incorrect: diff --git a/core/lib/Drupal/Component/Attribute/AttributeString.php b/core/lib/Drupal/Component/Attribute/AttributeString.php index fc059f6..aeaba0b 100644 --- a/core/lib/Drupal/Component/Attribute/AttributeString.php +++ b/core/lib/Drupal/Component/Attribute/AttributeString.php @@ -10,7 +10,7 @@ * To use with the Attribute class, set the key to be the attribute name * and the value the attribute value. * @code - * $attributes = new Attribute(array()); + * $attributes = new Attribute([]); * $attributes['id'] = 'socks'; * $attributes['style'] = 'background-color:white'; * echo ''; diff --git a/core/lib/Drupal/Component/Attribute/composer.json b/core/lib/Drupal/Component/Attribute/composer.json index 37f594e..6949ece 100644 --- a/core/lib/Drupal/Component/Attribute/composer.json +++ b/core/lib/Drupal/Component/Attribute/composer.json @@ -6,8 +6,8 @@ "license": "GPL-2.0+", "require": { "php": ">=5.5.9", - "drupal/core-render": "~8.2", - "drupal/core-utility": "~8.2" + "drupal/core-render": "^8.6", + "drupal/core-utility": "^8.6" }, "autoload": { "psr-4": { diff --git a/core/lib/Drupal/Core/Template/Attribute.php b/core/lib/Drupal/Core/Template/Attribute.php index f2b167b..2a45f2d 100644 --- a/core/lib/Drupal/Core/Template/Attribute.php +++ b/core/lib/Drupal/Core/Template/Attribute.php @@ -7,7 +7,7 @@ /** * Collects, sanitizes, and renders HTML attributes. * - * @deprecated in Drupal 8.2.0, will be removed before Drupal 9.0.0. + * @deprecated in Drupal 8.6.0, will be removed before Drupal 9.0.0. * Use \Drupal\Component\Attribute\Attribute. */ class Attribute extends ComponentAttribute {} diff --git a/core/lib/Drupal/Core/Template/AttributeArray.php b/core/lib/Drupal/Core/Template/AttributeArray.php index 68465d2..77ac311 100644 --- a/core/lib/Drupal/Core/Template/AttributeArray.php +++ b/core/lib/Drupal/Core/Template/AttributeArray.php @@ -7,7 +7,7 @@ /** * A class that defines a type of Attribute that can be added to as an array. * - * @deprecated in Drupal 8.2.0, will be removed before Drupal 9.0.0. + * @deprecated in Drupal 8.6.0, will be removed before Drupal 9.0.0. * Use \Drupal\Component\Attribute\AttributeArray. */ class AttributeArray extends ComponentAttributeArray {} diff --git a/core/lib/Drupal/Core/Template/AttributeBoolean.php b/core/lib/Drupal/Core/Template/AttributeBoolean.php index f20aae0..2009155 100644 --- a/core/lib/Drupal/Core/Template/AttributeBoolean.php +++ b/core/lib/Drupal/Core/Template/AttributeBoolean.php @@ -7,7 +7,7 @@ /** * A class that defines a type of boolean HTML attribute. * - * @deprecated in Drupal 8.2.0, will be removed before Drupal 9.0.0. + * @deprecated in Drupal 8.6.0, will be removed before Drupal 9.0.0. * Use \Drupal\Component\Attribute\AttributeBoolean. */ class AttributeBoolean extends ComponentAttributeBoolean {} diff --git a/core/lib/Drupal/Core/Template/AttributeString.php b/core/lib/Drupal/Core/Template/AttributeString.php index e2a34f2..961438f 100644 --- a/core/lib/Drupal/Core/Template/AttributeString.php +++ b/core/lib/Drupal/Core/Template/AttributeString.php @@ -7,7 +7,7 @@ /** * A class that represents most standard HTML attributes. * - * @deprecated in Drupal 8.2.0, will be removed before Drupal 9.0.0. + * @deprecated in Drupal 8.6.0, will be removed before Drupal 9.0.0. * Use \Drupal\Component\Attribute\AttributeString. */ class AttributeString extends ComponentAttributeString {} diff --git a/core/lib/Drupal/Core/Template/AttributeValueBase.php b/core/lib/Drupal/Core/Template/AttributeValueBase.php index 890a328..03959d8 100644 --- a/core/lib/Drupal/Core/Template/AttributeValueBase.php +++ b/core/lib/Drupal/Core/Template/AttributeValueBase.php @@ -7,7 +7,7 @@ /** * Defines the base class for an attribute type. * - * @deprecated in Drupal 8.2.0, will be removed before Drupal 9.0.0. + * @deprecated in Drupal 8.6.0, will be removed before Drupal 9.0.0. * Use \Drupal\Component\Attribute\AttributeValueBase. */ abstract class AttributeValueBase extends ComponentAttributeValueBase {} diff --git a/core/tests/Drupal/Tests/Component/Attribute/AttributeTest.php b/core/tests/Drupal/Tests/Component/Attribute/AttributeTest.php index c0dd76c..8ae35af 100644 --- a/core/tests/Drupal/Tests/Component/Attribute/AttributeTest.php +++ b/core/tests/Drupal/Tests/Component/Attribute/AttributeTest.php @@ -1,7 +1,6 @@