rector fixes

This commit is contained in:
2026-03-04 15:18:34 +01:00
parent 91c2251e43
commit 39a59fef51
9 changed files with 29 additions and 33 deletions

View File

@@ -17,12 +17,12 @@ use Chill\MainBundle\Audit\SubjectDisplayerInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
final class ActivityDisplayer implements SubjectDisplayerInterface
final readonly class ActivityDisplayer implements SubjectDisplayerInterface
{
public function __construct(
private readonly TranslatorInterface $translator,
private readonly ActivityRepository $activityRepository,
private readonly TranslatableStringHelperInterface $translatableStringHelper,
private TranslatorInterface $translator,
private ActivityRepository $activityRepository,
private TranslatableStringHelperInterface $translatableStringHelper,
) {}
public function supportsDisplay(Subject $subject, array $options = []): bool

View File

@@ -16,11 +16,11 @@ use Chill\MainBundle\Audit\Subject;
use Chill\MainBundle\Audit\SubjectDisplayerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
final class CalendarDisplayer implements SubjectDisplayerInterface
final readonly class CalendarDisplayer implements SubjectDisplayerInterface
{
public function __construct(
private readonly TranslatorInterface $translator,
private readonly CalendarRepository $calendarRepository,
private TranslatorInterface $translator,
private CalendarRepository $calendarRepository,
) {}
public function supportsDisplay(Subject $subject, array $options = []): bool

View File

@@ -16,11 +16,11 @@ use Chill\MainBundle\Audit\Subject;
use Chill\MainBundle\Audit\SubjectDisplayerInterface;
use Twig\Environment;
final class AccompanyingCourseDocumentSubjectDisplayer implements SubjectDisplayerInterface
final readonly class AccompanyingCourseDocumentSubjectDisplayer implements SubjectDisplayerInterface
{
public function __construct(
private readonly AccompanyingCourseDocumentRepository $repository,
private readonly Environment $twig,
private AccompanyingCourseDocumentRepository $repository,
private Environment $twig,
) {}
public function supportsDisplay(Subject $subject, array $options = []): bool

View File

@@ -21,7 +21,7 @@ class AssociatedEntityToStoredObjectRepository
/**
* @param iterable<AssociatedEntityToStoredObjectInterface> $repositories
*/
public function __construct(private iterable $repositories) {}
public function __construct(private readonly iterable $repositories) {}
public function findAssociatedEntityToStoredObject(StoredObject $storedObject): ?object
{

View File

@@ -28,12 +28,12 @@ class AuditEventDumper
public const MAX_LINES = 100_000;
public function __construct(
private StoredObjectManagerInterface $storedObjectManager,
private AuditTrailRepository $auditTrailRepository,
private TranslatorInterface $translator,
private SubjectConverterManagerInterface $converterManager,
private EntityManagerInterface $entityManager,
private UserRender $userRender,
private readonly StoredObjectManagerInterface $storedObjectManager,
private readonly AuditTrailRepository $auditTrailRepository,
private readonly TranslatorInterface $translator,
private readonly SubjectConverterManagerInterface $converterManager,
private readonly EntityManagerInterface $entityManager,
private readonly UserRender $userRender,
) {}
/**
@@ -111,9 +111,7 @@ class AuditEventDumper
$subjectsDisplay = '';
$subjects = $audit->getSubjects();
if ([] !== $subjects) {
$subjectsDisplay = implode(', ', array_map(function (array $s): string {
return $this->converterManager->display(Subject::fromArray($s), 'string');
}, $subjects));
$subjectsDisplay = implode(', ', array_map(fn (array $s): string => $this->converterManager->display(Subject::fromArray($s), 'string'), $subjects));
}
fputcsv($handle, [

View File

@@ -16,7 +16,7 @@ class ConvertSubjectException extends \LogicException
public function __construct(mixed $subject, ?\Throwable $previous = null)
{
parent::__construct(
sprintf('Could not convert object of type %s to an acceptable audit representation', is_object($subject) ? get_class($subject) : gettype($subject)),
sprintf('Could not convert object of type %s to an acceptable audit representation', get_debug_type($subject)),
previous: $previous
);
}

View File

@@ -98,13 +98,11 @@ class AuditDumpRequestHandlerTest extends TestCase
];
$this->auditEventDumper->dump(
Argument::that(function ($criteria) use ($expectedCriteria) {
return $criteria['from_date'] === $expectedCriteria['from_date']
&& $criteria['to_date'] === $expectedCriteria['to_date']
&& 1 === count($criteria['subjects'])
&& $criteria['subjects'][0]->isEqual($expectedCriteria['subjects'][0])
&& $criteria['by_users'] === $expectedCriteria['by_users'];
}),
Argument::that(fn ($criteria) => $criteria['from_date'] === $expectedCriteria['from_date']
&& $criteria['to_date'] === $expectedCriteria['to_date']
&& 1 === count($criteria['subjects'])
&& $criteria['subjects'][0]->isEqual($expectedCriteria['subjects'][0])
&& $criteria['by_users'] === $expectedCriteria['by_users']),
'fr',
$storedObject
)->shouldBeCalled();
@@ -152,7 +150,7 @@ class AuditDumpRequestHandlerTest extends TestCase
}
}
public function provideExceptions(): array
public static function provideExceptions(): array
{
return [
[new AuditDumpTooMuchLines(1000, 500)],

View File

@@ -20,9 +20,9 @@ use Twig\Environment;
class AccompanyingPeriodWorkSubjectDisplayer implements SubjectDisplayerInterface
{
public function __construct(
private AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository,
private Environment $twig,
private TranslatorInterface $translator,
private readonly AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository,
private readonly Environment $twig,
private readonly TranslatorInterface $translator,
) {}
public function supportsDisplay(Subject $subject, array $optons = []): bool

View File

@@ -20,7 +20,7 @@ use Symfony\Component\Validator\ConstraintViolationListInterface;
class RelationApiController extends ApiController
{
public function __construct(private TriggerAuditInterface $triggerAudit) {}
public function __construct(private readonly TriggerAuditInterface $triggerAudit) {}
protected function onAfterFlush(string $action, Request $request, string $_format, $entity, ConstraintViolationListInterface $errors, array $more = []): ?Response
{