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

@@ -13,14 +13,9 @@ namespace Chill\EventBundle\Form\ChoiceLoader;
use Chill\EventBundle\Entity\Event;
use Doctrine\ORM\EntityRepository;
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;
/**
* Class EventChoiceLoader.
*/
@@ -46,7 +41,7 @@ class EventChoiceLoader implements ChoiceLoaderInterface
*/
public function __construct(
EntityRepository $eventRepository,
?array $centers = null
array $centers = null
) {
$this->eventRepository = $eventRepository;
@@ -62,7 +57,7 @@ class EventChoiceLoader implements ChoiceLoaderInterface
{
return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList(
$this->lazyLoadedEvents,
static fn (Event $p) => call_user_func($value, $p)
static fn (Event $p) => \call_user_func($value, $p)
);
}
@@ -84,9 +79,9 @@ class EventChoiceLoader implements ChoiceLoaderInterface
if (
$this->hasCenterFilter()
&& !in_array($event->getCenter(), $this->centers, true)
&& !\in_array($event->getCenter(), $this->centers, true)
) {
throw new RuntimeException('chosen an event not in correct center');
throw new \RuntimeException('chosen an event not in correct center');
}
$choices[] = $event;
@@ -111,7 +106,7 @@ class EventChoiceLoader implements ChoiceLoaderInterface
continue;
}
$id = call_user_func($value, $choice);
$id = \call_user_func($value, $choice);
$values[] = $id;
$this->lazyLoadedEvents[$id] = $choice;
}
@@ -124,6 +119,6 @@ class EventChoiceLoader implements ChoiceLoaderInterface
*/
protected function hasCenterFilter()
{
return count($this->centers) > 0;
return \count($this->centers) > 0;
}
}

View File

@@ -19,7 +19,6 @@ use Chill\MainBundle\Form\Type\UserPickerType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Role\Role;
class EventType extends AbstractType
{

View File

@@ -14,7 +14,6 @@ namespace Chill\EventBundle\Form;
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class EventTypeType extends AbstractType
{

View File

@@ -15,7 +15,6 @@ use Chill\EventBundle\Entity\EventType;
use Chill\EventBundle\Entity\Status;
use Chill\EventBundle\Form\Type\PickRoleType;
use Chill\EventBundle\Form\Type\PickStatusType;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;

View File

@@ -13,12 +13,10 @@ namespace Chill\EventBundle\Form;
use Chill\EventBundle\Entity\EventType;
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
final class RoleType extends AbstractType
{

View File

@@ -15,7 +15,6 @@ use Chill\EventBundle\Form\Type\PickEventTypeType;
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class StatusType extends AbstractType
{

View File

@@ -19,21 +19,16 @@ use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\GroupCenter;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use RuntimeException;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Finder\Exception\AccessDeniedException;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
use function in_array;
use function is_array;
/**
* Class PickEventType.
*/
@@ -79,7 +74,7 @@ final class PickEventType extends AbstractType
// add the default options
$resolver->setDefaults([
'class' => Event::class,
'choice_label' => static fn (Event $e) => $e->getDate()->format('d/m/Y, H:i') . ' → ' .
'choice_label' => static fn (Event $e) => $e->getDate()->format('d/m/Y, H:i').' → '.
// $e->getType()->getName()['fr'] . ': ' . // display the type of event
$e->getName(),
'placeholder' => 'Pick an event',
@@ -128,18 +123,17 @@ final class PickEventType 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)

View File

@@ -14,9 +14,7 @@ namespace Chill\EventBundle\Form\Type;
use Chill\EventBundle\Entity\EventType;
use Chill\EventBundle\Entity\Role;
use Chill\EventBundle\Repository\RoleRepository;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -96,9 +94,9 @@ final class PickRoleType extends AbstractType
'data-event-type' => $r->getType()->getId(),
'data-link-category' => $r->getType()->getId(),
],
'choice_label' => static fn (Role $r) => $translatableStringHelper->localize($r->getName()) .
($r->getActive() === true ? '' :
' (' . $translator->trans('unactive') . ')'),
'choice_label' => static fn (Role $r) => $translatableStringHelper->localize($r->getName()).
(true === $r->getActive() ? '' :
' ('.$translator->trans('unactive').')'),
]);
}

View File

@@ -14,9 +14,7 @@ namespace Chill\EventBundle\Form\Type;
use Chill\EventBundle\Entity\EventType;
use Chill\EventBundle\Entity\Status;
use Chill\EventBundle\Repository\StatusRepository;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -93,9 +91,9 @@ final class PickStatusType extends AbstractType
'data-event-type' => $s->getType()->getId(),
'data-link-category' => $s->getType()->getId(),
],
'choice_label' => static fn (Status $s) => $translatableStringHelper->localize($s->getName()) .
($s->getActive() === true ? '' :
' (' . $translator->trans('unactive') . ')'),
'choice_label' => static fn (Status $s) => $translatableStringHelper->localize($s->getName()).
(true === $s->getActive() ? '' :
' ('.$translator->trans('unactive').')'),
]);
}