Apply rector rules + fix CS

This commit is contained in:
2023-08-30 14:55:26 +02:00
parent d01172274d
commit 1c0fd57913
26 changed files with 50 additions and 76 deletions

View File

@@ -42,9 +42,8 @@ class PersonAddressController extends AbstractController
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/address/create", name="chill_person_address_create", methods={"POST"})
* @param mixed $person_id
*/
public function createAction($person_id, Request $request)
public function createAction(mixed $person_id, Request $request)
{
$person = $this->getDoctrine()->getManager()
->getRepository(\Chill\PersonBundle\Entity\Person::class)
@@ -101,10 +100,8 @@ class PersonAddressController extends AbstractController
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/address/{address_id}/edit", name="chill_person_address_edit")
* @param mixed $person_id
* @param mixed $address_id
*/
public function editAction($person_id, $address_id)
public function editAction(mixed $person_id, mixed $address_id)
{
$person = $this->getDoctrine()->getManager()
->getRepository(\Chill\PersonBundle\Entity\Person::class)
@@ -134,9 +131,8 @@ class PersonAddressController extends AbstractController
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/address/list", name="chill_person_address_list")
* @param mixed $person_id
*/
public function listAction($person_id)
public function listAction(mixed $person_id)
{
$person = $this->getDoctrine()->getManager()
->getRepository(\Chill\PersonBundle\Entity\Person::class)
@@ -160,9 +156,8 @@ class PersonAddressController extends AbstractController
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/address/new", name="chill_person_address_new")
* @param mixed $person_id
*/
public function newAction($person_id)
public function newAction(mixed $person_id)
{
$person = $this->getDoctrine()->getManager()
->getRepository(\Chill\PersonBundle\Entity\Person::class)
@@ -191,10 +186,8 @@ class PersonAddressController extends AbstractController
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/address/{address_id}/update", name="chill_person_address_update")
* @param mixed $person_id
* @param mixed $address_id
*/
public function updateAction($person_id, $address_id, Request $request)
public function updateAction(mixed $person_id, mixed $address_id, Request $request)
{
$person = $this->getDoctrine()->getManager()
->getRepository(\Chill\PersonBundle\Entity\Person::class)

View File

@@ -40,10 +40,8 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person1_id}/duplicate/{person2_id}/confirm", name="chill_person_duplicate_confirm")
* @param mixed $person1_id
* @param mixed $person2_id
*/
public function confirmAction($person1_id, $person2_id, Request $request)
public function confirmAction(mixed $person1_id, mixed $person2_id, Request $request)
{
if ($person1_id === $person2_id) {
throw new InvalidArgumentException('Can not merge same person');
@@ -106,9 +104,8 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/find-manually", name="chill_person_find_manually_duplicate")
* @param mixed $person_id
*/
public function findManuallyDuplicateAction($person_id, Request $request)
public function findManuallyDuplicateAction(mixed $person_id, Request $request)
{
$person = $this->_getPerson($person_id);
@@ -160,10 +157,8 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person1_id}/duplicate/{person2_id}/not-duplicate", name="chill_person_duplicate_not_duplicate")
* @param mixed $person1_id
* @param mixed $person2_id
*/
public function notDuplicateAction($person1_id, $person2_id)
public function notDuplicateAction(mixed $person1_id, mixed $person2_id)
{
[$person1, $person2] = $this->_getPersonsByPriority($person1_id, $person2_id);
@@ -191,10 +186,8 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person1_id}/duplicate/{person2_id}/remove-not-duplicate", name="chill_person_remove_duplicate_not_duplicate")
* @param mixed $person1_id
* @param mixed $person2_id
*/
public function removeNotDuplicateAction($person1_id, $person2_id)
public function removeNotDuplicateAction(mixed $person1_id, mixed $person2_id)
{
[$person1, $person2] = $this->_getPersonsByPriority($person1_id, $person2_id);
@@ -217,9 +210,8 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/duplicate/view", name="chill_person_duplicate_view")
* @param mixed $person_id
*/
public function viewAction($person_id, PersonNotDuplicateRepository $personNotDuplicateRepository)
public function viewAction(mixed $person_id, PersonNotDuplicateRepository $personNotDuplicateRepository)
{
$person = $this->_getPerson($person_id);

View File

@@ -31,10 +31,8 @@ final class PersonResourceController extends AbstractController
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/resources/{resource_id}/delete", name="chill_person_resource_delete")
* @param mixed $person_id
* @param mixed $resource_id
*/
public function deleteAction(Request $request, $person_id, $resource_id): Response
public function deleteAction(Request $request, mixed $person_id, mixed $resource_id): Response
{
$personOwner = $this->personRepository->find($person_id);
$resource = $this->personResourceRepository->find($resource_id);
@@ -82,10 +80,8 @@ final class PersonResourceController extends AbstractController
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/resources/{resource_id}/edit", name="chill_person_resource_edit")
* @param mixed $resource_id
* @param mixed $person_id
*/
public function editAction(Request $request, $resource_id, $person_id): Response
public function editAction(Request $request, mixed $resource_id, mixed $person_id): Response
{
$resource = $this->personResourceRepository->find($resource_id);
$personOwner = $this->personRepository->find($person_id);
@@ -121,9 +117,8 @@ final class PersonResourceController extends AbstractController
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/resources/list", name="chill_person_resource_list")
* @param mixed $person_id
*/
public function listAction(Request $request, $person_id)
public function listAction(Request $request, mixed $person_id)
{
$personOwner = $this->personRepository->find($person_id);
$this->denyAccessUnlessGranted(PersonVoter::SEE, $personOwner);
@@ -142,9 +137,8 @@ final class PersonResourceController extends AbstractController
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/resources/new", name="chill_person_resource_new")
* @param mixed $person_id
*/
public function newAction(Request $request, $person_id)
public function newAction(Request $request, mixed $person_id)
{
$personOwner = $this->personRepository->find($person_id);
$personResource = new PersonResource();

View File

@@ -28,9 +28,8 @@ class TimelinePersonController extends AbstractController
/**
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/timeline", name="chill_person_timeline")
* @param mixed $person_id
*/
public function personAction(Request $request, $person_id)
public function personAction(Request $request, mixed $person_id)
{
$person = $this->getDoctrine()
->getRepository(Person::class)

View File

@@ -320,7 +320,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
return $this->customFieldProvider
->getCustomFieldByType($cf->getType())
->render(json_decode($value, true, 512, JSON_THROW_ON_ERROR), $cf, 'csv');
->render(json_decode((string) $value, true, 512, JSON_THROW_ON_ERROR), $cf, 'csv');
};
if ($cfType instanceof CustomFieldChoice && $cfType->isMultiple($cf)) {
@@ -330,7 +330,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
if (null === $value) {
return '';
}
$decoded = json_decode($value, true, 512, JSON_THROW_ON_ERROR);
$decoded = json_decode((string) $value, true, 512, JSON_THROW_ON_ERROR);
if ('_header' === $value) {
$label = $cfType->getChoices($cf)[$slugChoice];

View File

@@ -33,7 +33,7 @@ class LabelPersonHelper
return '';
}
$decoded = json_decode($value, null, 512, JSON_THROW_ON_ERROR);
$decoded = json_decode((string) $value, null, 512, JSON_THROW_ON_ERROR);
if (0 === count($decoded)) {
return '';

View File

@@ -103,7 +103,7 @@ final readonly class ListAccompanyingPeriodHelper
return '';
}
return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR));
return $this->translatableStringHelper->localize(json_decode((string) $value, true, 512, JSON_THROW_ON_ERROR));
},
'locationPersonName', 'requestorPerson' => function ($value) use ($key) {
if ('_header' === $value) {
@@ -140,7 +140,7 @@ final readonly class ListAccompanyingPeriodHelper
'|',
array_map(
fn ($s) => $this->translatableStringHelper->localize($s),
json_decode($value, true, 512, JSON_THROW_ON_ERROR)
json_decode((string) $value, true, 512, JSON_THROW_ON_ERROR)
)
);
},
@@ -157,7 +157,7 @@ final readonly class ListAccompanyingPeriodHelper
'|',
array_map(
fn ($s) => $this->socialIssueRender->renderString($this->socialIssueRepository->find($s), []),
json_decode($value, true, 512, JSON_THROW_ON_ERROR)
json_decode((string) $value, true, 512, JSON_THROW_ON_ERROR)
)
);
},

View File

@@ -332,7 +332,7 @@ class ListPersonHelper
return '';
}
$ids = json_decode($value, null, 512, JSON_THROW_ON_ERROR);
$ids = json_decode((string) $value, null, 512, JSON_THROW_ON_ERROR);
return
implode(

View File

@@ -57,7 +57,7 @@ final class PersonControllerUpdateTest extends WebTestCase
$em = self::$container->get(EntityManagerInterface::class);
foreach (self::$toDelete as list($class, $id)) {
foreach (self::$toDelete as [$class, $id]) {
$entity = $em->find($class, $id);
if (null === $entity) {

View File

@@ -41,7 +41,7 @@ final class PersonControllerViewTest extends WebTestCase
$em = self::$container->get(EntityManagerInterface::class);
foreach (self::$toDelete as list($class, $id)) {
foreach (self::$toDelete as [$class, $id]) {
$entity = $em->find($class, $id);
if (null === $entity) {
@@ -85,7 +85,8 @@ final class PersonControllerViewTest extends WebTestCase
$client->request('GET', $this->makeViewPath($personId));
self::assertResponseStatusCodeSame(403,
self::assertResponseStatusCodeSame(
403,
'The view page of a person of a center A must not be accessible for user of center B'
);
}

View File

@@ -27,7 +27,7 @@ final class PersonControllerViewWithHiddenFieldsTest extends WebTestCase
/**
* @var string The url to view the person details
*/
private string $viewUrl;
private readonly string $viewUrl;
protected function setUp(): void
{

View File

@@ -69,7 +69,7 @@ final class BirthdateValidatorTest extends ConstraintValidatorTestCase
return new BirthdateValidator(
new ParameterBag(['chill_person' => ['validation' => ['birthdate_not_after' => 'P1D']]]),
new MockClock(new \DateTimeImmutable('2023-08-30T14:12:00'))
);
);
}
private function createConstraint()

View File

@@ -26,7 +26,7 @@ use function is_object;
class BirthdateValidator extends ConstraintValidator
{
private string $interval_spec;
private readonly string $interval_spec;
private string $below_interval = 'P150Y';