phpstan boolean corrections

This commit is contained in:
2025-10-09 13:57:30 +02:00
parent 03fa79c93b
commit b132956ddc
37 changed files with 149 additions and 623 deletions

View File

@@ -83,7 +83,7 @@ final class ActivityController extends AbstractController
$activity = $this->activityRepository->find($id);
if (!$activity) {
if (null === $activity) {
throw $this->createNotFoundException('Unable to find Activity entity.');
}
@@ -106,9 +106,9 @@ final class ActivityController extends AbstractController
$this->logger->notice('An activity has been removed', [
'by_user' => $this->getUser()->getUserIdentifier(),
'activity_id' => $activity->getId(),
'person_id' => $activity->getPerson() ? $activity->getPerson()->getId() : null,
'comment' => $activity->getComment()->getComment(),
'scope_id' => $activity->getScope() ? $activity->getScope()->getId() : null,
'person_id' => null === $activity->getPerson() ? $activity->getPerson()->getId() : null,
'comment' => null === $activity->getComment()->getComment(),
'scope_id' => null === $activity->getScope() ? $activity->getScope()->getId() : null,
'reasons_ids' => $activity->getReasons()
->map(
static fn (ActivityReason $ar): int => $ar->getId()

View File

@@ -15,6 +15,7 @@ use Chill\ActivityBundle\Entity\ActivityReasonCategory;
use Chill\ActivityBundle\Form\ActivityReasonCategoryType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
/**
@@ -88,7 +89,7 @@ class ActivityReasonCategoryController extends AbstractController
$entity = $em->getRepository(ActivityReasonCategory::class)->find($id);
if (!$entity) {
if (null === $entity) {
throw $this->createNotFoundException('Unable to find ActivityReasonCategory entity.');
}
@@ -112,9 +113,8 @@ class ActivityReasonCategoryController extends AbstractController
*
* @param ActivityReasonCategory $entity The entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createCreateForm(ActivityReasonCategory $entity)
private function createCreateForm(ActivityReasonCategory $entity): FormInterface
{
$form = $this->createForm(ActivityReasonCategoryType::class, $entity, [
'action' => $this->generateUrl('chill_activity_activityreasoncategory_create'),
@@ -131,9 +131,8 @@ class ActivityReasonCategoryController extends AbstractController
*
* @param ActivityReasonCategory $entity The entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createEditForm(ActivityReasonCategory $entity)
private function createEditForm(ActivityReasonCategory $entity): FormInterface
{
$form = $this->createForm(ActivityReasonCategoryType::class, $entity, [
'action' => $this->generateUrl('chill_activity_activityreasoncategory_update', ['id' => $entity->getId()]),

View File

@@ -16,6 +16,8 @@ use Chill\ActivityBundle\Form\ActivityReasonType;
use Chill\ActivityBundle\Repository\ActivityReasonRepository;
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;
/**
@@ -89,7 +91,7 @@ class ActivityReasonController extends AbstractController
$entity = $em->getRepository(ActivityReason::class)->find($id);
if (!$entity) {
if (null === $entity) {
throw $this->createNotFoundException('Unable to find ActivityReason entity.');
}
@@ -112,10 +114,8 @@ class ActivityReasonController extends AbstractController
* Creates a form to create a ActivityReason entity.
*
* @param ActivityReason $entity The entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createCreateForm(ActivityReason $entity)
private function createCreateForm(ActivityReason $entity): FormInterface
{
$form = $this->createForm(ActivityReasonType::class, $entity, [
'action' => $this->generateUrl('chill_activity_activityreason_create'),
@@ -131,10 +131,8 @@ class ActivityReasonController extends AbstractController
* Creates a form to edit a ActivityReason entity.
*
* @param ActivityReason $entity The entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createEditForm(ActivityReason $entity)
private function createEditForm(ActivityReason $entity): FormInterface
{
$form = $this->createForm(ActivityReasonType::class, $entity, [
'action' => $this->generateUrl('chill_activity_activityreason_update', ['id' => $entity->getId()]),

View File

@@ -46,20 +46,20 @@ class ChargeType extends AbstractType
'required' => false,
]);
if ($options['show_start_date']) {
if (true === $options['show_start_date']) {
$builder->add('startDate', ChillDateType::class, [
'label' => 'Start of validity period',
]);
}
if ($options['show_end_date']) {
if (true === $options['show_end_date']) {
$builder->add('endDate', ChillDateType::class, [
'required' => false,
'label' => 'End of validity period',
]);
}
if ($options['show_help']) {
if (true === $options['show_help']) {
$builder->add('help', ChoiceType::class, [
'choices' => [
'charge.help.running' => Charge::HELP_ASKED,

View File

@@ -45,13 +45,13 @@ class ResourceType extends AbstractType
'required' => false,
]);
if ($options['show_start_date']) {
if (true === $options['show_start_date']) {
$builder->add('startDate', ChillDateType::class, [
'label' => 'Start of validity period',
]);
}
if ($options['show_end_date']) {
if (true === $options['show_end_date']) {
$builder->add('endDate', ChillDateType::class, [
'required' => false,
'label' => 'End of validity period',

View File

@@ -97,7 +97,7 @@ final readonly class CalendarContext implements CalendarContextInterface
'data' => $this->translatableStringHelper->localize($template->getName()),
]);
if ($options['askMainPerson']) {
if (true === $options['askMainPerson']) {
$builder->add('mainPerson', EntityType::class, [
'class' => Person::class,
'multiple' => false,
@@ -109,7 +109,7 @@ final readonly class CalendarContext implements CalendarContextInterface
]);
}
if ($options['askThirdParty']) {
if (true === $options['askThirdParty']) {
$builder->add('thirdParty', EntityType::class, [
'class' => ThirdParty::class,
'multiple' => false,
@@ -132,7 +132,7 @@ final readonly class CalendarContext implements CalendarContextInterface
]
);
if ($options['askMainPerson']) {
if (true === $options['askMainPerson']) {
$data['mainPerson'] = $this->normalizer->normalize($contextGenerationData['mainPerson'] ?? null, 'docgen', [
'docgen:expects' => Person::class,
'groups' => ['docgen:read'],
@@ -142,7 +142,7 @@ final readonly class CalendarContext implements CalendarContextInterface
]);
}
if ($options['askThirdParty']) {
if (true === $options['askThirdParty']) {
$data['thirdParty'] = $this->normalizer->normalize($contextGenerationData['thirdParty'] ?? null, 'docgen', [
'docgen:expects' => ThirdParty::class,
'groups' => ['docgen:read'],
@@ -167,7 +167,7 @@ final readonly class CalendarContext implements CalendarContextInterface
$options = $this->getOptions($template);
$data = [];
if ($options['askMainPerson']) {
if (true === $options['askMainPerson']) {
$data['mainPerson'] = null;
if (1 === \count($entity->getPersons())) {
@@ -175,7 +175,7 @@ final readonly class CalendarContext implements CalendarContextInterface
}
}
if ($options['askThirdParty']) {
if (true === $options['askThirdParty']) {
$data['thirdParty'] = null;
if (1 === \count($entity->getProfessionals())) {

View File

@@ -70,7 +70,7 @@ class CustomFieldController extends AbstractController
$entity = $em->getRepository(CustomField::class)->find($id);
if (!$entity) {
if (null === $entity) {
throw $this->createNotFoundException('Unable to find CustomField entity.');
}
@@ -98,7 +98,7 @@ class CustomFieldController extends AbstractController
->getRepository(CustomFieldsGroup::class)
->find($cfGroupId);
if (!$cfGroup) {
if (null === $cfGroup) {
throw $this->createNotFoundException('CustomFieldsGroup with id '.$cfGroupId.' is not found !');
}
$entity->setCustomFieldsGroup($cfGroup);
@@ -122,7 +122,7 @@ class CustomFieldController extends AbstractController
$entity = $em->getRepository(CustomField::class)->find($id);
if (!$entity) {
if (null === $entity) {
throw $this->createNotFoundException('Unable to find CustomField entity.');
}
@@ -150,7 +150,7 @@ class CustomFieldController extends AbstractController
/**
* Creates a form to create a CustomField entity.
*
* @return \Symfony\Component\Form\Form The form
* @return \Symfony\Component\Form\FormInterface The form
*/
private function createCreateForm(CustomField $entity, mixed $type)
{
@@ -174,7 +174,7 @@ class CustomFieldController extends AbstractController
*
* @param CustomField $entity The entity
*
* @return \Symfony\Component\Form\Form The form
* @return \Symfony\Component\Form\FormInterface The form
*/
private function createEditForm(CustomField $entity, mixed $type)
{

View File

@@ -24,6 +24,7 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -81,7 +82,7 @@ class CustomFieldsGroupController extends AbstractController
$entity = $em->getRepository(CustomFieldsGroup::class)->find($id);
if (!$entity) {
if (null === $entity) {
throw $this->createNotFoundException('Unable to find CustomFieldsGroup entity.');
}
@@ -134,7 +135,7 @@ class CustomFieldsGroupController extends AbstractController
$cFGroup = $em->getRepository(CustomFieldsGroup::class)->findOneById($cFGroupId);
if (!$cFGroup) {
if (null === $cFGroup) {
throw $this->createNotFoundException('customFieldsGroup not found with '."id {$cFGroupId}");
}
@@ -194,7 +195,7 @@ class CustomFieldsGroupController extends AbstractController
$entity = $em->getRepository(CustomFieldsGroup::class)->find($id);
if (!$entity) {
if (null === $entity) {
throw $this->createNotFoundException('Unable to find CustomFieldsGroups entity.');
}
@@ -237,7 +238,7 @@ class CustomFieldsGroupController extends AbstractController
$entity = $em->getRepository(CustomFieldsGroup::class)->find($id);
if (!$entity) {
if (null === $entity) {
throw $this->createNotFoundException('Unable to find CustomFieldsGroup entity.');
}
@@ -260,7 +261,7 @@ class CustomFieldsGroupController extends AbstractController
$entity = $em->getRepository(CustomFieldsGroup::class)->find($id);
if (!$entity) {
if (null === $entity) {
throw $this->createNotFoundException('Unable to find CustomFieldsGroup entity.');
}
@@ -320,7 +321,7 @@ class CustomFieldsGroupController extends AbstractController
*
* @param CustomFieldsGroup $entity The entity
*
* @return \Symfony\Component\Form\Form The form
* @return \Symfony\Component\Form\FormInterface The form
*/
private function createCreateForm(CustomFieldsGroup $entity)
{
@@ -338,10 +339,8 @@ class CustomFieldsGroupController extends AbstractController
* Creates a form to edit a CustomFieldsGroup entity.
*
* @param CustomFieldsGroup $entity The entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createEditForm(CustomFieldsGroup $entity)
private function createEditForm(CustomFieldsGroup $entity): FormInterface
{
$form = $this->createForm(CustomFieldsGroupType::class, $entity, [
'action' => $this->generateUrl('customfieldsgroup_update', ['id' => $entity->getId()]),
@@ -354,10 +353,8 @@ class CustomFieldsGroupController extends AbstractController
/**
* create a form to make the group default.
*
* @return \Symfony\Component\Form\Form
*/
private function createMakeDefaultForm(?CustomFieldsGroup $group = null): \Symfony\Component\Form\FormInterface
private function createMakeDefaultForm(?CustomFieldsGroup $group = null): FormInterface
{
return $this->createFormBuilder($group, [
'method' => 'POST',

View File

@@ -82,7 +82,7 @@ class CustomField
*/
public function getName($locale = null)
{
if ($locale) {
if (null !== $locale) {
if (isset($this->name[$locale])) {
return $this->name[$locale];
}

View File

@@ -72,7 +72,7 @@ class CustomFieldType extends AbstractType
// check if the customField object is "new"
// If no data is passed to the form, the data is "null".
// This should be considered a new "customField"
if (!$customField || null === $customField->getId()) {
if (null === $customField || null === $customField->getId()) {
$form->add('slug', TextType::class);
}
});

View File

@@ -29,7 +29,7 @@ class CustomFieldsGroupToIdTransformer implements DataTransformerInterface
*/
public function reverseTransform($id): ?CustomFieldsGroup
{
if (!$id) {
if (null === $id) {
return null;
}

View File

@@ -72,7 +72,7 @@ final class EventController extends AbstractController
'id' => $event_id,
]);
if (!$event) {
if (null === $event) {
throw $this->createNotFoundException('Unable to find this event.');
}
@@ -273,10 +273,6 @@ final class EventController extends AbstractController
#[\Symfony\Component\Routing\Attribute\Route(path: '/{_locale}/event/event/{event_id}/show', name: 'chill_event__event_show')]
public function showAction(Event $event, Request $request)
{
if (!$event) {
throw $this->createNotFoundException('Unable to find Event entity.');
}
$this->denyAccessUnlessGranted(
EventVoter::SEE_DETAILS,
$event,
@@ -308,7 +304,7 @@ final class EventController extends AbstractController
$entity = $em->getRepository(Event::class)->find($event_id);
if (!$entity) {
if (null === $entity) {
throw $this->createNotFoundException('Unable to find Event entity.');
}

View File

@@ -58,7 +58,7 @@ class EventTypeController extends AbstractController
$entity = $em->getRepository(EventType::class)->find($id);
if (!$entity) {
if (null === $entity) {
throw $this->createNotFoundException('Unable to find EventType entity.');
}
@@ -110,7 +110,7 @@ class EventTypeController extends AbstractController
$entity = $em->getRepository(EventType::class)->find($id);
if (!$entity) {
if (null === $entity) {
throw $this->createNotFoundException('Unable to find EventType entity.');
}
@@ -134,7 +134,7 @@ class EventTypeController extends AbstractController
*
* @param EventType $entity The entity
*
* @return \Symfony\Component\Form\Form The form
* @return \Symfony\Component\Form\FormInterface The form
*/
private function createCreateForm(EventType $entity)
{
@@ -153,7 +153,7 @@ class EventTypeController extends AbstractController
*
* @param EventType $entity The entity
*
* @return \Symfony\Component\Form\Form The form
* @return \Symfony\Component\Form\FormInterface The form
*/
private function createEditForm(EventType $entity)
{

View File

@@ -250,7 +250,7 @@ final class ParticipationController extends AbstractController
'id' => $participation_id,
]);
if (!$participation) {
if (null === $participation) {
throw $this->createNotFoundException('Unable to find participation.');
}

View File

@@ -58,7 +58,7 @@ class RoleController extends AbstractController
$entity = $em->getRepository(Role::class)->find($id);
if (!$entity) {
if (null === $entity) {
throw $this->createNotFoundException('Unable to find Role entity.');
}
@@ -110,7 +110,7 @@ class RoleController extends AbstractController
$entity = $em->getRepository(Role::class)->find($id);
if (!$entity) {
if (null === $entity) {
throw $this->createNotFoundException('Unable to find Role entity.');
}
@@ -134,7 +134,7 @@ class RoleController extends AbstractController
*
* @param Role $entity The entity
*
* @return \Symfony\Component\Form\Form The form
* @return \Symfony\Component\Form\FormInterface The form
*/
private function createCreateForm(Role $entity)
{
@@ -153,7 +153,7 @@ class RoleController extends AbstractController
*
* @param Role $entity The entity
*
* @return \Symfony\Component\Form\Form The form
* @return \Symfony\Component\Form\FormInterface The form
*/
private function createEditForm(Role $entity)
{

View File

@@ -58,7 +58,7 @@ class StatusController extends AbstractController
$entity = $em->getRepository(Status::class)->find($id);
if (!$entity) {
if (null === $entity) {
throw $this->createNotFoundException('Unable to find Status entity.');
}
@@ -110,7 +110,7 @@ class StatusController extends AbstractController
$entity = $em->getRepository(Status::class)->find($id);
if (!$entity) {
if (null === $entity) {
throw $this->createNotFoundException('Unable to find Status entity.');
}
@@ -134,7 +134,7 @@ class StatusController extends AbstractController
*
* @param Status $entity The entity
*
* @return \Symfony\Component\Form\Form The form
* @return \Symfony\Component\Form\FormInterface The form
*/
private function createCreateForm(Status $entity)
{
@@ -153,7 +153,7 @@ class StatusController extends AbstractController
*
* @param Status $entity The entity
*
* @return \Symfony\Component\Form\Form The form
* @return \Symfony\Component\Form\FormInterface The form
*/
private function createEditForm(Status $entity)
{

View File

@@ -88,11 +88,11 @@ class LoadAndUpdateLanguagesCommand extends Command
foreach (Languages::getNames() as $code => $lang) {
$excludeCode = (
(
!$input->getOption(self::INCLUDE_REGIONAL_VERSION)
null === $input->getOption(self::INCLUDE_REGIONAL_VERSION)
&& strpos($code, '_')
&& !\in_array($code, $this->regionalVersionToInclude, true)
) || (
!$input->getOption(self::INCLUDE_ANCIENT)
null === $input->getOption(self::INCLUDE_ANCIENT)
&& \in_array($code, $this->ancientToExclude, true)
)
);

View File

@@ -54,7 +54,7 @@ final class PermissionsGroupController extends AbstractController
{
$permissionsGroup = $this->permissionsGroupRepository->find($id);
if (!$permissionsGroup) {
if (null === $permissionsGroup) {
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
}
@@ -157,11 +157,11 @@ final class PermissionsGroupController extends AbstractController
$permissionsGroup = $this->permissionsGroupRepository->find($pgid);
$roleScope = $this->roleScopeRepository->find($rsid);
if (!$permissionsGroup) {
if (null === $permissionsGroup) {
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
}
if (!$roleScope) {
if (null === $roleScope) {
throw $this->createNotFoundException('Unable to find RoleScope entity');
}
@@ -213,7 +213,7 @@ final class PermissionsGroupController extends AbstractController
{
$permissionsGroup = $this->permissionsGroupRepository->find($id);
if (!$permissionsGroup) {
if (null === $permissionsGroup) {
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
}
@@ -288,7 +288,7 @@ final class PermissionsGroupController extends AbstractController
{
$permissionsGroup = $this->permissionsGroupRepository->find($id);
if (!$permissionsGroup) {
if (null === $permissionsGroup) {
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
}
@@ -341,7 +341,7 @@ final class PermissionsGroupController extends AbstractController
$permissionsGroup = $this->permissionsGroupRepository
->find($id);
if (!$permissionsGroup) {
if (null === $permissionsGroup) {
throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
}

View File

@@ -57,7 +57,7 @@ class UserController extends CRUDController
$user = $em->getRepository(User::class)->find($uid);
if (!$user) {
if (null === $user) {
throw $this->createNotFoundException('Unable to find User entity.');
}
@@ -110,14 +110,14 @@ class UserController extends CRUDController
$user = $em->getRepository(User::class)->find($uid);
if (!$user) {
if (null === $user) {
throw $this->createNotFoundException('Unable to find User entity.');
}
$groupCenter = $em->getRepository(GroupCenter::class)
->find($gcid);
if (!$groupCenter) {
if (null === $groupCenter) {
throw $this->createNotFoundException('Unable to find groupCenter entity');
}
@@ -434,7 +434,7 @@ class UserController extends CRUDController
'permissionsGroup' => $permissionsGroup,
]);
if (!$groupCenterManaged) {
if (null === $groupCenterManaged) {
$groupCenter = new GroupCenter();
$groupCenter->setCenter($center);
$groupCenter->setPermissionsGroup($permissionsGroup);

View File

@@ -36,7 +36,7 @@ class AddressType extends AbstractType
{
$builder
->add('street', TextType::class, [
'required' => !$options['has_no_address'], // true if has no address is false
'required' => false === $options['has_no_address'], // true if has no address is false
])
->add('streetNumber', TextType::class, [
'required' => false,
@@ -44,10 +44,10 @@ class AddressType extends AbstractType
->add('postCode', PostalCodeType::class, [
'label' => 'Postal code',
'placeholder' => 'Choose a postal code',
'required' => !$options['has_no_address'], // true if has no address is false
'required' => false === $options['has_no_address'], // true if has no address is false
]);
if ($options['has_valid_from']) {
if (true === $options['has_valid_from']) {
$builder
->add(
'validFrom',
@@ -58,7 +58,7 @@ class AddressType extends AbstractType
);
}
if ($options['has_no_address']) {
if (true === $options['has_no_address']) {
$builder
->add('isNoAddress', ChoiceType::class, [
'required' => true,

View File

@@ -30,7 +30,7 @@ final class ChillTextareaType extends AbstractType
{
public function buildView(FormView $view, FormInterface $form, array $options): void
{
if (!$options['disable_editor']) {
if (false === $options['disable_editor']) {
$view->vars['attr']['ckeditor'] = true;
}
}

View File

@@ -113,7 +113,7 @@ class UserType extends AbstractType
]);
// @phpstan-ignore-next-line
if ($options['is_creation'] && $this->parameterBag->get('chill_main.access_user_change_password')) {
if ((true === $options['is_creation']) && $this->parameterBag->get('chill_main.access_user_change_password')) {
$builder->add('plainPassword', RepeatedType::class, [
'mapped' => false,
'type' => PasswordType::class,

View File

@@ -96,12 +96,12 @@ class SearchApiQuery
{
$isMultiple = \count($this->whereClauses);
$where =
($isMultiple ? '(' : '').
($isMultiple > 0 ? '(' : '').
\implode(
($isMultiple ? ')' : '').' AND '.($isMultiple ? '(' : ''),
($isMultiple > 0 ? ')' : '').' AND '.($isMultiple > 0 ? '(' : ''),
$this->whereClauses
).
($isMultiple ? ')' : '');
($isMultiple > 0 ? ')' : '');
$select = $this->buildSelectClause($countOnly);

View File

@@ -79,7 +79,7 @@ final class ChillPersonMoveCommand extends Command
$sqls = $this->mover->getSQL($from, $to, $deleteEntities);
if ($input->getOption('dump-sql')) {
if (true === $input->getOption('dump-sql')) {
foreach ($sqls as $sql) {
$output->writeln($sql);
}

View File

@@ -33,7 +33,7 @@ class AccompanyingPeriodWorkDuplicateController extends AbstractController
* @ParamConverter("accompanyingPeriodWork", options={"id": "acpw_id"})
*/
#[Route(path: '{_locale}/person/accompanying-period/work/{id}/assign-duplicate', name: 'chill_person_accompanying_period_work_assign_duplicate')]
public function assignDuplicate(AccompanyingPeriodWork $acpw, Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
public function assignDuplicate(AccompanyingPeriodWork $acpw, Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|Response
{
$accompanyingPeriod = $acpw->getAccompanyingPeriod();
@@ -80,7 +80,7 @@ class AccompanyingPeriodWorkDuplicateController extends AbstractController
* @ParamConverter("acpw2", options={"id": "acpw2_id"})
*/
#[Route(path: '/{_locale}/person/{acpw1_id}/acpw-duplicate/{acpw2_id}/confirm', name: 'chill_person_acpw_duplicate_confirm')]
public function confirmAction(AccompanyingPeriodWork $acpw1, AccompanyingPeriodWork $acpw2, Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
public function confirmAction(AccompanyingPeriodWork $acpw1, AccompanyingPeriodWork $acpw2, Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|Response
{
$accompanyingPeriod = $acpw1->getAccompanyingPeriod();

View File

@@ -217,7 +217,7 @@ class PersonAddressController extends AbstractController
}
/**
* @return \Symfony\Component\Form\Form
* @return \Symfony\Component\Form\FormInterface
*/
protected function createCreateForm(Person $person, Address $address)
{
@@ -237,7 +237,7 @@ class PersonAddressController extends AbstractController
}
/**
* @return \Symfony\Component\Form\Form
* @return \Symfony\Component\Form\FormInterface
*/
protected function createEditForm(Person $person, Address $address)
{

View File

@@ -608,7 +608,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
*/
public function containsAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool
{
return ($this->participationsContainAccompanyingPeriod($accompanyingPeriod)) ? false : true;
return null === $this->participationsContainAccompanyingPeriod($accompanyingPeriod);
}
/**
@@ -1428,7 +1428,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
{
$participation = $this->participationsContainAccompanyingPeriod($accompanyingPeriod);
if (!null === $participation) {
if (null !== $participation) {
$participation->setEndDate(new \DateTime());
$this->accompanyingPeriodParticipations->removeElement($participation);
}

View File

@@ -229,7 +229,7 @@ class PersonType extends AbstractType
'by_reference' => false,
]);
if ($options['cFGroup']) {
if (true === $options['cFGroup']) {
$builder
->add(
'cFData',

View File

@@ -28,7 +28,7 @@ class PersonAltNameType extends AbstractType
foreach ($this->getKeyChoices() as $label => $key) {
$builder->add(
$key,
$options['force_hidden'] ? HiddenType::class : TextType::class,
true === $options['force_hidden'] ? HiddenType::class : TextType::class,
[
'label' => $label,
'required' => false,

View File

@@ -45,7 +45,7 @@ class PersonPhoneType extends AbstractType
$oldPersonPhone = $this->em->getUnitOfWork()
->getOriginalEntityData($event->getData());
if ($oldPersonPhone['phonenumber'] ?? null !== $event->getForm()->getData()->getPhonenumber()) {
if (($oldPersonPhone['phonenumber'] ?? null) !== $event->getForm()->getData()->getPhonenumber()) {
$type = $this->phonenumberHelper->getType($event->getData()->getPhonenumber());
$event->getData()->setType($type);
}

View File

@@ -100,7 +100,7 @@ class SimilarPersonMatcher
$notDuplicatePersons = $this->personNotDuplicateRepository->findNotDuplicatePerson($person);
if (\count($notDuplicatePersons)) {
if (count($notDuplicatePersons) > 0) {
$qb->andWhere($qb->expr()->notIn('p.id', ':notDuplicatePersons'));
$qb->setParameter('notDuplicatePersons', $notDuplicatePersons);
}

View File

@@ -171,8 +171,8 @@ class MembersEditorNormalizer implements DenormalizerAwareInterface, Denormalize
private function performChecks($data): void
{
if (
null === $data['concerned'] ?? null
&& false === \is_array('concerned')
!isset($data['concerned'])
|| !\is_array($data['concerned'])
) {
throw new Exception\UnexpectedValueException("The schema does not have any key 'concerned'");
}

View File

@@ -210,9 +210,21 @@ class PersonJsonNormalizer implements DenormalizerAwareInterface, NormalizerAwar
return $data;
}
return [...$data, 'centers' => $this->normalizer->normalize($this->centerResolverManager->resolveCenters($person), $format, $context), 'altNames' => $this->normalizeAltNames($person->getAltNames()), 'current_household_id' => $household ? $this->normalizer->normalize($household->getId(), $format, $context) : null, 'current_residential_addresses' => $currentResidentialAddresses ?
$this->normalizer->normalize($currentResidentialAddresses, $format, $context) :
null];
return [
...$data,
'centers' => $this->normalizer->normalize(
$this->centerResolverManager->resolveCenters($person),
$format,
$context
),
'altNames' => $this->normalizeAltNames($person->getAltNames()),
'current_household_id' => $household !== null ?
$this->normalizer->normalize($household->getId(), $format, $context) :
null,
'current_residential_addresses' => $currentResidentialAddresses !== [] ?
$this->normalizer->normalize($currentResidentialAddresses, $format, $context) :
null
];
}
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool

View File

@@ -21,6 +21,8 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -46,8 +48,6 @@ class ReportController extends AbstractController
* @param int $person_id the id of the person
* @param int $cf_group_id the id of the report type
* @param Request $request The request containing the form data (from the newAction)
*
* @return Response the web page
*/
public function createAction($person_id, $cf_group_id, Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
{
@@ -105,17 +105,15 @@ class ReportController extends AbstractController
*
* @param int|string $person_id the id of the person
* @param int|string $report_id the id of the report
*
* @return Response the web page
*/
public function editAction(int|string $person_id, int|string $report_id): \Symfony\Component\HttpFoundation\Response
{
$em = $this->managerRegistry->getManager();
/** @var Report $report */
$report = $em->getRepository('ChillReportBundle:Report')->find($report_id);
$report = $em->getRepository(Report::class)->find($report_id);
if (!$report) {
if (null == $report) {
throw $this->createNotFoundException($this->translator->trans('Unable to find this report.'));
}
@@ -147,17 +145,15 @@ class ReportController extends AbstractController
*
* @param int $cf_group_id The id of the report type to export
* @param Request $request The request
*
* @return A csv file with all the reports of the selected type
*/
public function exportAction($cf_group_id, Request $request)
public function exportAction($cf_group_id, Request $request): \Symfony\Component\HttpFoundation\Response
{
$em = $this->managerRegistry->getManager();
$cFGroup = $em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class)->find($cf_group_id);
$reports = $em->getRepository('ChillReportBundle:Report')->findByCFGroup($cFGroup);
$reports = $em->getRepository(Report::class)->findByCFGroup($cFGroup);
$response = $this->render('ChillReportBundle:Report:export.csv.twig', [
$response = $this->render('@ChillReport/Report/export.csv.twig', [
'reports' => $reports,
'cf_group' => $cFGroup,
]);
@@ -173,8 +169,6 @@ class ReportController extends AbstractController
*
* @param int $person_id the id of the person
* @param Request $request The request
*
* @return Response the web page
*/
public function listAction($person_id, Request $request): \Symfony\Component\HttpFoundation\Response
{
@@ -192,8 +186,7 @@ class ReportController extends AbstractController
);
$total = $em
->createQuery('SELECT COUNT(r.id) FROM ChillReportBundle:Report r '
.'WHERE r.person = :person AND r.scope IN (:scopes) ')
->createQuery('SELECT COUNT(r.id) FROM '.Report::class.' r WHERE r.person = :person AND r.scope IN (:scopes) ')
->setParameter('person', $person)
->setParameter('scopes', $reachableScopes)
->getSingleScalarResult();
@@ -202,7 +195,7 @@ class ReportController extends AbstractController
$paginator = $this->paginator->create($total);
$reports = $em->createQuery('SELECT r
FROM ChillReportBundle:Report r
FROM '.Report::class.' r
WHERE r.person = :person AND r.scope IN (:scopes)
ORDER BY r.date DESC')
->setParameter('person', $person)
@@ -230,8 +223,6 @@ class ReportController extends AbstractController
* @param int $person_id the id of the person
* @param int $cf_group_id the id of the report type
* @param Request $request The request
*
* @return Response the web page
*/
public function newAction($person_id, $cf_group_id, Request $request): \Symfony\Component\HttpFoundation\Response
{
@@ -278,8 +269,6 @@ class ReportController extends AbstractController
*
* @param int $person_id the id of the person
* @param Request $request The request
*
* @return Response the web page
*/
public function selectReportTypeAction($person_id, Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
{
@@ -342,8 +331,6 @@ class ReportController extends AbstractController
* (a csv file with all the report of this type).
*
* @param Request $request The request
*
* @return Response the web page
*/
public function selectReportTypeForExportAction(Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
{
@@ -389,16 +376,14 @@ class ReportController extends AbstractController
*
* @param int $person_id the id of the person
* @param int $report_id the id of the report
*
* @return Response the web page
*/
public function updateAction($person_id, $report_id, Request $request): \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
{
$em = $this->managerRegistry->getManager();
$report = $em->getRepository('ChillReportBundle:Report')->find($report_id);
$report = $em->getRepository(Report::class)->find($report_id);
if (!$report) {
if (null === $report) {
throw $this->createNotFoundException($this->translator->trans('Unable to find this report.'));
}
@@ -445,8 +430,6 @@ class ReportController extends AbstractController
*
* @param int $report_id the id of the report
* @param int $person_id the id of the person
*
* @return Response the web page
*/
public function viewAction($report_id, $person_id): \Symfony\Component\HttpFoundation\Response
{
@@ -454,9 +437,9 @@ class ReportController extends AbstractController
$person = $em->getRepository(Person::class)->find($person_id);
$entity = $em->getRepository('ChillReportBundle:Report')->find($report_id);
$entity = $em->getRepository(Report::class)->find($report_id);
if (!$entity || !$person) {
if (null === $entity || null === $person) {
throw $this->createNotFoundException($this->translator->trans('Unable to find this report.'));
}
@@ -479,10 +462,8 @@ class ReportController extends AbstractController
* Creates a form to create a Report entity.
*
* @param Report $entity The entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createCreateForm(Report $entity, Person $person, mixed $cFGroup): \Symfony\Component\Form\FormInterface
private function createCreateForm(Report $entity, Person $person, mixed $cFGroup): FormInterface
{
return $this->createForm(ReportType::class, $entity, [
'action' => $this->generateUrl(
@@ -501,10 +482,8 @@ class ReportController extends AbstractController
* Creates a form to edit a Report entity.
*
* @param Report $entity the report to edit
*
* @return \Symfony\Component\Form\Form The form
*/
private function createEditForm(Report $entity): \Symfony\Component\Form\FormInterface
private function createEditForm(Report $entity): FormInterface
{
return $this->createForm(ReportType::class, $entity, [
'action' => $this->generateUrl(

View File

@@ -48,7 +48,7 @@ class TimelineReportProvider implements TimelineProviderInterface
public function getEntities(array $ids)
{
$reports = $this->em->getRepository('ChillReportBundle:Report')
$reports = $this->em->getRepository(Report::class)
->findBy(['id' => $ids]);
$result = [];

View File

@@ -81,7 +81,7 @@ class SingleTaskListType extends AbstractType
'label' => 'Assignee',
]);
if ($options['add_status']) {
if (true === $options['add_status']) {
$builder
->add('status', ChoiceType::class, [
'choices' => $statuses,
@@ -91,7 +91,7 @@ class SingleTaskListType extends AbstractType
]);
}
if ($options['add_type']) {
if (true === $options['add_type']) {
$types = $this->getTaskTypesChoices($options);
if (\count($types) > 0) {