Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/Elements/AbstractElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,16 @@
'dir' => 'auto',
];

/**
* @param array<string, string>|null $attributes
* @param array<int, \MadeByDenis\PhpMjmlRenderer\Node>|null $childNodes
*/
public function __construct(?array $attributes = [], string $content = '', ?array $childNodes = [])
{
$this->attributes = $this->formatAttributes(
$this->defaultAttributes,
$this->allowedAttributes,
$attributes,
$attributes ?? [],
);

$this->content = $content;
Expand All @@ -104,12 +108,12 @@

public function isEndingTag(): bool
{
return static::ENDING_TAG;

Check failure on line 111 in src/Elements/AbstractElement.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static analysis checks (8.4, false)

Method MadeByDenis\PhpMjmlRenderer\Elements\AbstractElement::isEndingTag() should return bool but returns mixed.

Check failure on line 111 in src/Elements/AbstractElement.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static analysis checks (8.3, false)

Method MadeByDenis\PhpMjmlRenderer\Elements\AbstractElement::isEndingTag() should return bool but returns mixed.
}

public function getTagName(): string
{
return static::TAG_NAME;

Check failure on line 116 in src/Elements/AbstractElement.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static analysis checks (8.4, false)

Method MadeByDenis\PhpMjmlRenderer\Elements\AbstractElement::getTagName() should return string but returns mixed.

Check failure on line 116 in src/Elements/AbstractElement.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static analysis checks (8.3, false)

Method MadeByDenis\PhpMjmlRenderer\Elements\AbstractElement::getTagName() should return string but returns mixed.
}

public function isRawElement(): bool
Expand Down Expand Up @@ -181,7 +185,7 @@

// To-do: Override the globally set attributes if we override some from the CLI or some options.

protected function getChildren(): ?array

Check failure on line 188 in src/Elements/AbstractElement.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static analysis checks (8.4, false)

Method MadeByDenis\PhpMjmlRenderer\Elements\AbstractElement::getChildren() return type has no value type specified in iterable type array.

Check failure on line 188 in src/Elements/AbstractElement.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static analysis checks (8.3, false)

Method MadeByDenis\PhpMjmlRenderer\Elements\AbstractElement::getChildren() return type has no value type specified in iterable type array.
{
return $this->children;
}
Expand Down Expand Up @@ -231,9 +235,9 @@
return trim($attrOut);
}

abstract public function getStyles(): array;

Check failure on line 238 in src/Elements/AbstractElement.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static analysis checks (8.4, false)

Method MadeByDenis\PhpMjmlRenderer\Elements\AbstractElement::getStyles() return type has no value type specified in iterable type array.

Check failure on line 238 in src/Elements/AbstractElement.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static analysis checks (8.3, false)

Method MadeByDenis\PhpMjmlRenderer\Elements\AbstractElement::getStyles() return type has no value type specified in iterable type array.

protected function styles($styles): string

Check failure on line 240 in src/Elements/AbstractElement.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static analysis checks (8.4, false)

Method MadeByDenis\PhpMjmlRenderer\Elements\AbstractElement::styles() has parameter $styles with no type specified.

Check failure on line 240 in src/Elements/AbstractElement.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static analysis checks (8.3, false)

Method MadeByDenis\PhpMjmlRenderer\Elements\AbstractElement::styles() has parameter $styles with no type specified.
{
$stylesArray = [];

Expand All @@ -247,20 +251,20 @@

$styles = '';

array_walk($stylesArray, function ($val, $key) use (&$styles) {

Check failure on line 254 in src/Elements/AbstractElement.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static analysis checks (8.4, false)

Parameter #1 $array of function array_walk expects array|object, mixed given.

Check failure on line 254 in src/Elements/AbstractElement.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static analysis checks (8.3, false)

Parameter #1 $array of function array_walk expects array|object, mixed given.
if (!empty($val)) {
if (is_array($val)) {
$val = implode(' ', $val);
}

$styles .= "$key:$val;";

Check failure on line 260 in src/Elements/AbstractElement.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static analysis checks (8.4, false)

Part $val (mixed) of encapsed string cannot be cast to string.

Check failure on line 260 in src/Elements/AbstractElement.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static analysis checks (8.4, false)

Part $key (mixed) of encapsed string cannot be cast to string.

Check failure on line 260 in src/Elements/AbstractElement.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static analysis checks (8.3, false)

Part $val (mixed) of encapsed string cannot be cast to string.

Check failure on line 260 in src/Elements/AbstractElement.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static analysis checks (8.3, false)

Part $key (mixed) of encapsed string cannot be cast to string.
}
});

return trim($styles);
}

protected function getShorthandAttrValue($attribute, $direction): int

Check failure on line 267 in src/Elements/AbstractElement.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static analysis checks (8.4, false)

Method MadeByDenis\PhpMjmlRenderer\Elements\AbstractElement::getShorthandAttrValue() has parameter $direction with no type specified.

Check failure on line 267 in src/Elements/AbstractElement.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static analysis checks (8.4, false)

Method MadeByDenis\PhpMjmlRenderer\Elements\AbstractElement::getShorthandAttrValue() has parameter $attribute with no type specified.

Check failure on line 267 in src/Elements/AbstractElement.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static analysis checks (8.3, false)

Method MadeByDenis\PhpMjmlRenderer\Elements\AbstractElement::getShorthandAttrValue() has parameter $direction with no type specified.

Check failure on line 267 in src/Elements/AbstractElement.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static analysis checks (8.3, false)

Method MadeByDenis\PhpMjmlRenderer\Elements\AbstractElement::getShorthandAttrValue() has parameter $attribute with no type specified.
{
$mjAttributeDirection = $this->getAttribute("$attribute-$direction");
$mjAttribute = $this->getAttribute($attribute);
Expand Down Expand Up @@ -351,10 +355,16 @@
];
}

/**
* @param array<string, string> $defaultAttributes
* @param array<string, array<string, string>> $allowedAttributes
* @param array<string, string> $passedAttributes
* @return array<string, string>
*/
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.
Expand Down
Loading