DX: apply rector rules up to php8.0

This commit is contained in:
2023-04-15 01:05:37 +02:00
parent d8870e906f
commit dde3002100
714 changed files with 2348 additions and 9263 deletions

View File

@@ -27,20 +27,8 @@ use function get_class;
abstract class AbstractElementController extends AbstractController
{
protected LoggerInterface $chillMainLogger;
protected EntityManagerInterface $em;
protected TranslatorInterface $translator;
public function __construct(
EntityManagerInterface $em,
TranslatorInterface $translator,
LoggerInterface $chillMainLogger
) {
$this->em = $em;
$this->translator = $translator;
$this->chillMainLogger = $chillMainLogger;
public function __construct(protected EntityManagerInterface $em, protected TranslatorInterface $translator, protected LoggerInterface $chillMainLogger)
{
}
/**
@@ -48,11 +36,8 @@ abstract class AbstractElementController extends AbstractController
* "{_locale}/family-members/family-members/{id}/delete",
* name="chill_family_members_family_members_delete"
* ).
*
* @param mixed $template
* @param mixed $flashMessage
*/
protected function _delete(AbstractElement $element, Request $request, $template, $flashMessage): Response
protected function _delete(AbstractElement $element, Request $request, mixed $template, mixed $flashMessage): Response
{
$this->denyAccessUnlessGranted(BudgetElementVoter::DELETE, $element, 'You are not '
. 'allowed to delete this item');
@@ -72,7 +57,7 @@ abstract class AbstractElementController extends AbstractController
if ($form->isValid()) {
$this->chillMainLogger->notice('A budget element has been removed', [
'family_element' => get_class($element),
'family_element' => $element::class,
'by_user' => $this->getUser()->getUsername(),
'family_member_id' => $element->getId(),
'amount' => $element->getAmount(),
@@ -141,12 +126,7 @@ abstract class AbstractElementController extends AbstractController
]);
}
/**
* @param mixed $template
* @param mixed $flashMessageOnSuccess
* @param mixed $entity
*/
protected function _new($entity, Request $request, $template, $flashMessageOnSuccess)
protected function _new(mixed $entity, Request $request, mixed $template, mixed $flashMessageOnSuccess)
{
/** @var AbstractElement $element */
$element = $this->createNewElement();
@@ -196,10 +176,8 @@ abstract class AbstractElementController extends AbstractController
* "{_locale}/family-members/family-members/{id}/view",
* name="chill_family_members_family_members_view"
* ).
*
* @param mixed $template
*/
protected function _view(AbstractElement $element, $template)
protected function _view(AbstractElement $element, mixed $template)
{
$this->denyAccessUnlessGranted(BudgetElementVoter::SEE, $element);

View File

@@ -31,20 +31,8 @@ use function count;
class ElementController extends AbstractController
{
private CalculatorManager $calculator;
private ResourceRepository $resourceRepository;
private ChargeRepository $chargeRepository;
public function __construct(
CalculatorManager $calculator,
ResourceRepository $resourceRepository,
ChargeRepository $chargeRepository,
) {
$this->calculator = $calculator;
$this->resourceRepository = $resourceRepository;
$this->chargeRepository = $chargeRepository;
public function __construct(private CalculatorManager $calculator, private ResourceRepository $resourceRepository, private ChargeRepository $chargeRepository)
{
}
/**

View File

@@ -27,20 +27,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class ChargeType extends AbstractType
{
protected TranslatableStringHelperInterface $translatableStringHelper;
private ChargeKindRepository $repository;
private TranslatorInterface $translator;
public function __construct(
TranslatableStringHelperInterface $translatableStringHelper,
ChargeKindRepository $repository,
TranslatorInterface $translator
) {
$this->translatableStringHelper = $translatableStringHelper;
$this->repository = $repository;
$this->translator = $translator;
public function __construct(protected TranslatableStringHelperInterface $translatableStringHelper, private ChargeKindRepository $repository, private TranslatorInterface $translator)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -26,20 +26,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class ResourceType extends AbstractType
{
protected TranslatableStringHelperInterface $translatableStringHelper;
private ResourceKindRepository $repository;
private TranslatorInterface $translator;
public function __construct(
TranslatableStringHelperInterface $translatableStringHelper,
ResourceKindRepository $repository,
TranslatorInterface $translator
) {
$this->translatableStringHelper = $translatableStringHelper;
$this->repository = $repository;
$this->translator = $translator;
public function __construct(protected TranslatableStringHelperInterface $translatableStringHelper, private ResourceKindRepository $repository, private TranslatorInterface $translator)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)

View File

@@ -17,11 +17,8 @@ use Symfony\Component\Security\Core\Security;
final class AdminMenuBuilder implements LocalMenuBuilderInterface
{
private Security $security;
public function __construct(Security $security)
public function __construct(private Security $security)
{
$this->security = $security;
}
public function buildMenu($menuId, MenuItem $menu, array $parameters)

View File

@@ -20,16 +20,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class HouseholdMenuBuilder implements LocalMenuBuilderInterface
{
protected AuthorizationCheckerInterface $authorizationChecker;
protected TranslatorInterface $translator;
public function __construct(
AuthorizationCheckerInterface $authorizationChecker,
TranslatorInterface $translator
) {
$this->authorizationChecker = $authorizationChecker;
$this->translator = $translator;
public function __construct(protected AuthorizationCheckerInterface $authorizationChecker, protected TranslatorInterface $translator)
{
}
public function buildMenu($menuId, MenuItem $menu, array $parameters)

View File

@@ -20,16 +20,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class PersonMenuBuilder implements LocalMenuBuilderInterface
{
protected AuthorizationCheckerInterface $authorizationChecker;
protected TranslatorInterface $translator;
public function __construct(
AuthorizationCheckerInterface $authorizationChecker,
TranslatorInterface $translator
) {
$this->authorizationChecker = $authorizationChecker;
$this->translator = $translator;
public function __construct(protected AuthorizationCheckerInterface $authorizationChecker, protected TranslatorInterface $translator)
{
}
public function buildMenu($menuId, MenuItem $menu, array $parameters)

View File

@@ -37,24 +37,8 @@ final class SummaryBudget implements SummaryBudgetInterface
private const QUERY_RESOURCE_BY_PERSON = 'select SUM(amount) AS sum, string_agg(comment, \'|\') AS comment, resource_id AS kind_id FROM chill_budget.resource WHERE person_id = ? AND NOW() BETWEEN startdate AND COALESCE(enddate, \'infinity\'::timestamp) GROUP BY resource_id';
private ChargeKindRepositoryInterface $chargeKindRepository;
private EntityManagerInterface $em;
private ResourceKindRepositoryInterface $resourceKindRepository;
private TranslatableStringHelperInterface $translatableStringHelper;
public function __construct(
EntityManagerInterface $em,
TranslatableStringHelperInterface $translatableStringHelper,
ResourceKindRepositoryInterface $resourceKindRepository,
ChargeKindRepositoryInterface $chargeKindRepository
) {
$this->em = $em;
$this->translatableStringHelper = $translatableStringHelper;
$this->resourceKindRepository = $resourceKindRepository;
$this->chargeKindRepository = $chargeKindRepository;
public function __construct(private EntityManagerInterface $em, private TranslatableStringHelperInterface $translatableStringHelper, private ResourceKindRepositoryInterface $resourceKindRepository, private ChargeKindRepositoryInterface $chargeKindRepository)
{
}
public function getSummaryForHousehold(?Household $household): array

View File

@@ -22,14 +22,8 @@ use Symfony\Component\Templating\EngineInterface;
*/
final class BudgetElementTypeRender implements ChillEntityRenderInterface
{
private EngineInterface $engine;
private TranslatableStringHelperInterface $translatableStringHelper;
public function __construct(TranslatableStringHelperInterface $translatableStringHelper, EngineInterface $engine)
public function __construct(private TranslatableStringHelperInterface $translatableStringHelper, private EngineInterface $engine)
{
$this->translatableStringHelper = $translatableStringHelper;
$this->engine = $engine;
}
public function renderBox($entity, array $options): string

View File

@@ -66,11 +66,11 @@ final class SummaryBudgetTest extends TestCase
$em = $this->prophesize(EntityManagerInterface::class);
$em->createNativeQuery(Argument::type('string'), Argument::type(Query\ResultSetMapping::class))
->will(static function ($args) use ($queryResources, $queryCharges) {
if (false !== strpos($args[0], 'chill_budget.resource')) {
if (str_contains($args[0], 'chill_budget.resource')) {
return $queryResources->reveal();
}
if (false !== strpos($args[0], 'chill_budget.charge')) {
if (str_contains($args[0], 'chill_budget.charge')) {
return $queryCharges->reveal();
}