type fixes

This commit is contained in:
Yuri Kuznetsov
2022-03-13 14:19:38 +02:00
parent 120d090215
commit a164c33829
6 changed files with 22 additions and 7 deletions
@@ -33,9 +33,11 @@ use Psr\Http\Message\StreamInterface;
use GuzzleHttp\Psr7\Stream;
use RuntimeException;
class ContentsString implements Contents
{
private $contents;
private string $contents;
private function __construct(string $contents)
{
@@ -46,6 +48,10 @@ class ContentsString implements Contents
{
$resource = fopen('php://temp', 'r+');
if ($resource === false) {
throw new RuntimeException("Could not open temp.");
}
fwrite($resource, $this->getString());
rewind($resource);
@@ -59,7 +59,7 @@ class DataLoaderManager
$data = Data::create();
}
/** @var class-string[] */
/** @var class-string<DataLoader>[] */
$classNameList = $this->metadata->get(['pdfDefs', $entity->getEntityType(), 'dataLoaderClassNameList']) ?? [];
foreach ($classNameList as $className) {
@@ -74,7 +74,7 @@ class DataLoaderManager
}
/**
* @param class-string $className
* @param class-string<DataLoader> $className
*/
private function createLoader(string $className): DataLoader
{
@@ -84,7 +84,7 @@ class PrinterController
private function createEntityPrinter(): EntityPrinter
{
/** @var ?class-string */
/** @var ?class-string<EntityPrinter> */
$className = $this->metadata
->get(['app', 'pdfEngines', $this->engine, 'implementationClassNameMap', 'entity']) ?? null;
@@ -97,7 +97,7 @@ class PrinterController
private function createCollectionPrinter(): CollectionPrinter
{
/** @var ?class-string */
/** @var ?class-string<CollectionPrinter> */
$className = $this->metadata
->get(['app', 'pdfEngines', $this->engine, 'implementationClassNameMap', 'collection']) ?? null;
@@ -30,6 +30,7 @@
namespace Espo\Tools\Pdf\Tcpdf;
use Espo\Core\Utils\Config;
use Espo\Core\Utils\Json;
use Espo\Core\Htmlizer\TemplateRendererFactory;
use Espo\Core\Htmlizer\TemplateRenderer;
@@ -225,7 +226,7 @@ class EntityProcessor
];
}
$paramsString = urlencode(json_encode($params));
$paramsString = urlencode(Json::encode($params));
return "<tcpdf method=\"{$function}\" params=\"{$paramsString}\" />";
}
+3 -1
View File
@@ -35,6 +35,8 @@ use Espo\Core\Utils\Util;
use TCPDF_STATIC;
use Espo\Core\Utils\Json;
class Tcpdf extends TcpdfOriginal
{
/**
@@ -64,7 +66,7 @@ class Tcpdf extends TcpdfOriginal
public function serializeTCPDFtagParameters($data) /** @phpstan-ignore-line */
{
return urlencode(json_encode($data));
return urlencode(Json::encode($data));
}
protected function unserializeTCPDFtagParameters($data) /** @phpstan-ignore-line */
@@ -36,6 +36,8 @@ use Psr\Http\Message\StreamInterface;
use GuzzleHttp\Psr7\Stream;
use RuntimeException;
class TcpdfContents implements Contents
{
private $pdf;
@@ -49,6 +51,10 @@ class TcpdfContents implements Contents
{
$resource = fopen('php://temp', 'r+');
if ($resource === false) {
throw new RuntimeException("Could not open temp.");
}
fwrite($resource, $this->getString());
rewind($resource);