diff --git a/src/Elements/AbstractElement.php b/src/Elements/AbstractElement.php index 033a8b5..adbfbbc 100644 --- a/src/Elements/AbstractElement.php +++ b/src/Elements/AbstractElement.php @@ -90,12 +90,16 @@ abstract class AbstractElement implements Element 'dir' => 'auto', ]; + /** + * @param array|null $attributes + * @param array|null $childNodes + */ public function __construct(?array $attributes = [], string $content = '', ?array $childNodes = []) { $this->attributes = $this->formatAttributes( $this->defaultAttributes, $this->allowedAttributes, - $attributes, + $attributes ?? [], ); $this->content = $content; @@ -351,10 +355,16 @@ protected function widthParser($width, $options = []): array ]; } + /** + * @param array $defaultAttributes + * @param array> $allowedAttributes + * @param array $passedAttributes + * @return array + */ private function formatAttributes( array $defaultAttributes, array $allowedAttributes, - ?array $passedAttributes = [] + array $passedAttributes = [] ): array { /* * Check if the attributes are of the proper format based on the allowed attributes.