mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-27 10:03:49 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -22,7 +22,6 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
|
||||
/**
|
||||
* Class AccompanyingPeriodType.
|
||||
@@ -49,7 +48,7 @@ class AccompanyingPeriodType extends AbstractType
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
//if the period_action is close, date opening should not be seen
|
||||
// if the period_action is close, date opening should not be seen
|
||||
if ('close' !== $options['period_action']) {
|
||||
$builder
|
||||
->add('openingDate', DateType::class, [
|
||||
|
@@ -13,14 +13,9 @@ namespace Chill\PersonBundle\Form\ChoiceLoader;
|
||||
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Allow to load a list of person.
|
||||
*/
|
||||
@@ -32,7 +27,7 @@ class PersonChoiceLoader implements ChoiceLoaderInterface
|
||||
|
||||
public function __construct(
|
||||
protected PersonRepository $personRepository,
|
||||
?array $centers = null
|
||||
array $centers = null
|
||||
) {
|
||||
if (null !== $centers) {
|
||||
$this->centers = $centers;
|
||||
@@ -46,7 +41,7 @@ class PersonChoiceLoader implements ChoiceLoaderInterface
|
||||
{
|
||||
return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList(
|
||||
$this->lazyLoadedPersons,
|
||||
static fn (Person $p) => call_user_func($value, $p)
|
||||
static fn (Person $p) => \call_user_func($value, $p)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -68,9 +63,9 @@ class PersonChoiceLoader implements ChoiceLoaderInterface
|
||||
|
||||
if (
|
||||
$this->hasCenterFilter()
|
||||
&& !in_array($person->getCenter(), $this->centers, true)
|
||||
&& !\in_array($person->getCenter(), $this->centers, true)
|
||||
) {
|
||||
throw new RuntimeException('chosen a person not in correct center');
|
||||
throw new \RuntimeException('chosen a person not in correct center');
|
||||
}
|
||||
|
||||
$choices[] = $person;
|
||||
@@ -95,7 +90,7 @@ class PersonChoiceLoader implements ChoiceLoaderInterface
|
||||
continue;
|
||||
}
|
||||
|
||||
$id = call_user_func($value, $choice);
|
||||
$id = \call_user_func($value, $choice);
|
||||
$values[] = $id;
|
||||
$this->lazyLoadedPersons[$id] = $choice;
|
||||
}
|
||||
@@ -108,6 +103,6 @@ class PersonChoiceLoader implements ChoiceLoaderInterface
|
||||
*/
|
||||
protected function hasCenterFilter()
|
||||
{
|
||||
return count($this->centers) > 0;
|
||||
return \count($this->centers) > 0;
|
||||
}
|
||||
}
|
||||
|
@@ -53,7 +53,7 @@ class ClosingMotiveType extends AbstractType
|
||||
->add('isCanceledAccompanyingPeriod', CheckboxType::class, [
|
||||
'label' => $this->translator->trans('Consider canceled'),
|
||||
'required' => false,
|
||||
'help' => $this->translator->trans('Canceled parcours help')
|
||||
'help' => $this->translator->trans('Canceled parcours help'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@@ -17,9 +17,6 @@ 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;
|
||||
|
||||
class PersonAltNameDataMapper implements DataMapperInterface
|
||||
{
|
||||
public function mapDataToForms($viewData, $forms)
|
||||
@@ -35,12 +32,12 @@ class PersonAltNameDataMapper implements DataMapperInterface
|
||||
$mapIndexToKey = [];
|
||||
|
||||
foreach ($viewData->getIterator() as $key => $altName) {
|
||||
/** @var PersonAltName $altName */
|
||||
/* @var PersonAltName $altName */
|
||||
$mapIndexToKey[$altName->getKey()] = $key;
|
||||
}
|
||||
|
||||
foreach ($forms as $key => $form) {
|
||||
if (array_key_exists($key, $mapIndexToKey)) {
|
||||
if (\array_key_exists($key, $mapIndexToKey)) {
|
||||
$form->setData($viewData->get($mapIndexToKey[$key])->getLabel());
|
||||
}
|
||||
}
|
||||
@@ -48,13 +45,13 @@ class PersonAltNameDataMapper implements DataMapperInterface
|
||||
|
||||
/**
|
||||
* @param FormInterface[] $forms
|
||||
* @param Collection $viewData
|
||||
* @param Collection $viewData
|
||||
*/
|
||||
public function mapFormsToData($forms, &$viewData)
|
||||
{
|
||||
$mapIndexToKey = [];
|
||||
|
||||
if (is_array($viewData)) {
|
||||
if (\is_array($viewData)) {
|
||||
$dataIterator = $viewData;
|
||||
} else {
|
||||
$dataIterator = $viewData instanceof ArrayCollection ?
|
||||
@@ -62,14 +59,14 @@ class PersonAltNameDataMapper implements DataMapperInterface
|
||||
}
|
||||
|
||||
foreach ($dataIterator as $key => $altName) {
|
||||
/** @var PersonAltName $altName */
|
||||
/* @var PersonAltName $altName */
|
||||
$mapIndexToKey[$altName->getKey()] = $key;
|
||||
}
|
||||
|
||||
foreach ($forms as $key => $form) {
|
||||
$isEmpty = empty($form->getData());
|
||||
|
||||
if (array_key_exists($key, $mapIndexToKey)) {
|
||||
if (\array_key_exists($key, $mapIndexToKey)) {
|
||||
if ($isEmpty) {
|
||||
$viewData->remove($mapIndexToKey[$key]);
|
||||
} else {
|
||||
@@ -81,7 +78,7 @@ class PersonAltNameDataMapper implements DataMapperInterface
|
||||
->setKey($key)
|
||||
->setLabel($form->getData());
|
||||
|
||||
if (is_array($viewData)) {
|
||||
if (\is_array($viewData)) {
|
||||
$viewData[] = $altName;
|
||||
} else {
|
||||
$viewData->add($altName);
|
||||
|
@@ -20,7 +20,6 @@ use Chill\MainBundle\Form\Type\CommentType;
|
||||
use Chill\MainBundle\Form\Type\PickCivilityType;
|
||||
use Chill\MainBundle\Form\Type\Select2CountryType;
|
||||
use Chill\MainBundle\Form\Type\Select2LanguageType;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
@@ -29,7 +28,6 @@ use Chill\PersonBundle\Form\Type\GenderType;
|
||||
use Chill\PersonBundle\Form\Type\PersonAltNameType;
|
||||
use Chill\PersonBundle\Form\Type\PersonPhoneType;
|
||||
use Chill\PersonBundle\Form\Type\Select2MaritalStatusType;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\CallbackTransformer;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
@@ -156,7 +154,7 @@ class PersonType extends AbstractType
|
||||
'allow_delete' => true,
|
||||
'by_reference' => false,
|
||||
'label' => false,
|
||||
'delete_empty' => static fn (?PersonPhone $pp = null) => null === $pp || $pp->isEmpty(),
|
||||
'delete_empty' => static fn (PersonPhone $pp = null) => null === $pp || $pp->isEmpty(),
|
||||
'error_bubbling' => false,
|
||||
'empty_collection_explain' => 'No additional phone numbers',
|
||||
]);
|
||||
|
@@ -18,7 +18,6 @@ use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Form\ChoiceLoader\PersonChoiceLoader;
|
||||
use Chill\PersonBundle\Repository\PersonRepository;
|
||||
use Chill\PersonBundle\Search\PersonSearch;
|
||||
use RuntimeException;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\Options;
|
||||
@@ -29,9 +28,6 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
|
||||
/**
|
||||
* This type allow to pick a person.
|
||||
*
|
||||
@@ -113,7 +109,7 @@ class PickPersonType extends AbstractType
|
||||
// add the default options
|
||||
$resolver->setDefaults([
|
||||
'class' => Person::class,
|
||||
'choice_label' => static fn (Person $p) => $p->getFirstname() . ' ' . $p->getLastname(),
|
||||
'choice_label' => static fn (Person $p) => $p->getFirstname().' '.$p->getLastname(),
|
||||
'placeholder' => 'Pick a person',
|
||||
'choice_attr' => static fn (Person $p) => [
|
||||
'data-center' => $p->getCenter()->getId(),
|
||||
@@ -146,18 +142,17 @@ class PickPersonType extends AbstractType
|
||||
$selectedCenters = $centers;
|
||||
} else {
|
||||
$selectedCenters = [];
|
||||
$optionsCenters = is_array($options['centers']) ?
|
||||
$optionsCenters = \is_array($options['centers']) ?
|
||||
$options['centers'] : [$options['centers']];
|
||||
|
||||
foreach ($optionsCenters as $c) {
|
||||
// check that every member of the array is a center
|
||||
if (!$c instanceof Center) {
|
||||
throw new RuntimeException('Every member of the "centers" '
|
||||
. 'option must be an instance of ' . Center::class);
|
||||
throw new \RuntimeException('Every member of the "centers" option must be an instance of '.Center::class);
|
||||
}
|
||||
|
||||
if (
|
||||
!in_array($c->getId(), array_map(
|
||||
!\in_array($c->getId(), array_map(
|
||||
static fn (Center $c) => $c->getId(),
|
||||
$centers
|
||||
), true)
|
||||
|
@@ -20,9 +20,6 @@ use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
use const SORT_FLAG_CASE;
|
||||
use const SORT_STRING;
|
||||
|
||||
/**
|
||||
* A type to select the marital status.
|
||||
*/
|
||||
@@ -45,7 +42,7 @@ class Select2MaritalStatusType extends AbstractType
|
||||
$choices[$ms->getId()] = $this->translatableStringHelper->localize($ms->getName());
|
||||
}
|
||||
|
||||
asort($choices, SORT_STRING | SORT_FLAG_CASE);
|
||||
asort($choices, \SORT_STRING | \SORT_FLAG_CASE);
|
||||
|
||||
$resolver->setDefaults([
|
||||
'class' => MaritalStatus::class,
|
||||
|
Reference in New Issue
Block a user