apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -32,19 +32,22 @@ class Generator implements GeneratorInterface
/**
* @template T of File|null
* @template B of bool
* @param B $isTest
*
* @param B $isTest
* @param (B is true ? T : null) $testFile
*
* @psalm-return (B is true ? string : null)
*
* @throws \Symfony\Component\Serializer\Exception\ExceptionInterface|\Throwable
*/
public function generateDocFromTemplate(
DocGeneratorTemplate $template,
int $entityId,
array $contextGenerationDataNormalized,
?StoredObject $destinationStoredObject = null,
bool $isTest = false,
?File $testFile = null,
?User $creator = null
int $entityId,
array $contextGenerationDataNormalized,
StoredObject $destinationStoredObject = null,
bool $isTest = false,
File $testFile = null,
User $creator = null
): ?string {
if ($destinationStoredObject instanceof StoredObject && StoredObject::STATUS_PENDING !== $destinationStoredObject->getStatus()) {
$this->logger->info(self::LOG_PREFIX.'Aborting generation of an already generated document');
@@ -53,7 +56,7 @@ class Generator implements GeneratorInterface
$this->logger->info(self::LOG_PREFIX.'Starting generation of a document', [
'entity_id' => $entityId,
'destination_stored_object' => $destinationStoredObject === null ? null : $destinationStoredObject->getId()
'destination_stored_object' => null === $destinationStoredObject ? null : $destinationStoredObject->getId(),
]);
$context = $this->contextManager->getContextByDocGeneratorTemplate($template);
@@ -107,12 +110,13 @@ class Generator implements GeneratorInterface
$this->logger->info(self::LOG_PREFIX.'Finished generation of a document', [
'is_test' => true,
'entity_id' => $entityId,
'destination_stored_object' => $destinationStoredObject === null ? null : $destinationStoredObject->getId()
'destination_stored_object' => null === $destinationStoredObject ? null : $destinationStoredObject->getId(),
]);
return $generatedResource;
}
/** @var StoredObject $destinationStoredObject */
/* @var StoredObject $destinationStoredObject */
$destinationStoredObject
->setType($template->getFile()->getType())
->setFilename(sprintf('%s_odt', uniqid('doc_', true)))

View File

@@ -11,15 +11,12 @@ declare(strict_types=1);
namespace Chill\DocGeneratorBundle\Service\Generator;
use RuntimeException;
use Throwable;
class GeneratorException extends RuntimeException
class GeneratorException extends \RuntimeException
{
/**
* @param string[] $errors
*/
public function __construct(private readonly array $errors = [], ?Throwable $previous = null)
public function __construct(private readonly array $errors = [], \Throwable $previous = null)
{
parent::__construct(
'Could not generate the document',

View File

@@ -21,18 +21,21 @@ interface GeneratorInterface
/**
* @template T of File|null
* @template B of bool
* @param B $isTest
*
* @param B $isTest
* @param (B is true ? T : null) $testFile
*
* @psalm-return (B is true ? string : null)
*
* @throws \Symfony\Component\Serializer\Exception\ExceptionInterface|\Throwable
*/
public function generateDocFromTemplate(
DocGeneratorTemplate $template,
int $entityId,
array $contextGenerationDataNormalized,
?StoredObject $destinationStoredObject = null,
bool $isTest = false,
?File $testFile = null,
?User $creator = null
int $entityId,
array $contextGenerationDataNormalized,
StoredObject $destinationStoredObject = null,
bool $isTest = false,
File $testFile = null,
User $creator = null
): ?string;
}

View File

@@ -11,9 +11,7 @@ declare(strict_types=1);
namespace Chill\DocGeneratorBundle\Service\Generator;
use RuntimeException;
class ObjectReadyException extends RuntimeException
class ObjectReadyException extends \RuntimeException
{
public function __construct()
{

View File

@@ -11,11 +11,9 @@ declare(strict_types=1);
namespace Chill\DocGeneratorBundle\Service\Generator;
use RuntimeException;
class RelatedEntityNotFoundException extends RuntimeException
class RelatedEntityNotFoundException extends \RuntimeException
{
public function __construct(string $relatedEntityClass, int $relatedEntityId, ?\Throwable $previous = null)
public function __construct(string $relatedEntityClass, int $relatedEntityId, \Throwable $previous = null)
{
parent::__construct(
sprintf('Related entity not found: %s, %s', $relatedEntityClass, $relatedEntityId),