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

@@ -29,8 +29,6 @@ use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepository;
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use DateInterval;
use DateTimeImmutable;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
@@ -43,11 +41,8 @@ use Symfony\Component\Serializer\Exception\RuntimeException;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Validator\ConstraintViolationList;
use Symfony\Component\Validator\ConstraintViolationListInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Component\Workflow\Registry;
use function array_values;
use function count;
final class AccompanyingCourseApiController extends ApiController
{
@@ -70,7 +65,7 @@ final class AccompanyingCourseApiController extends ApiController
// throw new BadRequestException('It is not possible to confirm this period');
$errors = $this->validator->validate($accompanyingPeriod, null, [$accompanyingPeriod::STEP_CONFIRMED]);
if (count($errors) > 0) {
if (\count($errors) > 0) {
return $this->json($errors, 422);
}
}
@@ -96,7 +91,7 @@ final class AccompanyingCourseApiController extends ApiController
throw new AccessDeniedException();
}
$since = (new DateTimeImmutable('now'))->sub(new DateInterval('P15D'));
$since = (new \DateTimeImmutable('now'))->sub(new \DateInterval('P15D'));
$total = $this->accompanyingPeriodRepository->countByRecentUserHistory($user, $since);
@@ -146,7 +141,7 @@ final class AccompanyingCourseApiController extends ApiController
fn (AccompanyingPeriod $period) => $this->isGranted(AccompanyingPeriodVoter::SEE, $period)
);
return $this->json(array_values($accompanyingPeriodsChecked), Response::HTTP_OK, [], ['groups' => ['read']]);
return $this->json(\array_values($accompanyingPeriodsChecked), Response::HTTP_OK, [], ['groups' => ['read']]);
}
public function participationApi($id, Request $request, $_format)
@@ -284,11 +279,12 @@ final class AccompanyingCourseApiController extends ApiController
/**
* @Route("/api/1.0/person/accompanying-course/{id}/confidential.json", name="chill_api_person_accompanying_period_confidential")
*
* @ParamConverter("accompanyingCourse", options={"id": "id"})
*/
public function toggleConfidentialApi(AccompanyingPeriod $accompanyingCourse, mixed $id, Request $request)
{
if ($request->getMethod() === 'POST') {
if ('POST' === $request->getMethod()) {
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::TOGGLE_CONFIDENTIAL, $accompanyingCourse);
$accompanyingCourse->setConfidential(!$accompanyingCourse->isConfidential());
@@ -301,14 +297,15 @@ final class AccompanyingCourseApiController extends ApiController
/**
* @Route("/api/1.0/person/accompanying-course/{id}/intensity.json", name="chill_api_person_accompanying_period_intensity")
*
* @ParamConverter("accompanyingCourse", options={"id": "id"})
*/
public function toggleIntensityApi(AccompanyingPeriod $accompanyingCourse, Request $request)
{
if ($request->getMethod() === 'POST') {
if ('POST' === $request->getMethod()) {
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::TOGGLE_INTENSITY, $accompanyingCourse);
$status = $accompanyingCourse->getIntensity() === 'regular' ? 'occasional' : 'regular';
$status = 'regular' === $accompanyingCourse->getIntensity() ? 'occasional' : 'regular';
$accompanyingCourse->setIntensity($status);
$this->getDoctrine()->getManager()->flush();
}

View File

@@ -16,7 +16,6 @@ use Chill\PersonBundle\Form\AccompanyingCourseCommentType;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodCommentVoter;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Doctrine\ORM\EntityManagerInterface;
use LogicException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\FormType;
@@ -26,7 +25,6 @@ use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -38,6 +36,7 @@ class AccompanyingCourseCommentController extends AbstractController
* Page of comments in Accompanying Course section.
*
* @Route("/{_locale}/parcours/{accompanying_period_id}/comments", name="chill_person_accompanying_period_comment_list")
*
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
*/
public function commentAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response
@@ -66,13 +65,13 @@ class AccompanyingCourseCommentController extends AbstractController
}
if (!isset($editForm)) {
throw new NotFoundHttpException('comment with id ' . $request->query->getInt('edit') . ' is not found');
throw new NotFoundHttpException('comment with id '.$request->query->getInt('edit').' is not found');
}
if (isset($commentEdited)) {
$this->denyAccessUnlessGranted(AccompanyingPeriodCommentVoter::EDIT, $commentEdited);
} else {
throw new LogicException('at this step, commentEdited should be set');
throw new \LogicException('at this step, commentEdited should be set');
}
$editForm->handleRequest($request);

View File

@@ -19,7 +19,6 @@ use Chill\PersonBundle\Form\AccompanyingCourseType;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -33,9 +32,6 @@ use Symfony\Component\Workflow\Registry;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function array_slice;
use function is_array;
/**
* Class AccompanyingCourseController.
*/
@@ -45,6 +41,7 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
/**
* @Route("/{_locale}/parcours/{accompanying_period_id}/close", name="chill_person_accompanying_course_close")
*
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
*/
public function closeAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response
@@ -76,7 +73,7 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
$this->addFlash('error', $this->translator->trans('It is not possible to close this course'));
foreach ($errors as $e) {
/** @var ConstraintViolationInterface $e */
/* @var ConstraintViolationInterface $e */
$this->addFlash('error', $e->getMessage());
}
}
@@ -91,6 +88,7 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
* Delete page of Accompanying Course section.
*
* @Route("/{_locale}/parcours/{accompanying_period_id}/delete", name="chill_person_accompanying_course_delete")
*
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
*/
public function deleteAction(Request $request, AccompanyingPeriod $accompanyingCourse)
@@ -108,7 +106,7 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
->add('submit', SubmitType::class, ['label' => 'Delete'])
->getForm();
if ($request->getMethod() === Request::METHOD_DELETE) {
if (Request::METHOD_DELETE === $request->getMethod()) {
$form->handleRequest($request);
if ($form->isValid()) {
@@ -147,6 +145,7 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
* the page edit all blocks managed by vuejs component
*
* @Route("/{_locale}/parcours/{accompanying_period_id}/edit", name="chill_person_accompanying_course_edit")
*
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
*/
public function editAction(AccompanyingPeriod $accompanyingCourse): Response
@@ -164,6 +163,7 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
* the page show anti chronologic history with all actions, title of page is 'Accompanying Course History'
*
* @Route("/{_locale}/parcours/{accompanying_period_id}/history", name="chill_person_accompanying_course_history")
*
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
*/
public function historyAction(AccompanyingPeriod $accompanyingCourse): Response
@@ -179,6 +179,7 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
* Homepage of Accompanying Course section.
*
* @Route("/{_locale}/parcours/{accompanying_period_id}", name="chill_person_accompanying_course_index")
*
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
*/
public function indexAction(AccompanyingPeriod $accompanyingCourse): Response
@@ -200,7 +201,7 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
['date' => 'DESC', 'id' => 'DESC'],
);
$activities = array_slice($activities, 0, 3);
$activities = \array_slice($activities, 0, 3);
$works = $this->workRepository->findByAccompanyingPeriod(
$accompanyingCourse,
@@ -228,7 +229,7 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
if ($request->query->has('person_id')) {
$personIds = $request->query->get('person_id');
if (false === is_array($personIds)) {
if (false === \is_array($personIds)) {
throw new BadRequestHttpException('person_id parameter should be an array');
}
@@ -290,6 +291,7 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
/**
* @Route("/{_locale}/parcours/{accompanying_period_id}/open", name="chill_person_accompanying_course_reopen")
*
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
*/
public function reOpenAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response

View File

@@ -15,8 +15,6 @@ use Chill\MainBundle\CRUD\Controller\ApiController;
use Chill\MainBundle\Serializer\Model\Collection;
use Chill\MainBundle\Serializer\Model\Counter;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
use DateInterval;
use DateTimeImmutable;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
@@ -30,10 +28,10 @@ class AccompanyingCourseWorkApiController extends ApiController
*/
public function myWorksNearEndDate(Request $request): JsonResponse
{
$since = (new DateTimeImmutable('now'))
->sub(new DateInterval('P' . $request->query->getInt('since', 15) . 'D'));
$until = (new DateTimeImmutable('now'))
->add(new DateInterval('P' . $request->query->getInt('since', 15) . 'D'));
$since = (new \DateTimeImmutable('now'))
->sub(new \DateInterval('P'.$request->query->getInt('since', 15).'D'));
$until = (new \DateTimeImmutable('now'))
->add(new \DateInterval('P'.$request->query->getInt('since', 15).'D'));
$total = $this->accompanyingPeriodWorkRepository
->countNearEndDateByUser($this->getUser(), $since, $until);

View File

@@ -11,7 +11,6 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface;
@@ -25,7 +24,6 @@ use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkVoter;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -56,11 +54,11 @@ final class AccompanyingCourseWorkController extends AbstractController
{
$this->denyAccessUnlessGranted(AccompanyingPeriodWorkVoter::CREATE, $period);
if ($period->getSocialIssues()->count() === 0) {
if (0 === $period->getSocialIssues()->count()) {
$this->addFlash(
'error',
$this->trans->trans(
'accompanying_work.You must add at least ' .
'accompanying_work.You must add at least '.
'one social issue on accompanying period'
)
);
@@ -93,7 +91,7 @@ final class AccompanyingCourseWorkController extends AbstractController
$form = $this->createDeleteForm($work->getId());
if ($request->getMethod() === Request::METHOD_DELETE) {
if (Request::METHOD_DELETE === $request->getMethod()) {
$form->handleRequest($request);
if ($form->isValid()) {
@@ -161,7 +159,7 @@ final class AccompanyingCourseWorkController extends AbstractController
'types' => $filter->hasEntityChoice('typesFilter') ? $filter->getEntityChoiceData('typesFilter') : [],
'before' => $filter->getDateRangeData('dateFilter')['to'],
'after' => $filter->getDateRangeData('dateFilter')['from'],
'user' => $filter->getUserPickerData('userFilter')
'user' => $filter->getUserPickerData('userFilter'),
];
$totalItems = $this->workRepository->countByAccompanyingPeriod($period);
@@ -178,7 +176,7 @@ final class AccompanyingCourseWorkController extends AbstractController
'accompanyingCourse' => $period,
'works' => $works,
'paginator' => $paginator,
'filter' => $filter
'filter' => $filter,
]);
}
@@ -226,7 +224,7 @@ final class AccompanyingCourseWorkController extends AbstractController
if (1 < count($types)) {
$filterBuilder
->addEntityChoice('typesFilter', 'accompanying_course_work.types_filter', \Chill\PersonBundle\Entity\SocialWork\SocialAction::class, $types, [
'choice_label' => fn (SocialAction $sa) => $this->translatableStringHelper->localize($sa->getTitle())
'choice_label' => fn (SocialAction $sa) => $this->translatableStringHelper->localize($sa->getTitle()),
]);
}

View File

@@ -37,7 +37,7 @@ class AccompanyingCourseWorkEvaluationDocumentController extends AbstractControl
$this->security->isGranted(AccompanyingPeriodWorkVoter::UPDATE, $work) ?
'chill_person_accompanying_period_work_edit' : 'chill_person_accompanying_period_work_show',
[
'id' => $work->getId()
'id' => $work->getId(),
]
);
}

View File

@@ -18,7 +18,6 @@ use Chill\PersonBundle\Privacy\PrivacyEvent;
use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepositoryInterface;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use DateTime;
use Doctrine\DBAL\Exception;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -27,9 +26,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Validator\ConstraintViolationListInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use function array_filter;
use function count;
/**
* Class AccompanyingPeriodController.
@@ -57,6 +54,7 @@ class AccompanyingPeriodController extends AbstractController
/**
* @throws \Exception
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/accompanying-period/close", name="chill_person_accompanying_period_close")
*/
public function closeAction(int $person_id, Request $request): Response
@@ -65,7 +63,7 @@ class AccompanyingPeriodController extends AbstractController
$this->denyAccessUnlessGranted(PersonVoter::UPDATE, $person, 'You are not allowed to update this person');
if ($person->isOpen() === false) {
if (false === $person->isOpen()) {
$this->get('session')->getFlashBag()
->add('error', $this->get('translator')
->trans(
@@ -85,14 +83,14 @@ class AccompanyingPeriodController extends AbstractController
'center' => $person->getCenter(),
]);
if ($request->getMethod() === 'POST') {
if ('POST' === $request->getMethod()) {
$form->handleRequest($request);
if ($form->isValid()) {
$person->close($current);
$errors = $this->_validatePerson($person);
if (count($errors) === 0) {
if (0 === \count($errors)) {
$this->get('session')->getFlashBag()
->add('success', $this->get('translator')
->trans('An accompanying period has been closed.', [
@@ -113,7 +111,7 @@ class AccompanyingPeriodController extends AbstractController
$this->get('session')->getFlashBag()
->add('info', $error->getMessage());
}
} else { //if form is not valid
} else { // if form is not valid
$this->get('session')->getFlashBag()
->add(
'error',
@@ -148,11 +146,11 @@ class AccompanyingPeriodController extends AbstractController
'You are not allowed to update this person'
);
$accompanyingPeriod = new AccompanyingPeriod(new DateTime('now'));
$accompanyingPeriod->setClosingDate(new DateTime('now'));
$accompanyingPeriod = new AccompanyingPeriod(new \DateTime('now'));
$accompanyingPeriod->setClosingDate(new \DateTime('now'));
$accompanyingPeriod->addPerson($person);
//or $person->addAccompanyingPeriod($accompanyingPeriod);
// or $person->addAccompanyingPeriod($accompanyingPeriod);
$form = $this->createForm(
AccompanyingPeriodType::class,
@@ -163,14 +161,14 @@ class AccompanyingPeriodController extends AbstractController
]
);
if ($request->getMethod() === 'POST') {
if ('POST' === $request->getMethod()) {
$form->handleRequest($request);
$errors = $this->_validatePerson($person);
$flashBag = $this->get('session')->getFlashBag();
if (
$form->isValid(['Default', 'closed'])
&& count($errors) === 0
&& 0 === \count($errors)
) {
$em = $this->getDoctrine()->getManager();
$em->persist($accompanyingPeriod);
@@ -203,6 +201,7 @@ class AccompanyingPeriodController extends AbstractController
/**
* @ParamConverter("person", options={"id": "person_id"})
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/accompanying-period", name="chill_person_accompanying_period_list")
*/
public function listAction(Person $person): Response
@@ -216,12 +215,12 @@ class AccompanyingPeriodController extends AbstractController
$this->eventDispatcher->dispatch($event, PrivacyEvent::PERSON_PRIVACY_EVENT);
$accompanyingPeriods = $this->accompanyingPeriodACLAwareRepository
->findByPerson($person, AccompanyingPeriodVoter::SEE, ["openingDate" => "DESC", "id" => "DESC"]);
->findByPerson($person, AccompanyingPeriodVoter::SEE, ['openingDate' => 'DESC', 'id' => 'DESC']);
//usort($accompanyingPeriodsRaw, static fn ($a, $b) => $b->getOpeningDate() <=> $a->getOpeningDate());
// usort($accompanyingPeriodsRaw, static fn ($a, $b) => $b->getOpeningDate() <=> $a->getOpeningDate());
// filter visible or not visible
//$accompanyingPeriods = array_filter($accompanyingPeriodsRaw, fn (AccompanyingPeriod $ap) => $this->isGranted(AccompanyingPeriodVoter::SEE, $ap));
// $accompanyingPeriods = array_filter($accompanyingPeriodsRaw, fn (AccompanyingPeriod $ap) => $this->isGranted(AccompanyingPeriodVoter::SEE, $ap));
return $this->render('@ChillPerson/AccompanyingPeriod/list.html.twig', [
'accompanying_periods' => $accompanyingPeriods,
@@ -242,7 +241,7 @@ class AccompanyingPeriodController extends AbstractController
'You are not allowed to update this person'
);
//in case the person is already open
// in case the person is already open
if ($person->isOpen()) {
$this->get('session')->getFlashBag()
->add('error', $this->get('translator')
@@ -256,7 +255,7 @@ class AccompanyingPeriodController extends AbstractController
]);
}
$accompanyingPeriod = new AccompanyingPeriod(new DateTime());
$accompanyingPeriod = new AccompanyingPeriod(new \DateTime());
$form = $this->createForm(
AccompanyingPeriodType::class,
@@ -267,7 +266,7 @@ class AccompanyingPeriodController extends AbstractController
]
);
if ($request->getMethod() === 'POST') {
if ('POST' === $request->getMethod()) {
$form->handleRequest($request);
if ($form->isValid()) {
@@ -275,7 +274,7 @@ class AccompanyingPeriodController extends AbstractController
$errors = $this->_validatePerson($person);
if (count($errors) <= 0) {
if (\count($errors) <= 0) {
$this->get('session')->getFlashBag()
->add('success', $this->get('translator')
->trans(
@@ -323,9 +322,9 @@ class AccompanyingPeriodController extends AbstractController
$person = $this->_getPerson($person_id);
/** @var AccompanyingPeriod $period */
$period = array_filter(
$period = \array_filter(
$person->getAccompanyingPeriods(),
static fn (AccompanyingPeriod $p) => $p->getId() === ($period_id)
static fn (AccompanyingPeriod $p) => $p->getId() === $period_id
)[0] ?? null;
if (null === $period) {
@@ -364,6 +363,7 @@ class AccompanyingPeriodController extends AbstractController
/**
* @throws Exception
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/accompanying-period/{period_id}/update", name="chill_person_accompanying_period_update")
*/
public function updateAction(int $person_id, int $period_id, Request $request): Response
@@ -374,7 +374,7 @@ class AccompanyingPeriodController extends AbstractController
$accompanyingPeriod = $em->getRepository(AccompanyingPeriod::class)->find($period_id);
if (null === $accompanyingPeriod) {
throw $this->createNotFoundException('Period with id ' . $period_id . ' is not found');
throw $this->createNotFoundException('Period with id '.$period_id.' is not found');
}
/** @var Person $person */
@@ -382,7 +382,7 @@ class AccompanyingPeriodController extends AbstractController
// CHECK
if (!$accompanyingPeriod->containsPerson($person)) {
throw new Exception('Accompanying period ' . $period_id . ' does not contain person ' . $person_id);
throw new Exception('Accompanying period '.$period_id.' does not contain person '.$person_id);
}
$this->denyAccessUnlessGranted(
@@ -400,14 +400,14 @@ class AccompanyingPeriodController extends AbstractController
]
);
if ($request->getMethod() === 'POST') {
if ('POST' === $request->getMethod()) {
$form->handleRequest($request);
$errors = $this->_validatePerson($person);
$flashBag = $this->get('session')->getFlashBag();
if (
$form->isValid(['Default', 'closed'])
&& count($errors) === 0
&& 0 === \count($errors)
) {
$em->flush();

View File

@@ -28,7 +28,6 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Templating\EngineInterface;
class AccompanyingPeriodRegulationListController
{

View File

@@ -27,9 +27,6 @@ use Symfony\Component\Security\Core\Security;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\SerializerInterface;
use function count;
use function in_array;
class AccompanyingPeriodWorkEvaluationApiController
{
public function __construct(private readonly AccompanyingPeriodWorkEvaluationRepository $accompanyingPeriodWorkEvaluationRepository, private readonly DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private readonly SerializerInterface $serializer, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security) {}
@@ -51,12 +48,12 @@ class AccompanyingPeriodWorkEvaluationApiController
static function (DocGeneratorTemplate $t) use ($evaluation) {
$ids = $t->getOptions()['evaluations'] ?? [];
return in_array($evaluation->getId(), $ids, true);
return \in_array($evaluation->getId(), $ids, true);
}
);
$paginator = $this->paginatorFactory->create(count($evaluations));
$paginator->setItemsPerPage(count($evaluations));
$paginator = $this->paginatorFactory->create(\count($evaluations));
$paginator->setItemsPerPage(\count($evaluations));
return new JsonResponse($this->serializer->serialize(
new Collection(array_values($evaluations), $paginator),

View File

@@ -53,6 +53,7 @@ class AdminController extends AbstractController
/**
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/person_redirect_to_main", name="chill_person_admin_redirect_to_admin_index", options={null})
*/
public function redirectToAdminIndexAction()

View File

@@ -52,7 +52,7 @@ class ClosingMotiveController extends CRUDController
*/
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
{
/** @var \Doctrine\ORM\QueryBuilder $query */
/* @var \Doctrine\ORM\QueryBuilder $query */
return $query->orderBy('e.ordering', 'ASC');
}
}

View File

@@ -22,16 +22,12 @@ use Chill\PersonBundle\Event\Person\PersonAddressMoveEvent;
use Chill\PersonBundle\Repository\Household\HouseholdACLAwareRepositoryInterface;
use Chill\PersonBundle\Repository\Household\HouseholdRepository;
use Chill\PersonBundle\Security\Authorization\HouseholdVoter;
use DateTimeImmutable;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use function array_filter;
use function array_values;
class HouseholdApiController extends ApiController
{
@@ -79,9 +75,9 @@ class HouseholdApiController extends ApiController
$household->addAddress($address);
foreach ($household->getMembersOnRange(
DateTimeImmutable::createFromMutable($address->getValidFrom()),
\DateTimeImmutable::createFromMutable($address->getValidFrom()),
null === $address->getValidTo() ? null :
DateTimeImmutable::createFromMutable($address->getValidTo())
\DateTimeImmutable::createFromMutable($address->getValidTo())
) as $member) {
/** @var HouseholdMember $member */
$event = new PersonAddressMoveEvent($member->getPerson());
@@ -114,6 +110,7 @@ class HouseholdApiController extends ApiController
* "_format": "json"
* }
* )
*
* @ParamConverter("household", options={"id": "household_id"})
*/
public function suggestAddressByHousehold(Household $household, string $_format)
@@ -146,11 +143,11 @@ class HouseholdApiController extends ApiController
$actual = $household->getCurrentAddress();
if (null !== $actual) {
$addresses = array_filter($addresses, static fn ($a) => $a !== $actual);
$addresses = \array_filter($addresses, static fn ($a) => $a !== $actual);
}
return $this->json(
array_values($addresses),
\array_values($addresses),
Response::HTTP_OK,
[],
['groups' => ['read']]
@@ -186,7 +183,7 @@ class HouseholdApiController extends ApiController
}
if (null !== $currentHouseholdPerson) {
$count = $count - 1;
--$count;
$paginator = $this->getPaginatorFactory()->create($count);
}
}

View File

@@ -18,7 +18,6 @@ use Chill\PersonBundle\Form\HouseholdCompositionType;
use Chill\PersonBundle\Repository\Household\HouseholdCompositionRepository;
use Chill\PersonBundle\Repository\Household\HouseholdRepository;
use Chill\PersonBundle\Security\Authorization\HouseholdVoter;
use DateTimeImmutable;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
@@ -31,7 +30,6 @@ use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Templating\EngineInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
class HouseholdCompositionController extends AbstractController
@@ -71,7 +69,7 @@ class HouseholdCompositionController extends AbstractController
->add('submit', SubmitType::class, ['label' => 'Delete'])
->getForm();
if ($request->getMethod() === Request::METHOD_DELETE) {
if (Request::METHOD_DELETE === $request->getMethod()) {
$form->handleRequest($request);
if ($form->isValid()) {
@@ -135,13 +133,13 @@ class HouseholdCompositionController extends AbstractController
if ($isEdit) {
$householdCompositions = $household->getCompositions()->filter(static fn (HouseholdComposition $composition) => $composition->getId() === $request->query->getInt('edit'));
if ($householdCompositions->count() !== 1) {
if (1 !== $householdCompositions->count()) {
throw new BadRequestHttpException('could not find the composition with this id associated to the household');
}
$householdComposition = $householdCompositions->first();
} else {
$householdComposition = (new HouseholdComposition())
->setStartDate(new DateTimeImmutable());
->setStartDate(new \DateTimeImmutable());
}
$form = $this->formFactory->create(HouseholdCompositionType::class, $householdComposition);

View File

@@ -14,7 +14,6 @@ namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\HttpFoundation\Request;
use UnexpectedValueException;
class HouseholdCompositionTypeApiController extends ApiController
{
@@ -25,7 +24,7 @@ class HouseholdCompositionTypeApiController extends ApiController
{
match ($action) {
'_index' => $query->andWhere($query->expr()->eq('e.active', "'TRUE'")),
default => throw new UnexpectedValueException('unexepcted action: ' . $action),
default => throw new \UnexpectedValueException('unexepcted action: '.$action),
};
}
}

View File

@@ -29,9 +29,6 @@ use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function array_key_exists;
use function count;
/**
* @Route("/{_locale}/person/household")
*/
@@ -45,6 +42,7 @@ class HouseholdController extends AbstractController
* name="chill_person_household_accompanying_period",
* methods={"GET", "HEAD"}
* )
*
* @ParamConverter("household", options={"id": "household_id"})
*/
public function accompanyingPeriod(Request $request, Household $household)
@@ -77,7 +75,7 @@ class HouseholdController extends AbstractController
}
$id = $accompanyingPeriod->getId();
if (!array_key_exists($id, $accompanyingPeriodsOld) && !array_key_exists($id, $accompanyingPeriods)) {
if (!\array_key_exists($id, $accompanyingPeriodsOld) && !\array_key_exists($id, $accompanyingPeriods)) {
$accompanyingPeriodsOld[$id] = $accompanyingPeriod;
}
}
@@ -99,6 +97,7 @@ class HouseholdController extends AbstractController
* name="chill_person_household_address_edit",
* methods={"GET", "HEAD", "POST"}
* )
*
* @ParamConverter("household", options={"id": "household_id"})
*/
public function addressEdit(Request $request, Household $household)
@@ -125,17 +124,18 @@ class HouseholdController extends AbstractController
* name="chill_person_household_addresses",
* methods={"GET", "HEAD"}
* )
*
* @ParamConverter("household", options={"id": "household_id"})
*/
public function addresses(Request $request, Household $household)
{
// TODO ACL
//TODO put these lines into a validator constraint on household->getAddress
// TODO put these lines into a validator constraint on household->getAddress
$addresses = $household->getAddresses();
$cond = true;
for ($i = 0; count($addresses) - 1 > $i; ++$i) {
for ($i = 0; \count($addresses) - 1 > $i; ++$i) {
if ($addresses[$i]->getValidFrom() !== $addresses[$i + 1]->getValidTo()) {
$cond = false;
}
@@ -155,6 +155,7 @@ class HouseholdController extends AbstractController
* name="chill_person_household_address_move",
* methods={"GET", "HEAD", "POST"}
* )
*
* @ParamConverter("household", options={"id": "household_id"})
*/
public function addressMove(Request $request, Household $household)
@@ -175,6 +176,7 @@ class HouseholdController extends AbstractController
* name="chill_person_household_address_valid_from_edit",
* methods={"GET", "HEAD", "POST"}
* )
*
* @ParamConverter("household", options={"id": "household_id"})
*/
public function addressValidFromEdit(Request $request, Household $household)
@@ -231,6 +233,7 @@ class HouseholdController extends AbstractController
* name="chill_person_household_members_metadata_edit",
* methods={"GET", "POST"}
* )
*
* @ParamConverter("household", options={"id": "household_id"})
*/
public function editHouseholdMetadata(Request $request, Household $household)
@@ -262,6 +265,7 @@ class HouseholdController extends AbstractController
* name="chill_person_household_relationship",
* methods={"GET", "HEAD"}
* )
*
* @ParamConverter("household", options={"id": "household_id"})
*/
public function showRelationship(Request $request, Household $household)
@@ -287,6 +291,7 @@ class HouseholdController extends AbstractController
* name="chill_person_household_summary",
* methods={"GET", "HEAD"}
* )
*
* @ParamConverter("household", options={"id": "household_id"})
*/
public function summary(Request $request, Household $household)

View File

@@ -28,8 +28,6 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Serializer\Exception;
use Symfony\Contracts\Translation\TranslatorInterface;
use function count;
class HouseholdMemberController extends ApiController
{
public function __construct(private readonly UrlGeneratorInterface $generator, private readonly TranslatorInterface $translator, private readonly AccompanyingPeriodRepository $periodRepository) {}
@@ -90,9 +88,8 @@ class HouseholdMemberController extends ApiController
if ($request->query->has('persons')) {
$ids = $request->query->get('persons', []);
if (0 === count($ids)) {
throw new BadRequestHttpException('parameters persons in query ' .
'is not an array or empty');
if (0 === \count($ids)) {
throw new BadRequestHttpException('parameters persons in query is not an array or empty');
}
$persons = $em->getRepository(Person::class)
@@ -181,7 +178,7 @@ class HouseholdMemberController extends ApiController
//
$errors = $editor->validate();
if (count($errors) > 0) {
if (\count($errors) > 0) {
return $this->json($errors, 422);
}

View File

@@ -12,7 +12,6 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController;
use DateTime;
use Symfony\Component\HttpFoundation\Request;
class OpeningApiController extends ApiController
@@ -21,6 +20,6 @@ class OpeningApiController extends ApiController
{
$qb->where($qb->expr()->gt('e.noActiveAfter', ':now'))
->orWhere($qb->expr()->isNull('e.noActiveAfter'));
$qb->setParameter('now', new DateTime('now'));
$qb->setParameter('now', new \DateTime('now'));
}
}

View File

@@ -19,8 +19,6 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use function count;
/**
* Class PersonAddressController
* Controller for addresses associated with person.
@@ -50,8 +48,7 @@ class PersonAddressController extends AbstractController
->find($person_id);
if (null === $person) {
throw $this->createNotFoundException("Person with id {$person_id} not"
. ' found ');
throw $this->createNotFoundException("Person with id {$person_id} not".' found ');
}
$this->denyAccessUnlessGranted(
@@ -70,7 +67,7 @@ class PersonAddressController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
$validatePersonErrors = $this->validatePerson($person);
if (count($validatePersonErrors) !== 0) {
if (0 !== \count($validatePersonErrors)) {
foreach ($validatePersonErrors as $error) {
$this->addFlash('error', $error->getMessage());
}
@@ -108,8 +105,7 @@ class PersonAddressController extends AbstractController
->find($person_id);
if (null === $person) {
throw $this->createNotFoundException("Person with id {$person_id} not"
. ' found ');
throw $this->createNotFoundException("Person with id {$person_id} not".' found ');
}
$this->denyAccessUnlessGranted(
@@ -139,8 +135,7 @@ class PersonAddressController extends AbstractController
->find($person_id);
if (null === $person) {
throw $this->createNotFoundException("Person with id {$person_id} not"
. ' found ');
throw $this->createNotFoundException("Person with id {$person_id} not".' found ');
}
$this->denyAccessUnlessGranted(
@@ -164,8 +159,7 @@ class PersonAddressController extends AbstractController
->find($person_id);
if (null === $person) {
throw $this->createNotFoundException("Person with id {$person_id} not"
. ' found ');
throw $this->createNotFoundException("Person with id {$person_id} not".' found ');
}
$this->denyAccessUnlessGranted(
@@ -194,8 +188,7 @@ class PersonAddressController extends AbstractController
->find($person_id);
if (null === $person) {
throw $this->createNotFoundException("Person with id {$person_id} not"
. ' found ');
throw $this->createNotFoundException("Person with id {$person_id} not".' found ');
}
$this->denyAccessUnlessGranted(
@@ -212,7 +205,7 @@ class PersonAddressController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
$validatePersonErrors = $this->validatePerson($person);
if (count($validatePersonErrors) !== 0) {
if (0 !== \count($validatePersonErrors)) {
foreach ($validatePersonErrors as $error) {
$this->addFlash('error', $error->getMessage());
}
@@ -284,9 +277,9 @@ class PersonAddressController extends AbstractController
/**
* @param int $address_id
*
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the address id does not exists or is not associated with given person
*
* @return Address
*
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the address id does not exists or is not associated with given person
*/
protected function findAddressById(Person $person, $address_id)
{

View File

@@ -13,7 +13,6 @@ namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController;
use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\Center;
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
use Chill\PersonBundle\Entity\Person;
@@ -24,7 +23,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use function in_array;
class PersonApiController extends ApiController
{
@@ -91,6 +89,7 @@ class PersonApiController extends ApiController
* "_format": "json"
* }
* )
*
* @ParamConverter("person", options={"id": "person_id"})
*/
public function suggestAddress(Person $person, Request $request, string $_format): Response
@@ -116,7 +115,7 @@ class PersonApiController extends ApiController
static function (Address $address) use (&$seenAddressIds): bool {
$id = $address->getId();
if (in_array($id, $seenAddressIds, true)) {
if (\in_array($id, $seenAddressIds, true)) {
return false;
}

View File

@@ -11,7 +11,6 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
use Chill\PersonBundle\Entity\Household\Household;
@@ -23,9 +22,7 @@ use Chill\PersonBundle\Privacy\PrivacyEvent;
use Chill\PersonBundle\Repository\PersonRepository;
use Chill\PersonBundle\Search\SimilarPersonMatcher;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use DateTimeImmutable;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -33,18 +30,11 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function count;
use function hash;
use function implode;
use function in_array;
use function is_array;
final class PersonController extends AbstractController
{
@@ -131,6 +121,7 @@ final class PersonController extends AbstractController
* name="chill_person_household_person_history",
* methods={"GET", "POST"}
* )
*
* @ParamConverter("person", options={"id": "person_id"})
*/
public function householdHistoryByPerson(Request $request, Person $person): Response
@@ -160,6 +151,7 @@ final class PersonController extends AbstractController
*
* The next post compare the data with previous one and, if yes, show a
* review page if there are "alternate persons".
*
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/new", name="chill_person_new")
*/
public function newAction(Request $request): Response
@@ -168,7 +160,7 @@ final class PersonController extends AbstractController
$authorizedCenters = $this->authorizationHelper->getReachableCenters($this->getUser(), PersonVoter::CREATE);
if (1 === count($authorizedCenters)) {
if (1 === \count($authorizedCenters)) {
$person->setCenter($authorizedCenters[0]);
}
@@ -183,10 +175,10 @@ final class PersonController extends AbstractController
$form->handleRequest($request);
if ($request->getMethod() === Request::METHOD_GET) {
if (Request::METHOD_GET === $request->getMethod()) {
$this->lastPostDataReset();
} elseif (
$request->getMethod() === Request::METHOD_POST
Request::METHOD_POST === $request->getMethod()
&& $form->isValid()
) {
$alternatePersons = $this->similarPersonMatcher
@@ -194,7 +186,7 @@ final class PersonController extends AbstractController
if (
false === $this->isLastPostDataChanges($form, $request, true)
|| count($alternatePersons) === 0
|| 0 === \count($alternatePersons)
) {
$this->em->persist($person);
@@ -209,7 +201,7 @@ final class PersonController extends AbstractController
$member = new HouseholdMember();
$member->setPerson($person);
$member->setStartDate(new DateTimeImmutable());
$member->setStartDate(new \DateTimeImmutable());
$household->addMember($member);
$household->setForceAddress($address);
@@ -243,7 +235,7 @@ final class PersonController extends AbstractController
['person_id' => $person->getId()]
);
}
} elseif ($request->getMethod() === Request::METHOD_POST && !$form->isValid()) {
} elseif (Request::METHOD_POST === $request->getMethod() && !$form->isValid()) {
$this->addFlash('error', $this->translator->trans('This form contains errors'));
}
@@ -264,8 +256,7 @@ final class PersonController extends AbstractController
$person = $this->_getPerson($person_id);
if (null === $person) {
throw $this->createNotFoundException("Person with id {$person_id} not"
. ' found on this server');
throw $this->createNotFoundException("Person with id {$person_id} not".' found on this server');
}
$this->denyAccessUnlessGranted(
@@ -290,7 +281,6 @@ final class PersonController extends AbstractController
/**
* easy getting a person by his id.
*
*
* @return \Chill\PersonBundle\Entity\Person
*/
private function _getPerson(int $id)
@@ -306,14 +296,14 @@ final class PersonController extends AbstractController
$errors = $this->validator
->validate($person, null, ['creation']);
//validate accompanying periods
// validate accompanying periods
$periods = $person->getAccompanyingPeriods();
foreach ($periods as $period) {
$period_errors = $this->validator
->validate($period);
//group errors :
// group errors :
foreach ($period_errors as $error) {
$errors->add($error);
}
@@ -353,15 +343,15 @@ final class PersonController extends AbstractController
$ignoredFields = ['form_status', '_token'];
foreach ($request->request->all()[$form->getName()] as $field => $value) {
if (in_array($field, $ignoredFields, true)) {
if (\in_array($field, $ignoredFields, true)) {
continue;
}
$fields[$field] = is_array($value) ?
implode(',', $value) : $value;
$fields[$field] = \is_array($value) ?
\implode(',', $value) : $value;
}
ksort($fields);
return hash('sha512', implode('&', $fields));
return \hash('sha512', \implode('&', $fields));
}
private function lastPostDataReset(): void

View File

@@ -25,11 +25,9 @@ use Chill\PersonBundle\Repository\PersonRepository;
use Chill\PersonBundle\Search\SimilarPersonMatcher;
use Chill\TaskBundle\Entity\SingleTask;
use http\Exception\InvalidArgumentException;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Contracts\Translation\TranslatorInterface;
use function count;
class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController
@@ -52,8 +50,7 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll
$person2->counters = $this->_getCounters($person2_id);
if (null === $person1) {
throw $this->createNotFoundException("Person with id {$person1_id} not"
. ' found on this server');
throw $this->createNotFoundException("Person with id {$person1_id} not".' found on this server');
}
$this->denyAccessUnlessGranted(
@@ -63,8 +60,7 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll
);
if (null === $person2) {
throw $this->createNotFoundException("Person with id {$person2_id} not"
. ' found on this server');
throw $this->createNotFoundException("Person with id {$person2_id} not".' found on this server');
}
$form = $this->createForm(PersonConfimDuplicateType::class);
@@ -109,8 +105,7 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll
$person = $this->_getPerson($person_id);
if (null === $person) {
throw $this->createNotFoundException("Person with id {$person_id} not"
. ' found on this server');
throw $this->createNotFoundException("Person with id {$person_id} not".' found on this server');
}
$this->denyAccessUnlessGranted(
@@ -127,8 +122,7 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll
$person2 = $form->get('person')->getData();
if (null === $person2) {
throw $this->createNotFoundException("Person with id {$person2->getId}() not"
. ' found on this server');
throw $this->createNotFoundException("Person with id {$person2->getId}() not".' found on this server');
}
$direction = $form->get('direction')->getData();
@@ -215,8 +209,7 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll
$person = $this->_getPerson($person_id);
if (null === $person) {
throw $this->createNotFoundException("Person with id {$person_id} not"
. ' found on this server');
throw $this->createNotFoundException("Person with id {$person_id} not".' found on this server');
}
$this->denyAccessUnlessGranted(
@@ -248,11 +241,11 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll
$person = $em->getRepository(Person::class)->findOneBy(['id' => $id]);
return [
'nb_activity' => count($nb_activity),
'nb_document' => count($nb_document),
'nb_activity' => \count($nb_activity),
'nb_document' => \count($nb_document),
// 'nb_event' => count($nb_event),
'nb_task' => $nb_task,
'nb_addresses' => count($person->getAddresses()),
'nb_addresses' => \count($person->getAddresses()),
];
}
@@ -279,13 +272,11 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll
}
if (null === $person1) {
throw $this->createNotFoundException("Person with id {$person1_id} not"
. ' found on this server');
throw $this->createNotFoundException("Person with id {$person1_id} not".' found on this server');
}
if (null === $person2) {
throw $this->createNotFoundException("Person with id {$person2_id} not"
. ' found on this server');
throw $this->createNotFoundException("Person with id {$person2_id} not".' found on this server');
}
return [$person1, $person2];

View File

@@ -50,7 +50,7 @@ final class PersonResourceController extends AbstractController
->add('submit', SubmitType::class, ['label' => 'Delete'])
->getForm();
if ($request->getMethod() === Request::METHOD_DELETE) {
if (Request::METHOD_DELETE === $request->getMethod()) {
$form->handleRequest($request);
if ($form->isValid()) {

View File

@@ -36,7 +36,6 @@ use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Validator\Constraints\NotIdenticalTo;
use Symfony\Component\Validator\Constraints\NotNull;
use function is_int;
class ReassignAccompanyingPeriodController extends AbstractController
{
@@ -142,7 +141,7 @@ class ReassignAccompanyingPeriodController extends AbstractController
return $builder->getForm();
}
private function buildReassignForm(array $periodIds, ?User $userFrom = null): FormInterface
private function buildReassignForm(array $periodIds, User $userFrom = null): FormInterface
{
$defaultData = [
'userFrom' => $userFrom,
@@ -181,7 +180,7 @@ class ReassignAccompanyingPeriodController extends AbstractController
return null;
}
if (!is_int((int) $id)) {
if (!\is_int((int) $id)) {
throw new TransformationFailedException('the user id is not a numeric');
}

View File

@@ -13,7 +13,6 @@ namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController;
use Chill\MainBundle\Pagination\PaginatorInterface;
use DateTimeImmutable;
use Symfony\Component\HttpFoundation\Request;
class SocialIssueApiController extends ApiController
@@ -26,7 +25,7 @@ class SocialIssueApiController extends ApiController
$query->expr()->isNull('e.desactivationDate')
)
);
$query->setParameter('now', new DateTimeImmutable());
$query->setParameter('now', new \DateTimeImmutable());
}
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator, $_format)

View File

@@ -13,13 +13,12 @@ namespace Chill\PersonBundle\Controller\SocialWork;
use Chill\MainBundle\CRUD\Controller\CRUDController;
use Chill\MainBundle\Pagination\PaginatorInterface;
use LogicException;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
class SocialIssueController extends CRUDController
{
protected function createFormFor(string $action, $entity, ?string $formClass = null, array $formOptions = []): FormInterface
protected function createFormFor(string $action, $entity, string $formClass = null, array $formOptions = []): FormInterface
{
if ('new' === $action) {
return parent::createFormFor($action, $entity, $formClass, ['step' => 'create']);
@@ -29,7 +28,7 @@ class SocialIssueController extends CRUDController
return parent::createFormFor($action, $entity, $formClass, ['step' => 'edit']);
}
throw new LogicException('action is not supported: ' . $action);
throw new \LogicException('action is not supported: '.$action);
}
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)

View File

@@ -31,6 +31,7 @@ class SocialWorkEvaluationApiController extends AbstractController
* "_format": "json"
* }
* )
*
* @ParamConverter("action", options={"id": "action_id"})
*/
public function listEvaluationBySocialAction(SocialAction $action): Response

View File

@@ -20,8 +20,6 @@ use Symfony\Component\Clock\ClockInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use function count;
final class SocialWorkSocialActionApiController extends ApiController
{
public function __construct(
@@ -46,9 +44,9 @@ final class SocialWorkSocialActionApiController extends ApiController
usort($socialActions, static fn (SocialAction $sa, SocialAction $sb) => $sa->getOrdering() <=> $sb->getOrdering());
$pagination = $this->paginator->create(count($socialActions));
$pagination = $this->paginator->create(\count($socialActions));
// max one page
$pagination->setItemsPerPage(count($socialActions));
$pagination->setItemsPerPage(\count($socialActions));
$collection = new Collection($socialActions, $pagination);