diff --git a/core/lib/Drupal/Core/Render/Element.php b/core/lib/Drupal/Core/Render/Element.php index dfd4eb099d36f2a052e1bd14f0455abedfb48294..75c3ab74017409c477461627a3d6f3b5df2f3b9c 100644 --- a/core/lib/Drupal/Core/Render/Element.php +++ b/core/lib/Drupal/Core/Render/Element.php @@ -24,7 +24,7 @@ class Element { * TRUE of the key is a property, FALSE otherwise. */ public static function property($key) { - return $key[0] == '#'; + return is_string($key) && $key[0] == '#'; } /** diff --git a/core/tests/Drupal/Tests/Core/Render/ElementTest.php b/core/tests/Drupal/Tests/Core/Render/ElementTest.php index a09cb3f61febfe4adbdfb7ffdd6a54619312a385..1c795c7dba0b1ce69d4c86b59c6c9981656210cc 100644 --- a/core/tests/Drupal/Tests/Core/Render/ElementTest.php +++ b/core/tests/Drupal/Tests/Core/Render/ElementTest.php @@ -19,6 +19,7 @@ public function testProperty() { $this->assertTrue(Element::property('#property')); $this->assertFalse(Element::property('property')); $this->assertFalse(Element::property('property#')); + $this->assertFalse(Element::property(0)); } /** @@ -29,13 +30,12 @@ public function testProperties() { '#property1' => 'property1', '#property2' => 'property2', 'property3' => 'property3', + 0 => [], ]; $properties = Element::properties($element); - $this->assertContains('#property1', $properties); - $this->assertContains('#property2', $properties); - $this->assertNotContains('property3', $properties); + $this->assertSame(['#property1', '#property2'], $properties); } /**