mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-02-28 02:59:40 +00:00
Apply new rector rules regarding to PHP version to 8.4
This commit is contained in:
@@ -23,6 +23,7 @@ class AdminDocGeneratorTemplateController extends CRUDController
|
||||
{
|
||||
public function __construct(private readonly ContextManager $contextManager) {}
|
||||
|
||||
#[\Override]
|
||||
public function generateTemplateParameter(string $action, $entity, Request $request, array $defaultTemplateParameters = [])
|
||||
{
|
||||
switch ($action) {
|
||||
@@ -48,6 +49,7 @@ class AdminDocGeneratorTemplateController extends CRUDController
|
||||
}
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function new(Request $request): Response
|
||||
{
|
||||
if (!$request->query->has('context')) {
|
||||
@@ -67,6 +69,7 @@ class AdminDocGeneratorTemplateController extends CRUDController
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
protected function createEntity(string $action, Request $request): object
|
||||
{
|
||||
/** @var DocGeneratorTemplate $entity */
|
||||
@@ -84,6 +87,7 @@ class AdminDocGeneratorTemplateController extends CRUDController
|
||||
*
|
||||
* @return QueryBuilder|mixed
|
||||
*/
|
||||
#[\Override]
|
||||
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator): QueryBuilder
|
||||
{
|
||||
return $query->addSelect('JSON_EXTRACT(e.name, :lang) AS HIDDEN name_lang')
|
||||
|
||||
@@ -223,7 +223,7 @@ final class DocGeneratorTemplateController extends AbstractController
|
||||
: [];
|
||||
|
||||
// we prepare the object to store the document
|
||||
$storedObject = (new StoredObject())
|
||||
$storedObject = new StoredObject()
|
||||
->setStatus(StoredObject::STATUS_PENDING)
|
||||
;
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ class LoadDocGeneratorTemplate extends AbstractFixture
|
||||
|
||||
$manager->persist($newStoredObj);
|
||||
|
||||
$newTemplate = (new DocGeneratorTemplate())
|
||||
$newTemplate = new DocGeneratorTemplate()
|
||||
->setName($template['name'])
|
||||
->setDescription($template['desc'])
|
||||
->setFile($newStoredObj)
|
||||
|
||||
@@ -62,13 +62,7 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
|
||||
$attributes = \array_filter(
|
||||
$metadata->getAttributesMetadata(),
|
||||
static function (AttributeMetadataInterface $a) use ($expectedGroups) {
|
||||
foreach ($a->getGroups() as $g) {
|
||||
if (\in_array($g, $expectedGroups, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return array_any($a->getGroups(), fn($g) => \in_array($g, $expectedGroups, true));
|
||||
}
|
||||
);
|
||||
|
||||
@@ -153,15 +147,7 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
|
||||
// add a discriminator
|
||||
if (null !== $discriminator = $metadata->getClassDiscriminatorMapping()) {
|
||||
$typeKey = $discriminator->getTypeProperty();
|
||||
$typeValue = null;
|
||||
|
||||
foreach ($discriminator->getTypesMapping() as $type => $typeClass) {
|
||||
if ($typeClass === $context['docgen:expects']) {
|
||||
$typeValue = $type;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
$typeValue = array_find_key($discriminator->getTypesMapping(), fn($typeClass) => $typeClass === $context['docgen:expects']);
|
||||
|
||||
if (null === $typeValue) {
|
||||
$typeKey = null;
|
||||
|
||||
@@ -26,7 +26,7 @@ use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class Generator implements GeneratorInterface
|
||||
{
|
||||
private const LOG_PREFIX = '[docgen generator] ';
|
||||
private const string LOG_PREFIX = '[docgen generator] ';
|
||||
|
||||
public function __construct(
|
||||
private readonly ContextManagerInterface $contextManager,
|
||||
|
||||
@@ -30,7 +30,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
*/
|
||||
final readonly class OnGenerationFails implements EventSubscriberInterface
|
||||
{
|
||||
public const LOG_PREFIX = '[docgen failed] ';
|
||||
public const string LOG_PREFIX = '[docgen failed] ';
|
||||
|
||||
public function __construct(
|
||||
private DocGeneratorTemplateRepositoryInterface $docGeneratorTemplateRepository,
|
||||
@@ -118,7 +118,7 @@ final readonly class OnGenerationFails implements EventSubscriberInterface
|
||||
return;
|
||||
}
|
||||
|
||||
$email = (new TemplatedEmail())
|
||||
$email = new TemplatedEmail()
|
||||
->to($message->getSendResultToEmail())
|
||||
->subject($this->translator->trans('docgen.failure_email.The generation of a document failed'))
|
||||
->textTemplate('@ChillDocGenerator/Email/on_generation_failed_email.txt.twig')
|
||||
|
||||
@@ -32,8 +32,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
#[\Symfony\Component\Messenger\Attribute\AsMessageHandler]
|
||||
class RequestGenerationHandler
|
||||
{
|
||||
final public const AUTHORIZED_TRIALS = 5;
|
||||
private const LOG_PREFIX = '[docgen message handler] ';
|
||||
final public const int AUTHORIZED_TRIALS = 5;
|
||||
private const string LOG_PREFIX = '[docgen message handler] ';
|
||||
|
||||
public function __construct(
|
||||
private readonly DocGeneratorTemplateRepositoryInterface $docGeneratorTemplateRepository,
|
||||
@@ -115,7 +115,7 @@ class RequestGenerationHandler
|
||||
$this->logger->info(self::LOG_PREFIX.'Request generation finished', [
|
||||
'template_id' => $message->getTemplateId(),
|
||||
'destination_stored_object' => $message->getDestinationStoredObjectId(),
|
||||
'duration_int' => (new \DateTimeImmutable('now'))->getTimestamp() - $message->getCreatedAt()->getTimestamp(),
|
||||
'duration_int' => new \DateTimeImmutable('now')->getTimestamp() - $message->getCreatedAt()->getTimestamp(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ class RequestGenerationHandler
|
||||
$contentType = $destinationStoredObject->getType();
|
||||
|
||||
// Create the email with the document as an attachment
|
||||
$email = (new TemplatedEmail())
|
||||
$email = new TemplatedEmail()
|
||||
->to($message->getSendResultToEmail())
|
||||
->textTemplate('@ChillDocGenerator/Email/send_data_dump_to_admin.txt.twig')
|
||||
->context([
|
||||
|
||||
@@ -126,7 +126,6 @@ class RequestGenerationHandlerTest extends TestCase
|
||||
{
|
||||
$reflection = new \ReflectionClass($object);
|
||||
$property = $reflection->getProperty($propertyName);
|
||||
$property->setAccessible(true);
|
||||
$property->setValue($object, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,12 +19,14 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
*/
|
||||
final class Version20210805162522 extends AbstractMigration
|
||||
{
|
||||
#[\Override]
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP SEQUENCE chill_docgen_template_id_seq CASCADE');
|
||||
$this->addSql('DROP TABLE chill_docgen_template');
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Creation of table for storing DocGenTemplate';
|
||||
|
||||
@@ -19,6 +19,7 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
*/
|
||||
final class Version20210812214310 extends AbstractMigration
|
||||
{
|
||||
#[\Override]
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_docgen_template DROP entities');
|
||||
@@ -26,6 +27,7 @@ final class Version20210812214310 extends AbstractMigration
|
||||
$this->addSql('COMMENT ON COLUMN chill_docgen_template.name IS NULL');
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add entities and context fields to DocGenTemplate';
|
||||
|
||||
@@ -19,6 +19,7 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
*/
|
||||
final class Version20211103111010 extends AbstractMigration
|
||||
{
|
||||
#[\Override]
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_docgen_template DROP CONSTRAINT FK_49A347E893CB796C');
|
||||
@@ -29,6 +30,7 @@ final class Version20211103111010 extends AbstractMigration
|
||||
$this->addSql('ALTER TABLE chill_docgen_template ALTER context DROP NOT NULL');
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Using DocStore objects inside the DocGenTemplate';
|
||||
|
||||
@@ -16,11 +16,13 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20211119173556 extends AbstractMigration
|
||||
{
|
||||
#[\Override]
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->throwIrreversibleMigrationException();
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'remove comment on deprecated json_array type';
|
||||
|
||||
@@ -16,6 +16,7 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20211201191757 extends AbstractMigration
|
||||
{
|
||||
#[\Override]
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_docgen_template DROP active');
|
||||
@@ -25,6 +26,7 @@ final class Version20211201191757 extends AbstractMigration
|
||||
$this->addSql('COMMENT ON COLUMN chill_docgen_template.entities IS \'(DC2Type:simple_array)\'');
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add options, active and link to entity in docgen_template';
|
||||
|
||||
@@ -16,6 +16,7 @@ use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20230214192558 extends AbstractMigration
|
||||
{
|
||||
#[\Override]
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add status, template_id and fix defaults on chill_doc.stored_object';
|
||||
@@ -38,6 +39,7 @@ final class Version20230214192558 extends AbstractMigration
|
||||
$this->addSql('CREATE INDEX IDX_49604E363174800F ON chill_doc.stored_object (createdBy_id)');
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_doc.stored_object DROP CONSTRAINT FK_49604E365DA0FB8');
|
||||
|
||||
@@ -42,8 +42,8 @@ class GeneratorTest extends TestCase
|
||||
{
|
||||
$templateStoredObject = new StoredObject();
|
||||
$templateStoredObject->registerVersion(type: 'application/test');
|
||||
$template = (new DocGeneratorTemplate())->setFile($templateStoredObject);
|
||||
$destinationStoredObject = (new StoredObject())->setStatus(StoredObject::STATUS_PENDING);
|
||||
$template = new DocGeneratorTemplate()->setFile($templateStoredObject);
|
||||
$destinationStoredObject = new StoredObject()->setStatus(StoredObject::STATUS_PENDING);
|
||||
$reflection = new \ReflectionClass($destinationStoredObject);
|
||||
$reflection->getProperty('id')->setValue($destinationStoredObject, 1);
|
||||
$entity = new class () {};
|
||||
@@ -117,8 +117,8 @@ class GeneratorTest extends TestCase
|
||||
|
||||
$templateStoredObject = new StoredObject();
|
||||
$templateStoredObject->registerVersion(type: 'application/test');
|
||||
$template = (new DocGeneratorTemplate())->setFile($templateStoredObject);
|
||||
$destinationStoredObject = (new StoredObject())->setStatus(StoredObject::STATUS_READY);
|
||||
$template = new DocGeneratorTemplate()->setFile($templateStoredObject);
|
||||
$destinationStoredObject = new StoredObject()->setStatus(StoredObject::STATUS_READY);
|
||||
|
||||
$generator->generateDocFromTemplate(
|
||||
$template,
|
||||
@@ -135,8 +135,8 @@ class GeneratorTest extends TestCase
|
||||
|
||||
$templateStoredObject = new StoredObject();
|
||||
$templateStoredObject->registerVersion(type: 'application/test');
|
||||
$template = (new DocGeneratorTemplate())->setFile($templateStoredObject);
|
||||
$destinationStoredObject = (new StoredObject())->setStatus(StoredObject::STATUS_PENDING);
|
||||
$template = new DocGeneratorTemplate()->setFile($templateStoredObject);
|
||||
$destinationStoredObject = new StoredObject()->setStatus(StoredObject::STATUS_PENDING);
|
||||
$reflection = new \ReflectionClass($destinationStoredObject);
|
||||
$reflection->getProperty('id')->setValue($destinationStoredObject, 1);
|
||||
|
||||
|
||||
@@ -62,19 +62,16 @@ class OnAfterMessageHandledClearStoredObjectCacheTest extends TestCase
|
||||
|
||||
$class = new \ReflectionClass($creator);
|
||||
$property = $class->getProperty('id');
|
||||
$property->setAccessible(true);
|
||||
$property->setValue($creator, 1);
|
||||
|
||||
$template ??= new DocGeneratorTemplate();
|
||||
$class = new \ReflectionClass($template);
|
||||
$property = $class->getProperty('id');
|
||||
$property->setAccessible(true);
|
||||
$property->setValue($template, 2);
|
||||
|
||||
$destinationStoredObject = new StoredObject();
|
||||
$class = new \ReflectionClass($destinationStoredObject);
|
||||
$property = $class->getProperty('id');
|
||||
$property->setAccessible(true);
|
||||
$property->setValue($destinationStoredObject, 3);
|
||||
|
||||
return new RequestGenerationMessage(
|
||||
|
||||
@@ -115,14 +115,7 @@ class OnGenerationFailsTest extends TestCase
|
||||
if (!$arg instanceof Email) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($arg->getTo() as $to) {
|
||||
if ('test@test.com' === $to->getAddress()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return array_any($arg->getTo(), fn($to) => 'test@test.com' === $to->getAddress());
|
||||
}),
|
||||
Argument::any()
|
||||
)
|
||||
@@ -155,19 +148,16 @@ class OnGenerationFailsTest extends TestCase
|
||||
if (null === $creator->getId()) {
|
||||
$class = new \ReflectionClass($creator);
|
||||
$property = $class->getProperty('id');
|
||||
$property->setAccessible(true);
|
||||
$property->setValue($creator, 1);
|
||||
}
|
||||
|
||||
$template ??= new DocGeneratorTemplate();
|
||||
$class = new \ReflectionClass($template);
|
||||
$property = $class->getProperty('id');
|
||||
$property->setAccessible(true);
|
||||
$property->setValue($template, 2);
|
||||
|
||||
$class = new \ReflectionClass($destinationStoredObject);
|
||||
$property = $class->getProperty('id');
|
||||
$property->setAccessible(true);
|
||||
$property->setValue($destinationStoredObject, 3);
|
||||
|
||||
return new RequestGenerationMessage(
|
||||
|
||||
Reference in New Issue
Block a user