fix phpcs, psalm and phpstan

This commit is contained in:
Julien Fastré 2022-02-11 13:06:03 +01:00
parent 64fa7f2e00
commit e3c5f6f95f
5 changed files with 16 additions and 23 deletions

View File

@ -927,15 +927,6 @@ parameters:
count: 1 count: 1
path: src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php path: src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php
-
message:
"""
#^Parameter \\$trans of method Chill\\\\PersonBundle\\\\Controller\\\\AccompanyingCourseWorkController\\:\\:__construct\\(\\) has typehint with deprecated interface Symfony\\\\Component\\\\Translation\\\\TranslatorInterface\\:
since Symfony 4\\.2, use Symfony\\\\Contracts\\\\Translation\\\\TranslatorInterface instead$#
"""
count: 1
path: src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php
- -
message: message:
""" """

View File

@ -167,6 +167,7 @@ class WorkflowController extends AbstractController
$handler = $this->entityWorkflowManager->getHandler($entityWorkflow); $handler = $this->entityWorkflowManager->getHandler($entityWorkflow);
$workflow = $this->registry->get($entityWorkflow, $entityWorkflow->getWorkflowName()); $workflow = $this->registry->get($entityWorkflow, $entityWorkflow->getWorkflowName());
$errors = [];
if (count($workflow->getEnabledTransitions($entityWorkflow)) > 0) { if (count($workflow->getEnabledTransitions($entityWorkflow)) > 0) {
// possible transition // possible transition
@ -245,7 +246,7 @@ class WorkflowController extends AbstractController
'handler_template_data' => $handler->getTemplateData($entityWorkflow), 'handler_template_data' => $handler->getTemplateData($entityWorkflow),
'transition_form' => isset($transitionForm) ? $transitionForm->createView() : null, 'transition_form' => isset($transitionForm) ? $transitionForm->createView() : null,
'entity_workflow' => $entityWorkflow, 'entity_workflow' => $entityWorkflow,
'transition_form_errors' => $errors ?? [], 'transition_form_errors' => $errors,
//'comment_form' => $commentForm->createView(), //'comment_form' => $commentForm->createView(),
] ]
); );

View File

@ -56,7 +56,7 @@ class EntityWorkflowStepRepository implements ObjectRepository
public function getClassName() public function getClassName()
{ {
return EntityWorkflow::class; return EntityWorkflowStep::class;
} }
private function buildQueryByUser(User $user): QueryBuilder private function buildQueryByUser(User $user): QueryBuilder

View File

@ -32,20 +32,20 @@ final class WorkflowByUserCounter implements NotificationCounterInterface, Event
$this->cacheItemPool = $cacheItemPool; $this->cacheItemPool = $cacheItemPool;
} }
public function addNotification(UserInterface $user): int public function addNotification(UserInterface $u): int
{ {
if (!$user instanceof User) { if (!$u instanceof User) {
return 0; return 0;
} }
$key = self::generateCacheKeyWorkflowByUser($user); $key = self::generateCacheKeyWorkflowByUser($u);
$item = $this->cacheItemPool->getItem($key); $item = $this->cacheItemPool->getItem($key);
if ($item->isHit()) { if ($item->isHit()) {
return $item->get(); return $item->get();
} }
$nb = $this->getCountUnreadByUser($user); $nb = $this->getCountUnreadByUser($u);
$item->set($nb) $item->set($nb)
->expiresAfter(60 * 15); ->expiresAfter(60 * 15);

View File

@ -72,17 +72,18 @@ class MetadataExtractor
foreach ($transitions as $transition) { foreach ($transitions as $transition) {
if ($transition->getName() === $transitionName) { if ($transition->getName() === $transitionName) {
break; $metadata = $workflow->getMetadataStore()->getTransitionMetadata($transition);
return [
'name' => $transition->getName(),
'text' => array_key_exists('label', $metadata) ?
$this->translatableStringHelper->localize($metadata['label']) : $transition->getName(),
'isForward' => $metadata['isForward'] ?? null,
];
} }
} }
$metadata = $workflow->getMetadataStore()->getTransitionMetadata($transition);
return [ return [];
'name' => $transition->getName(),
'text' => array_key_exists('label', $metadata) ?
$this->translatableStringHelper->localize($metadata['label']) : $transition->getName(),
'isForward' => $metadata['isForward'] ?? null,
];
} }
public function buildArrayPresentationForWorkflow(WorkflowInterface $workflow): array public function buildArrayPresentationForWorkflow(WorkflowInterface $workflow): array