cs: Fix code-style (using PHPCSFixer and PHPCS).

This commit is contained in:
Pol Dellaiera
2021-12-21 10:59:23 +01:00
parent b7360955f7
commit 8401ce2656
280 changed files with 742 additions and 319 deletions

View File

@@ -17,6 +17,7 @@ use Chill\PersonBundle\Entity\Person;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\ClassMetadata;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use function array_merge;
use function implode;
use function in_array;

View File

@@ -16,6 +16,7 @@ use Chill\PersonBundle\Entity\Person;
use Doctrine\ORM\QueryBuilder;
use Exception;
use Symfony\Component\HttpFoundation\Request;
use function array_merge;
/**

View File

@@ -20,6 +20,7 @@ use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use function ctype_digit;
final class ChillPersonMoveCommand extends Command

View File

@@ -39,6 +39,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\FormFactoryInterface;
use function array_key_exists;
use function count;
use function file_get_contents;
@@ -46,6 +47,7 @@ use function get_class;
use function in_array;
use function is_array;
use function json_decode;
use const JSON_PRETTY_PRINT;
use const LC_TIME;
@@ -417,13 +419,15 @@ final class ImportPeopleFromCSVCommand extends Command
$line = $this->line = 1;
try {
while (false !== ($row = fgetcsv(
$csv,
$input->getOption('length'),
$input->getOption('delimiter'),
$input->getOption('enclosure'),
$input->getOption('escape')
))) {
while (
false !== ($row = fgetcsv(
$csv,
$input->getOption('length'),
$input->getOption('delimiter'),
$input->getOption('enclosure'),
$input->getOption('escape')
))
) {
$this->logger->debug('Processing line ' . $this->line);
if (1 === $line) {
@@ -450,8 +454,10 @@ final class ImportPeopleFromCSVCommand extends Command
$this->eventDispatcher->dispatch('chill_person.person_import', $event);
if ($this->input->getOption('force') === true
&& false === $event->skipPerson) {
if (
$this->input->getOption('force') === true
&& false === $event->skipPerson
) {
$this->em->persist($person);
}
@@ -602,8 +608,10 @@ final class ImportPeopleFromCSVCommand extends Command
->getResult();
if (count($postalCodes) >= 1) {
if ($postalCodes[0]->getCode() === $postalCode
&& $postalCodes[0]->getName() === $locality) {
if (
$postalCodes[0]->getCode() === $postalCode
&& $postalCodes[0]->getName() === $locality
) {
return $postalCodes[0];
}
}
@@ -625,7 +633,7 @@ final class ImportPeopleFromCSVCommand extends Command
$question = new ChoiceQuestion(
sprintf(
'Which postal code match the '
. 'name "%s" with postal code "%s" ? (default to "%s")',
. 'name "%s" with postal code "%s" ? (default to "%s")',
$locality,
$postalCode,
$names[0]
@@ -658,13 +666,15 @@ final class ImportPeopleFromCSVCommand extends Command
$csv = $this->openCSV();
// getting the first row
if (false !== ($row = fgetcsv(
$csv,
$input->getOption('length'),
$input->getOption('delimiter'),
$input->getOption('enclosure'),
$input->getOption('escape')
))) {
if (
false !== ($row = fgetcsv(
$csv,
$input->getOption('length'),
$input->getOption('delimiter'),
$input->getOption('enclosure'),
$input->getOption('escape')
))
) {
try {
$this->matchColumnToCustomField($row);
} finally {
@@ -863,7 +873,9 @@ final class ImportPeopleFromCSVCommand extends Command
if (!isset($this->cacheAnswersMapping[$cf->getSlug()][$value])) {
// try to find the answer (with array_keys and a search value
$values = array_keys(
array_map(static function ($label) { return trim(strtolower($label)); }, $answers),
array_map(static function ($label) {
return trim(strtolower($label));
}, $answers),
trim(strtolower($value)),
true
);

View File

@@ -38,6 +38,7 @@ 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;

View File

@@ -1,5 +1,14 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\PersonBundle\Controller;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
@@ -12,10 +21,10 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use function array_key_exists;
class AccompanyingCourseCommentController extends Controller
{
/**
* Comments page of Accompanying Course section.
*
@@ -37,6 +46,7 @@ class AccompanyingCourseCommentController extends Controller
}
}
$pinnedComment = $accompanyingCourse->getPinnedComment();
if ($pinnedComment->getId() === $request->query->getInt('edit')) {
$editForm = $this->createCommentForm($pinnedComment, 'edit');
$commentEditId = $pinnedComment->getId();
@@ -54,6 +64,7 @@ class AccompanyingCourseCommentController extends Controller
if ($currentForm->isSubmitted() && $currentForm->isValid()) {
$em = $this->getDoctrine()->getManager();
if ($isEditingNew) {
$em->persist($newComment);
}
@@ -61,7 +72,7 @@ class AccompanyingCourseCommentController extends Controller
}
return $this->redirectToRoute('chill_person_accompanying_period_comment_list', [
'accompanying_period_id' => $accompanyingCourse->getId()
'accompanying_period_id' => $accompanyingCourse->getId(),
]);
}
@@ -78,7 +89,7 @@ class AccompanyingCourseCommentController extends Controller
$form = $this->createForm(AccompanyingCourseCommentType::class, $comment);
if ('edit' === $step) {
$form->add('edit', HiddenType::class, ['mapped' => false ]);
$form->add('edit', HiddenType::class, ['mapped' => false]);
}
return $form;

View File

@@ -30,6 +30,7 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Component\Workflow\Registry;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function is_array;
/**

View File

@@ -67,7 +67,7 @@ class AccompanyingCourseWorkController extends AbstractController
'error',
$this->trans->trans(
'accompanying_work.You must add at least ' .
'one social issue on accompanying period'
'one social issue on accompanying period'
)
);

View File

@@ -27,6 +27,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;
@@ -170,8 +171,10 @@ class AccompanyingPeriodController extends AbstractController
$errors = $this->_validatePerson($person);
$flashBag = $this->get('session')->getFlashBag();
if ($form->isValid(['Default', 'closed'])
&& count($errors) === 0) {
if (
$form->isValid(['Default', 'closed'])
&& count($errors) === 0
) {
$em = $this->getDoctrine()->getManager();
$em->persist($accompanyingPeriod);
$em->flush();
@@ -405,8 +408,10 @@ class AccompanyingPeriodController extends AbstractController
$errors = $this->_validatePerson($person);
$flashBag = $this->get('session')->getFlashBag();
if ($form->isValid(['Default', 'closed'])
&& count($errors) === 0) {
if (
$form->isValid(['Default', 'closed'])
&& count($errors) === 0
) {
$em->flush();
$flashBag->add(

View File

@@ -22,6 +22,7 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\SerializerInterface;
use function count;
use function in_array;

View File

@@ -24,6 +24,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use function array_filter;
use function array_values;
@@ -93,8 +94,10 @@ class HouseholdApiController extends ApiController
$addresses[$a->getId()] = $a;
}
if (null !== $personLocation = $participation
->getAccompanyingPeriod()->getPersonLocation()) {
if (
null !== $personLocation = $participation
->getAccompanyingPeriod()->getPersonLocation()
) {
$a = $personLocation->getCurrentHouseholdAddress();
if (null !== $a) {

View File

@@ -25,6 +25,7 @@ use Symfony\Component\Security\Core\Security;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Translation\TranslatorInterface;
use function array_key_exists;
use function count;

View File

@@ -27,6 +27,7 @@ use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Serializer\Exception;
use Symfony\Component\Translation\TranslatorInterface;
use function count;
class HouseholdMemberController extends ApiController
@@ -186,7 +187,7 @@ class HouseholdMemberController extends ApiController
$_format,
['groups' => ['read']]
);
} catch (Exception\InvalidArgumentException | Exception\UnexpectedValueException $e) {
} catch (Exception\InvalidArgumentException|Exception\UnexpectedValueException $e) {
throw new BadRequestException("Deserialization error: {$e->getMessage()}", 45896, $e);
}

View File

@@ -18,6 +18,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use function count;
/**

View File

@@ -20,6 +20,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use function array_filter;
use function array_values;

View File

@@ -32,6 +32,7 @@ use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use function count;
use function hash;
use function implode;
@@ -207,8 +208,10 @@ final class PersonController extends AbstractController
{
$person = new Person();
if (1 === count($this->security->getUser()
->getGroupCenters())) {
if (
1 === count($this->security->getUser()
->getGroupCenters())
) {
$person->setCenter(
$this->security->getUser()
->getGroupCenters()[0]
@@ -227,8 +230,10 @@ final class PersonController extends AbstractController
if ($request->getMethod() === Request::METHOD_GET) {
$this->lastPostDataReset();
} elseif ($request->getMethod() === Request::METHOD_POST
&& $form->isValid()) {
} elseif (
$request->getMethod() === Request::METHOD_POST
&& $form->isValid()
) {
$alternatePersons = $this->similarPersonMatcher
->matchPerson($person);

View File

@@ -29,6 +29,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Translation\TranslatorInterface;
use function count;
class PersonDuplicateController extends Controller

View File

@@ -17,6 +17,7 @@ use Chill\MainBundle\Serializer\Model\Collection;
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use function count;
class SocialWorkSocialActionApiController extends ApiController

View File

@@ -13,6 +13,7 @@ namespace Chill\PersonBundle\DataFixtures\Helper;
use Chill\PersonBundle\Entity\Person;
use Doctrine\ORM\EntityManagerInterface;
use function array_pop;
use function random_int;

View File

@@ -13,6 +13,7 @@ namespace Chill\PersonBundle\DataFixtures\Helper;
use Chill\PersonBundle\Entity\Person;
use Doctrine\ORM\EntityManagerInterface;
use function random_int;
trait RandomPersonHelperTrait

View File

@@ -14,7 +14,6 @@ namespace Chill\PersonBundle\DataFixtures\ORM;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager;
/**

View File

@@ -19,6 +19,7 @@ use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
use Chill\PersonBundle\Repository\SocialWork\EvaluationRepository;
use DateTimeImmutable;
use Doctrine\Persistence\ObjectManager;
use function array_pop;
use function array_rand;
use function count;

View File

@@ -28,7 +28,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
class LoadCustomFields extends AbstractFixture implements
ContainerAwareInterface,
ContainerAwareInterface,
OrderedFixtureInterface
{
/**
@@ -115,7 +115,9 @@ class LoadCustomFields extends AbstractFixture implements
// get possible values for cfGroup
$choices = array_map(
static function ($a) { return $a['slug']; },
static function ($a) {
return $a['slug'];
},
$this->customFieldChoice->getOptions()['choices']
);
// create faker

View File

@@ -25,6 +25,7 @@ use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ObjectManager;
use Nelmio\Alice\Loader\NativeLoader;
use function array_pop;
use function array_rand;
use function random_int;

View File

@@ -31,8 +31,10 @@ class LoadHouseholdPosition extends Fixture
public function load(ObjectManager $manager)
{
foreach (self::POSITIONS_DATA as [$name, $share, $allowHolder,
$ordering, $ref, ]) {
foreach (
self::POSITIONS_DATA as [$name, $share, $allowHolder,
$ordering, $ref, ]
) {
$position = (new Position())
->setLabel(['fr' => $name])
->setAllowHolder($allowHolder)

View File

@@ -42,6 +42,7 @@ use Nelmio\Alice\Loader\NativeLoader;
use Nelmio\Alice\ObjectSet;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\Workflow\Registry;
use function count;
use function random_int;
use function ucfirst;

View File

@@ -20,6 +20,7 @@ use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ObjectManager;
use function count;
class LoadRelationships extends Fixture implements DependentFixtureInterface

View File

@@ -23,6 +23,7 @@ use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use function array_key_exists;
/**

View File

@@ -13,6 +13,7 @@ namespace Chill\PersonBundle\DependencyInjection\CompilerPass;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use function in_array;
/**

View File

@@ -42,8 +42,10 @@ use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Component\Validator\GroupSequenceProviderInterface;
use UnexpectedValueException;
use function count;
use function in_array;
use const SORT_REGULAR;
/**
@@ -533,8 +535,10 @@ class AccompanyingPeriod implements
public function getCenters(): ?iterable
{
foreach ($this->getPersons() as $person) {
if (!in_array($person->getCenter(), $centers ?? [], true)
&& null !== $person->getCenter()) {
if (
!in_array($person->getCenter(), $centers ?? [], true)
&& null !== $person->getCenter()
) {
$centers[] = $person->getCenter();
}
}

View File

@@ -410,8 +410,10 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
*/
public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self
{
if ($this->accompanyingPeriod instanceof AccompanyingPeriod
&& $accompanyingPeriod !== $this->accompanyingPeriod) {
if (
$this->accompanyingPeriod instanceof AccompanyingPeriod
&& $accompanyingPeriod !== $this->accompanyingPeriod
) {
throw new LogicException('A work cannot change accompanyingPeriod');
}

View File

@@ -268,7 +268,8 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
if (
$accompanyingPeriodWork instanceof AccompanyingPeriodWork
&& $this->accompanyingPeriodWork instanceof AccompanyingPeriodWork
&& $this->accompanyingPeriodWork->getId() !== $accompanyingPeriodWork->getId()) {
&& $this->accompanyingPeriodWork->getId() !== $accompanyingPeriodWork->getId()
) {
throw new RuntimeException('Changing the ' .
'accompanyingPeriodWork is not allowed');
}

View File

@@ -144,8 +144,10 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
{
// if an evaluation is already associated, we cannot change the association (removing the association,
// by setting a null value, is allowed.
if ($this->accompanyingPeriodWorkEvaluation instanceof AccompanyingPeriodWorkEvaluation
&& $accompanyingPeriodWorkEvaluation instanceof AccompanyingPeriodWorkEvaluation) {
if (
$this->accompanyingPeriodWorkEvaluation instanceof AccompanyingPeriodWorkEvaluation
&& $accompanyingPeriodWorkEvaluation instanceof AccompanyingPeriodWorkEvaluation
) {
if ($this->accompanyingPeriodWorkEvaluation !== $accompanyingPeriodWorkEvaluation) {
throw new RuntimeException('It is not allowed to change the evaluation for a document');
}

View File

@@ -117,7 +117,8 @@ class AccompanyingPeriodWorkGoal
public function setAccompanyingPeriodWork(?AccompanyingPeriodWork $accompanyingPeriodWork): self
{
if ($this->accompanyingPeriodWork instanceof AccompanyingPeriodWork
if (
$this->accompanyingPeriodWork instanceof AccompanyingPeriodWork
&& $accompanyingPeriodWork !== $this->accompanyingPeriodWork
&& null !== $accompanyingPeriodWork
) {

View File

@@ -24,6 +24,7 @@ use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function count;
/**
@@ -254,7 +255,9 @@ class Household
public function getCurrentPersons(?DateTimeImmutable $now = null): Collection
{
return $this->getCurrentMembers($now)
->map(static function (HouseholdMember $m) { return $m->getPerson(); });
->map(static function (HouseholdMember $m) {
return $m->getPerson();
});
}
public function getId(): ?int

View File

@@ -13,6 +13,7 @@ namespace Chill\PersonBundle\EventListener;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\PersonAltName;
use const MB_CASE_TITLE;
class PersonEventListener

View File

@@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Export;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use function in_array;
class AbstractAccompanyingPeriodExportElement

View File

@@ -90,7 +90,9 @@ class CountPerson implements ExportInterface
*/
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$centers = array_map(static function ($el) { return $el['center']; }, $acl);
$centers = array_map(static function ($el) {
return $el['center'];
}, $acl);
$qb = $this->entityManager->createQueryBuilder();

View File

@@ -32,6 +32,7 @@ use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function addcslashes;
use function array_key_exists;
use function array_keys;
@@ -266,7 +267,9 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$centers = array_map(static function ($el) { return $el['center']; }, $acl);
$centers = array_map(static function ($el) {
return $el['center'];
}, $acl);
// throw an error if any fields are present
if (!array_key_exists('fields', $data)) {

View File

@@ -20,6 +20,7 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function array_filter;
use function count;
use function implode;

View File

@@ -16,6 +16,7 @@ use Chill\PersonBundle\Repository\PersonRepository;
use RuntimeException;
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
use function call_user_func;
use function count;
use function in_array;
@@ -76,8 +77,10 @@ class PersonChoiceLoader implements ChoiceLoaderInterface
$person = $this->personRepository->find($value);
if ($this->hasCenterFilter()
&& !in_array($person->getCenter(), $this->centers, true)) {
if (
$this->hasCenterFilter()
&& !in_array($person->getCenter(), $this->centers, true)
) {
throw new RuntimeException('chosen a person not in correct center');
}

View File

@@ -16,6 +16,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Form\DataMapperInterface;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use function array_key_exists;
use function is_array;

View File

@@ -14,7 +14,6 @@ namespace Chill\PersonBundle\Form\Type;
use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**

View File

@@ -28,6 +28,7 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInt
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Translation\TranslatorInterface;
use function in_array;
use function is_array;
@@ -161,10 +162,14 @@ class PickPersonType extends AbstractType
. 'option must be an instance of ' . Center::class);
}
if (!in_array($c->getId(), array_map(
static function (Center $c) { return $c->getId(); },
$centers
), true)) {
if (
!in_array($c->getId(), array_map(
static function (Center $c) {
return $c->getId();
},
$centers
), true)
) {
throw new AccessDeniedException('The given center is not reachable');
}
$selectedCenters[] = $c;

View File

@@ -19,6 +19,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use const SORT_FLAG_CASE;
use const SORT_STRING;

View File

@@ -21,6 +21,7 @@ use LogicException;
use Symfony\Component\Validator\ConstraintViolationList;
use Symfony\Component\Validator\ConstraintViolationListInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use function in_array;
use function spl_object_hash;

View File

@@ -82,7 +82,8 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
'order' => 99999,
]);
if ('visible' === $this->showAccompanyingPeriod
if (
'visible' === $this->showAccompanyingPeriod
&& $this->security->isGranted(AccompanyingPeriodVoter::SEE, $parameters['person'])
) {
$menu->addChild($this->translator->trans('Accompanying period list'), [

View File

@@ -33,6 +33,7 @@ namespace Chill\PersonBundle\Privacy;
use Chill\PersonBundle\Entity\Person;
use Symfony\Component\EventDispatcher\Event;
use function count;
/**

View File

@@ -35,6 +35,7 @@ use Chill\PersonBundle\Entity\Person;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use function array_map;
class PrivacyEventSubscriber implements EventSubscriberInterface
@@ -75,7 +76,9 @@ class PrivacyEventSubscriber implements EventSubscriberInterface
$involved = $this->getInvolved();
$involved['period_id'] = $event->getPeriod()->getId();
$involved['persons'] = $event->getPeriod()->getPersons()
->map(static function (Person $p) { return $p->getId(); })
->map(static function (Person $p) {
return $p->getId();
})
->toArray();
$this->logger->notice(
@@ -99,7 +102,9 @@ class PrivacyEventSubscriber implements EventSubscriberInterface
if ($event->hasPersons()) {
$involved['persons'] = array_map(
static function (Person $p) { return $p->getId(); },
static function (Person $p) {
return $p->getId();
},
$event->getPersons()
);
}

View File

@@ -16,6 +16,7 @@ use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Security\Core\Security;
use function count;
final class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodACLAwareRepositoryInterface

View File

@@ -17,6 +17,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query\ResultSetMappingBuilder;
use Doctrine\Persistence\ObjectRepository;
use function strtr;
final class HouseholdRepository implements ObjectRepository

View File

@@ -23,6 +23,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\Query;
use Symfony\Component\Security\Core\Security;
use function array_fill;
use function array_map;
use function array_merge;
@@ -316,7 +317,9 @@ final class PersonACLAwareRepository implements PersonACLAwareRepositoryInterfac
),
]
),
array_map(static function (Center $c) {return $c->getId(); }, $authorizedCenters)
array_map(static function (Center $c) {
return $c->getId();
}, $authorizedCenters)
);
}
}

View File

@@ -17,6 +17,7 @@ use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ObjectRepository;
use Exception;
use function count;
use function in_array;
use function str_replace;

View File

@@ -8,6 +8,7 @@
*/
declare(strict_types=1);
/*
* Chill is a software for social workers
*

View File

@@ -18,7 +18,8 @@ use Symfony\Component\HttpFoundation\Request;
// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP'])
if (
isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1'], true) || \PHP_SAPI === 'cli-server')
) {

View File

@@ -28,6 +28,7 @@ use Symfony\Component\Form\Extension\Core\Type\TelType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Templating\EngineInterface;
use function array_fill_keys;
use function array_filter;
use function array_key_exists;
@@ -330,13 +331,17 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
$phoneResults = $this->extractPhonenumberFromPattern->extractPhonenumber($datesResults->getFilteredSubject());
$terms['_default'] = $phoneResults->getFilteredSubject();
if ($datesResults->hasResult() && (!array_key_exists('birthdate', $terms)
|| null !== $terms['birthdate'])) {
if (
$datesResults->hasResult() && (!array_key_exists('birthdate', $terms)
|| null !== $terms['birthdate'])
) {
$terms['birthdate'] = $datesResults->getFound()[0]->format('Y-m-d');
}
if ($phoneResults->hasResult() && (!array_key_exists('phonenumber', $terms)
|| null !== $terms['phonenumber'])) {
if (
$phoneResults->hasResult() && (!array_key_exists('phonenumber', $terms)
|| null !== $terms['phonenumber'])
) {
$terms['phonenumber'] = $phoneResults->getFound()[0];
}

View File

@@ -19,6 +19,7 @@ use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use Chill\PersonBundle\Repository\PersonACLAwareRepositoryInterface;
use Chill\PersonBundle\Repository\PersonRepository;
use Symfony\Component\Security\Core\Security;
use function array_map;
use function count;
use function in_array;

View File

@@ -18,6 +18,7 @@ use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Chill\PersonBundle\Templating\Entity\PersonRender;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use function count;
class SimilarPersonMatcher

View File

@@ -20,6 +20,7 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Security;
use function in_array;
class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
@@ -113,8 +114,10 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
if (AccompanyingPeriod::STEP_DRAFT === $subject->getStep()) {
// only creator can see, edit, delete, etc.
if ($subject->getCreatedBy() === $token->getUser()
|| null === $subject->getCreatedBy()) {
if (
$subject->getCreatedBy() === $token->getUser()
|| null === $subject->getCreatedBy()
) {
return true;
}

View File

@@ -30,6 +30,7 @@ use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
use Symfony\Contracts\Translation\TranslatorInterface;
use function is_array;
class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterface, NormalizerAwareInterface

View File

@@ -21,6 +21,7 @@ use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\ObjectToPopulateTrait;
use function array_key_exists;
use function array_merge;
use function count;

View File

@@ -20,6 +20,7 @@ use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
use Symfony\Component\Serializer\Normalizer\ObjectToPopulateTrait;
use function array_key_exists;
use function array_merge;
use function in_array;

View File

@@ -21,6 +21,7 @@ use Symfony\Component\Serializer\Exception;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use function array_key_exists;
class MembersEditorNormalizer implements DenormalizerAwareInterface, DenormalizerInterface
@@ -152,8 +153,10 @@ class MembersEditorNormalizer implements DenormalizerAwareInterface, Denormalize
private function performChecks($data): void
{
if (null === $data['concerned'] ?? null
&& false === ·\is_array('concerned')) {
if (
null === $data['concerned'] ?? null
&& false === ·\is_array('concerned')
) {
throw new Exception\UnexpectedValueException("The schema does not have any key 'concerned'");
}

View File

@@ -27,6 +27,7 @@ use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
use Symfony\Contracts\Translation\TranslatorInterface;
use function array_map;
use function implode;

View File

@@ -37,7 +37,9 @@ class SocialIssueNormalizer implements ContextAwareNormalizerInterface, Normaliz
'type' => 'social_issue',
'id' => $socialIssue->getId(),
'parent_id' => $socialIssue->hasParent() ? $socialIssue->getParent()->getId() : null,
'children_ids' => $socialIssue->getChildren()->map(static function (SocialIssue $si) { return $si->getId(); }),
'children_ids' => $socialIssue->getChildren()->map(static function (SocialIssue $si) {
return $si->getId();
}),
'title' => $socialIssue->getTitle(),
'text' => $this->render->renderString($socialIssue, []),
];

View File

@@ -33,6 +33,7 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function array_key_exists;
class AccompanyingPeriodContext implements
@@ -149,7 +150,9 @@ class AccompanyingPeriodContext implements
public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, $entity): void
{
$options = $template->getOptions();
$persons = $entity->getCurrentParticipations()->map(static function (AccompanyingPeriodParticipation $p) { return $p->getPerson(); })
$persons = $entity->getCurrentParticipations()->map(static function (AccompanyingPeriodParticipation $p) {
return $p->getPerson();
})
->toArray();
foreach (['mainPerson', 'person1', 'person2'] as $key) {
@@ -157,7 +160,9 @@ class AccompanyingPeriodContext implements
$builder->add($key, EntityType::class, [
'class' => Person::class,
'choices' => $persons,
'choice_label' => function (Person $p) { return $this->personRender->renderString($p, []); },
'choice_label' => function (Person $p) {
return $this->personRender->renderString($p, []);
},
'multiple' => false,
'expanded' => true,
'label' => $options[$key . 'Label'],

View File

@@ -60,7 +60,9 @@ class AccompanyingPeriodWorkEvaluationContext implements
$this->accompanyingPeriodWorkContext->adminFormReverseTransform($data),
[
'evaluations' => array_map(
static function (Evaluation $e) { return $e->getId(); },
static function (Evaluation $e) {
return $e->getId();
},
$data['evaluations']
),
]
@@ -73,7 +75,9 @@ class AccompanyingPeriodWorkEvaluationContext implements
$this->accompanyingPeriodWorkContext->adminFormTransform($data),
[
'evaluations' => array_map(
function ($id) { return $this->evaluationRepository->find($id); },
function ($id) {
return $this->evaluationRepository->find($id);
},
$data['evaluations'] ?? []
),
]

View File

@@ -25,6 +25,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\Expr\Comparison;
use Doctrine\Persistence\ObjectRepository;
use Exception;
use function count;
final class SocialWorkMetadata implements SocialWorkMetadataInterface

View File

@@ -15,6 +15,7 @@ use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender;
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Templating\EngineInterface;
use function array_key_exists;
/**

View File

@@ -15,6 +15,7 @@ use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Symfony\Component\Templating\EngineInterface;
use function array_merge;
use function array_reverse;
use function implode;

View File

@@ -15,6 +15,7 @@ use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Symfony\Component\Templating\EngineInterface;
use function array_reverse;
use function implode;

View File

@@ -21,6 +21,7 @@ use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Doctrine\ORM\EntityManager;
use LogicException;
use Symfony\Component\Security\Core\Security;
use function implode;
use function in_array;

View File

@@ -19,6 +19,7 @@ use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use function in_array;
class AccompanyingPeriodValidityValidator extends ConstraintValidator
@@ -68,7 +69,9 @@ class AccompanyingPeriodValidityValidator extends ConstraintValidator
$periodIssuesWithAncestors = array_merge(
$periodIssuesWithAncestors,
array_map(
static function (SocialIssue $si) { return $si->getId(); },
static function (SocialIssue $si) {
return $si->getId();
},
$si->getAncestors(true)
)
);

View File

@@ -38,9 +38,11 @@ class LocationValidityValidator extends ConstraintValidator
}
if ($period->getLocationStatus() === 'person') {
if (null === $period->getOpenParticipationContainsPerson(
$period->getPersonLocation()
)) {
if (
null === $period->getOpenParticipationContainsPerson(
$period->getPersonLocation()
)
) {
$this->context->buildViolation($constraint->messagePersonLocatedMustBeAssociated)
->setParameter('{{ person_name }}', $this->render->renderString(
$period->getPersonLocation(),
@@ -50,8 +52,10 @@ class LocationValidityValidator extends ConstraintValidator
}
}
if ($period->getStep() !== AccompanyingPeriod::STEP_DRAFT
&& $period->getLocationStatus() === 'none') {
if (
$period->getStep() !== AccompanyingPeriod::STEP_DRAFT
&& $period->getLocationStatus() === 'none'
) {
$this->context
->buildViolation(
$constraint->messagePeriodMustRemainsLocated

View File

@@ -19,6 +19,7 @@ use Doctrine\Common\Collections\Collection;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use function count;
class ParticipationOverlapValidator extends ConstraintValidator

View File

@@ -18,6 +18,7 @@ use Doctrine\Common\Collections\Collection;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use function count;
use function in_array;

View File

@@ -17,6 +17,7 @@ use Chill\PersonBundle\Templating\Entity\PersonRender;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use function count;
/**

View File

@@ -16,6 +16,7 @@ use DateTime;
use LogicException;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use function get_class;
use function gettype;
use function is_object;

View File

@@ -25,6 +25,7 @@ use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Security\Core\User\UserInterface;
use Twig\Environment;
use UnexpectedValueException;
use function array_key_exists;
use function count;

View File

@@ -13,6 +13,7 @@ namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use function count;
/**