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

@@ -37,6 +37,7 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Contracts\Translation\TranslatorInterface;
use function array_map;
use function array_merge;

View File

@@ -25,6 +25,7 @@ use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Workflow\Registry;
use Symfony\Component\Workflow\Transition;
use function array_filter;
use function array_values;
@@ -96,7 +97,8 @@ class TaskController extends AbstractController
static function (Transition $t) use ($transition) {
return $t->getName() === $transition;
}
))[0];
)
)[0];
$form = $this->createTransitionForm($task);

View File

@@ -18,6 +18,7 @@ use Chill\TaskBundle\Security\Authorization\TaskVoter;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager;
use function in_array;
/**

View File

@@ -19,6 +19,7 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use function array_fill_keys;
use function array_keys;

View File

@@ -12,7 +12,6 @@ declare(strict_types=1);
namespace Chill\TaskBundle\Entity;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

View File

@@ -29,6 +29,7 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Role\Role;
use function array_combine;
use function array_map;
use function count;
@@ -217,9 +218,13 @@ class SingleTaskListType extends AbstractType
$users = $this->getUsersAssigneedToTask($options);
$choices = array_combine(
// get usernames
array_map(static function (User $user) { return $user->getUsername(); }, $users),
array_map(static function (User $user) {
return $user->getUsername();
}, $users),
// get ids
array_map(static function (User $user) { return $user->getId(); }, $users)
array_map(static function (User $user) {
return $user->getId();
}, $users)
);
$choices['Unassigned'] = '_unassigned';

View File

@@ -23,6 +23,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Security\Core\Security;
use function count;
use function substr;
@@ -68,69 +69,69 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository
foreach ($flags as $key => $flag) {
switch ($flag) {
case 'no-alert':
$orXDate
->add(
$qb->expr()->orX(
case 'no-alert':
$orXDate
->add(
$qb->expr()->orX(
$qb->expr()->isNull('t.endDate'),
$qb->expr()->gte('t.endDate - COALESCE(t.warningInterval, :intervalBlank)', ':now')
)
);
$qb
->setParameter('intervalBlank', new DateInterval('P0D'))
->setParameter('now', $now);
);
$qb
->setParameter('intervalBlank', new DateInterval('P0D'))
->setParameter('now', $now);
break;
break;
case 'warning':
$orXDate
->add(
$qb->expr()->andX(
case 'warning':
$orXDate
->add(
$qb->expr()->andX(
$qb->expr()->not($qb->expr()->isNull('t.endDate')),
$qb->expr()->not($qb->expr()->isNull('t.warningInterval')),
$qb->expr()->lte('t.endDate - t.warningInterval', ':now'),
$qb->expr()->gt('t.endDate', ':now')
)
);
$qb
->setParameter('now', $now);
);
$qb
->setParameter('now', $now);
break;
break;
case 'alert':
$orXDate
->add(
$qb->expr()->andX(
case 'alert':
$orXDate
->add(
$qb->expr()->andX(
$qb->expr()->not($qb->expr()->isNull('t.endDate')),
$qb->expr()->lte('t.endDate', ':now')
)
);
$qb
->setParameter('now', $now);
);
$qb
->setParameter('now', $now);
break;
break;
case 'state_new':
$orXState
->add(
'JSONB_ARRAY_LENGTH(t.currentStates) = 0'
);
case 'state_new':
$orXState
->add(
'JSONB_ARRAY_LENGTH(t.currentStates) = 0'
);
break;
break;
case substr($flag, 0, 6) === 'state_':
$state = substr($flag, 6);
$orXState
->add(
"JSONB_EXISTS_IN_ARRAY(t.currentStates, :state_{$key}) = 'TRUE'"
);
$qb->setParameter("state_{$key}", $state);
case substr($flag, 0, 6) === 'state_':
$state = substr($flag, 6);
$orXState
->add(
"JSONB_EXISTS_IN_ARRAY(t.currentStates, :state_{$key}) = 'TRUE'"
);
$qb->setParameter("state_{$key}", $state);
break;
break;
default:
throw new LogicException("this flag is not supported: {$flag}");
}
default:
throw new LogicException("this flag is not supported: {$flag}");
}
}
if ($orXDate->count() > 0) {

View File

@@ -22,6 +22,7 @@ use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Security\Core\Role\Role;
use UnexpectedValueException;
use function array_key_exists;
use function count;

View File

@@ -25,6 +25,7 @@ use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use function in_array;
final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface

View File

@@ -17,6 +17,7 @@ use Chill\TaskBundle\Repository\SingleTaskRepository;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Workflow\Event\Event;
use function array_merge;
class CountNotificationTask implements NotificationCounterInterface
@@ -69,10 +70,12 @@ class CountNotificationTask implements NotificationCounterInterface
$task = $e->getSubject();
if (null !== $task->getAssignee()) {
foreach ([
SingleTaskRepository::DATE_STATUS_ENDED,
SingleTaskRepository::DATE_STATUS_WARNING,
] as $status) {
foreach (
[
SingleTaskRepository::DATE_STATUS_ENDED,
SingleTaskRepository::DATE_STATUS_WARNING,
] as $status
) {
$key = $this->getCacheKey($task->getAssignee(), $status);
$sumCache = $this->cachePool->getItem($key);

View File

@@ -19,6 +19,7 @@ use Doctrine\ORM\EntityManagerInterface;
use LogicException;
use Symfony\Component\Workflow\Registry;
use Symfony\Component\Workflow\Workflow;
use function array_combine;
use function array_map;
@@ -85,7 +86,9 @@ class SingleTaskTaskLifeCycleEventTimelineProvider implements TimelineProviderIn
->findBy(['id' => $ids]);
return array_combine(
array_map(static function ($e) { return $e->getId(); }, $events),
array_map(static function ($e) {
return $e->getId();
}, $events),
$events
);
}

View File

@@ -24,6 +24,7 @@ use Symfony\Component\Security\Core\Security;
use Symfony\Component\Workflow\Registry;
use Symfony\Component\Workflow\Workflow;
use UnexpectedValueException;
use function array_combine;
use function array_fill;
use function array_map;
@@ -96,7 +97,9 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface
->findBy(['id' => $ids]);
return array_combine(
array_map(static function ($e) { return $e->getId(); }, $events),
array_map(static function ($e) {
return $e->getId();
}, $events),
$events
);
}
@@ -189,10 +192,12 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface
$clauses = [];
// loop over centers
foreach ($this->authorizationHelper->getReachableCenters(
$this->security->getUser(),
new Role(ActivityVoter::SEE_DETAILS)
) as $center) {
foreach (
$this->authorizationHelper->getReachableCenters(
$this->security->getUser(),
new Role(ActivityVoter::SEE_DETAILS)
) as $center
) {
if (false === in_array($center, $centers, true)) {
continue;
}

View File

@@ -15,6 +15,7 @@ use Chill\TaskBundle\Entity\AbstractTask;
use Chill\TaskBundle\Entity\SingleTask;
use LogicException;
use Symfony\Component\Workflow\Transition;
use function array_key_exists;
use function array_slice;
use function explode;

View File

@@ -30,10 +30,12 @@ class DefaultTaskGuardEvent implements EventSubscriberInterface
public function checkACL(GuardEvent $event)
{
if (false === $this->authorizationChecker->isGranted(
TaskVoter::UPDATE,
$event->getSubject()
)) {
if (
false === $this->authorizationChecker->isGranted(
TaskVoter::UPDATE,
$event->getSubject()
)
) {
$event->setBlocked(true);
}
}

View File

@@ -16,6 +16,7 @@ use LogicException;
use Symfony\Component\Workflow\Event\Event;
use Symfony\Component\Workflow\SupportStrategy\WorkflowSupportStrategyInterface;
use Symfony\Component\Workflow\WorkflowInterface;
use function count;
use function sprintf;