Skip to content

Commit da87f65

Browse files
authored
Merge pull request #11 from dingo-d/fix/assignment-types
Fix type assignment errors in element construction
2 parents b63151b + b26b24f commit da87f65

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Elements/AbstractElement.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,16 @@ abstract class AbstractElement implements Element
9090
'dir' => 'auto',
9191
];
9292

93+
/**
94+
* @param array<string, string>|null $attributes
95+
* @param array<int, \MadeByDenis\PhpMjmlRenderer\Node>|null $childNodes
96+
*/
9397
public function __construct(?array $attributes = [], string $content = '', ?array $childNodes = [])
9498
{
9599
$this->attributes = $this->formatAttributes(
96100
$this->defaultAttributes,
97101
$this->allowedAttributes,
98-
$attributes,
102+
$attributes ?? [],
99103
);
100104

101105
$this->content = $content;
@@ -351,10 +355,16 @@ protected function widthParser($width, $options = []): array
351355
];
352356
}
353357

358+
/**
359+
* @param array<string, string> $defaultAttributes
360+
* @param array<string, array<string, string>> $allowedAttributes
361+
* @param array<string, string> $passedAttributes
362+
* @return array<string, string>
363+
*/
354364
private function formatAttributes(
355365
array $defaultAttributes,
356366
array $allowedAttributes,
357-
?array $passedAttributes = []
367+
array $passedAttributes = []
358368
): array {
359369
/*
360370
* Check if the attributes are of the proper format based on the allowed attributes.

0 commit comments

Comments
 (0)