type fixes

This commit is contained in:
Yuri Kuznetsov
2022-03-24 12:21:14 +02:00
parent eaed64fe6a
commit ceddfd8486
4 changed files with 22 additions and 13 deletions

View File

@@ -47,9 +47,13 @@ class TableTag implements Helper
$attributesPart .= " width=\"{$width}\"";
}
$function = $data->getFunction();
$content = $function !== null ? $function() : '';
return Result::createSafeString(
"<table border=\"{$border}\" cellpadding=\"{$cellpadding}\" {$attributesPart}>" .
$data->getFunction()() .
$content .
"</table>"
);
}

View File

@@ -51,10 +51,12 @@ class TdTag implements Helper
$attributesPart .= " width=\"{$width}\"";
}
$function = $data->getFunction();
$content = $function !== null ? $function() : '';
return Result::createSafeString(
"<td>" .
$data->getFunction()() .
"</td>"
"<td>" . $content . "</td>"
);
}
}

View File

@@ -37,10 +37,12 @@ class TrTag implements Helper
{
public function render(Data $data): Result
{
$function = $data->getFunction();
$content = $function !== null ? $function() : '';
return Result::createSafeString(
"<tr>" .
$data->getFunction()() .
"</tr>"
"<tr>" . $content . "</tr>"
);
}
}

View File

@@ -30,6 +30,7 @@
namespace Espo\Core\Htmlizer\Helper;
use stdClass;
use Closure;
class Data
{
@@ -55,12 +56,12 @@ class Data
private $rootContext;
/**
* @var ?callable
* @var ?Closure
*/
private $func = null;
/**
* @var ?callable
* @var ?Closure
*/
private $inverseFunc = null;
@@ -77,8 +78,8 @@ class Data
array $context,
array $rootContext,
int $blockParams,
?callable $func,
?callable $inverseFunc
?Closure $func,
?Closure $inverseFunc
) {
$this->name = $name;
$this->argumentList = $argumentList;
@@ -137,12 +138,12 @@ class Data
return $this->options->$name ?? null;
}
public function getFunction(): ?callable
public function getFunction(): ?Closure
{
return $this->func;
}
public function getInverseFunction(): ?callable
public function getInverseFunction(): ?Closure
{
return $this->inverseFunc;
}