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

@@ -34,12 +34,8 @@ use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use DateInterval;
use DateTime;
use DateTimeZone;
use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ObjectManager;
use RuntimeException;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\CallbackTransformer;
@@ -53,8 +49,6 @@ use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use function in_array;
class ActivityType extends AbstractType
{
protected User $user;
@@ -69,7 +63,7 @@ class ActivityType extends AbstractType
protected SocialActionRender $socialActionRender
) {
if (!$tokenStorage->getToken()->getUser() instanceof User) {
throw new RuntimeException('you should have a valid user');
throw new \RuntimeException('you should have a valid user');
}
$this->user = $tokenStorage->getToken()->getUser();
@@ -102,16 +96,16 @@ class ActivityType extends AbstractType
]);
}
/** @var ? \Chill\PersonBundle\Entity\AccompanyingPeriod $accompanyingPeriod */
/** @var \Chill\PersonBundle\Entity\AccompanyingPeriod|null $accompanyingPeriod */
$accompanyingPeriod = null;
if ($options['accompanyingPeriod'] instanceof AccompanyingPeriod) {
$accompanyingPeriod = $options['accompanyingPeriod'];
}
if ($activityType->isVisible('socialIssues') && $accompanyingPeriod) {
if ($activityType->isVisible('socialIssues') && null !== $accompanyingPeriod) {
$builder->add('socialIssues', HiddenType::class, [
'required' => $activityType->getSocialIssuesVisible() === 2,
'required' => 2 === $activityType->getSocialIssuesVisible(),
]);
$builder->get('socialIssues')
->addModelTransformer(new CallbackTransformer(
@@ -137,9 +131,9 @@ class ActivityType extends AbstractType
));
}
if ($activityType->isVisible('socialActions') && $accompanyingPeriod) {
if ($activityType->isVisible('socialActions') && null !== $accompanyingPeriod) {
$builder->add('socialActions', HiddenType::class, [
'required' => $activityType->getSocialActionsVisible() === 2,
'required' => 2 === $activityType->getSocialActionsVisible(),
]);
$builder->get('socialActions')
->addModelTransformer(new CallbackTransformer(
@@ -323,7 +317,7 @@ class ActivityType extends AbstractType
if ($activityType->isVisible('location')) {
$builder->add('location', HiddenType::class, [
'required' => $activityType->getLocationVisible() === 2,
'required' => 2 === $activityType->getLocationVisible(),
])
->get('location')
->addModelTransformer(new CallbackTransformer(
@@ -374,16 +368,16 @@ class ActivityType extends AbstractType
) {
// set the timezone to GMT, and fix the difference between current and GMT
// the datetimetransformer will then handle timezone as GMT
$timezoneUTC = new DateTimeZone('GMT');
/** @var DateTime $data */
$data = $formEvent->getData() ?? DateTime::createFromFormat('U', '300');
$timezoneUTC = new \DateTimeZone('GMT');
/** @var \DateTime $data */
$data = $formEvent->getData() ?? \DateTime::createFromFormat('U', '300');
$seconds = $data->getTimezone()->getOffset($data);
$data->setTimeZone($timezoneUTC);
$data->add(new DateInterval('PT' . $seconds . 'S'));
$data->add(new \DateInterval('PT'.$seconds.'S'));
// test if the timestamp is in the choices.
// If not, recreate the field with the new timestamp
if (!in_array($data->getTimestamp(), $timeChoices, true)) {
if (!\in_array($data->getTimestamp(), $timeChoices, true)) {
// the data are not in the possible values. add them
$timeChoices[$data->format('H:i')] = $data->getTimestamp();
$form = $builder->create($fieldName, ChoiceType::class, array_merge(

View File

@@ -56,8 +56,8 @@ class ActivityTypeType extends AbstractType
foreach ($fields as $field) {
$builder
->add($field . 'Visible', ActivityFieldPresence::class)
->add($field . 'Label', TextType::class, [
->add($field.'Visible', ActivityFieldPresence::class)
->add($field.'Label', TextType::class, [
'required' => false,
'empty_data' => '',
]);

View File

@@ -31,7 +31,7 @@ class TranslatableActivityReasonCategoryType extends AbstractType
[
'class' => ActivityReasonCategory::class,
'choice_label' => fn (ActivityReasonCategory $category) => $this->translatableStringHelper->localize($category->getName())
. (!$category->getActive() ? ' (' . $this->translator->trans('inactive') . ')' : ''),
.(!$category->getActive() ? ' ('.$this->translator->trans('inactive').')' : ''),
]
);
}