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

@@ -48,7 +48,7 @@ final readonly class WorkflowByUserCounter implements NotificationCounterInterfa
public static function generateCacheKeyWorkflowByUser(User $user): string
{
return 'chill_main_workflow_by_u_' . $user->getId();
return 'chill_main_workflow_by_u_'.$user->getId();
}
public function getCountUnreadByUser(User $user): int

View File

@@ -14,14 +14,12 @@ namespace Chill\MainBundle\Workflow\EventSubscriber;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
use Chill\MainBundle\Templating\Entity\UserRender;
use DateTimeImmutable;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Workflow\Event\Event;
use Symfony\Component\Workflow\Event\GuardEvent;
use Symfony\Component\Workflow\TransitionBlocker;
use function array_key_exists;
class EntityWorkflowTransitionEventSubscriber implements EventSubscriberInterface
{
@@ -112,7 +110,7 @@ class EntityWorkflowTransitionEventSubscriber implements EventSubscriberInterfac
$placeMetadata = $event->getWorkflow()->getMetadataStore()
->getPlaceMetadata($step->getCurrentStep());
if (array_key_exists('isFinal', $placeMetadata) && true === $placeMetadata['isFinal']) {
if (\array_key_exists('isFinal', $placeMetadata) && true === $placeMetadata['isFinal']) {
$step->setIsFinal(true);
}
}
@@ -129,7 +127,7 @@ class EntityWorkflowTransitionEventSubscriber implements EventSubscriberInterfac
$step
->setTransitionAfter($event->getTransition()->getName())
->setTransitionAt(new DateTimeImmutable('now'))
->setTransitionAt(new \DateTimeImmutable('now'))
->setTransitionBy($this->security->getUser());
$this->chillLogger->info('[workflow] apply transition on entityWorkflow', [

View File

@@ -18,10 +18,8 @@ use Chill\MainBundle\Workflow\Helper\MetadataExtractor;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Templating\EngineInterface;
use Symfony\Component\Workflow\Event\Event;
use Symfony\Component\Workflow\Registry;
use function in_array;
class NotificationOnTransition implements EventSubscriberInterface
{
@@ -87,7 +85,7 @@ class NotificationOnTransition implements EventSubscriberInterface
'dest' => $subscriber,
'place' => $place,
'workflow' => $workflow,
'is_dest' => in_array($subscriber->getId(), array_map(static fn (User $u) => $u->getId(), $entityWorkflow->futureDestUsers), true),
'is_dest' => \in_array($subscriber->getId(), array_map(static fn (User $u) => $u->getId(), $entityWorkflow->futureDestUsers), true),
];
$notification = new Notification();

View File

@@ -16,7 +16,6 @@ use Chill\MainBundle\Workflow\EntityWorkflowManager;
use Chill\MainBundle\Workflow\Helper\MetadataExtractor;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Email;
use Symfony\Component\Templating\EngineInterface;
use Symfony\Component\Workflow\Registry;
class SendAccessKeyEventSubscriber

View File

@@ -11,6 +11,4 @@ declare(strict_types=1);
namespace Chill\MainBundle\Workflow\Exception;
use RuntimeException;
class HandlerNotFoundException extends RuntimeException {}
class HandlerNotFoundException extends \RuntimeException {}

View File

@@ -16,7 +16,6 @@ use Chill\MainBundle\Entity\Workflow\EntityWorkflowStep;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Symfony\Component\Workflow\Registry;
use Symfony\Component\Workflow\WorkflowInterface;
use function array_key_exists;
class MetadataExtractor
{
@@ -35,7 +34,7 @@ class MetadataExtractor
foreach ($workflows as $workflow) {
$metadata = $workflow->getMetadataStore()->getWorkflowMetadata();
$text = array_key_exists('label', $metadata) ?
$text = \array_key_exists('label', $metadata) ?
$this->translatableStringHelper->localize($metadata['label']) : $workflow->getName();
$workflowsList[] = ['name' => $workflow->getName(), 'text' => $text];
@@ -44,14 +43,14 @@ class MetadataExtractor
return $workflowsList;
}
public function buildArrayPresentationForPlace(EntityWorkflow $entityWorkflow, ?EntityWorkflowStep $step = null): array
public function buildArrayPresentationForPlace(EntityWorkflow $entityWorkflow, EntityWorkflowStep $step = null): array
{
$workflow = $this->registry->get($entityWorkflow, $entityWorkflow->getWorkflowName());
$step ??= $entityWorkflow->getCurrentStep();
$markingMetadata = $workflow->getMetadataStore()->getPlaceMetadata($step->getCurrentStep());
$text = array_key_exists('label', $markingMetadata) ?
$text = \array_key_exists('label', $markingMetadata) ?
$this->translatableStringHelper->localize($markingMetadata['label']) : $step->getCurrentStep();
return ['name' => $step->getCurrentStep(), 'text' => $text];
@@ -68,7 +67,7 @@ class MetadataExtractor
return [
'name' => $transition->getName(),
'text' => array_key_exists('label', $metadata) ?
'text' => \array_key_exists('label', $metadata) ?
$this->translatableStringHelper->localize($metadata['label']) : $transition->getName(),
'isForward' => $metadata['isForward'] ?? null,
];
@@ -81,7 +80,7 @@ class MetadataExtractor
public function buildArrayPresentationForWorkflow(WorkflowInterface $workflow): array
{
$metadata = $workflow->getMetadataStore()->getWorkflowMetadata();
$text = array_key_exists('label', $metadata) ?
$text = \array_key_exists('label', $metadata) ?
$this->translatableStringHelper->localize($metadata['label']) : $workflow->getName();
return ['name' => $workflow->getName(), 'text' => $text];

View File

@@ -30,6 +30,7 @@ class WorkflowNotificationHandler implements NotificationHandlerInterface
public function getTemplateData(Notification $notification, array $options = []): array
{
$entityWorkflow = $this->entityWorkflowRepository->find($notification->getRelatedEntityId());
return [
'entity_workflow' => $entityWorkflow,
'handler' => $this->entityWorkflowManager->getHandler($entityWorkflow),
@@ -41,7 +42,7 @@ class WorkflowNotificationHandler implements NotificationHandlerInterface
{
$notificationCc = false;
if ($notification->getRelatedEntityClass() === EntityWorkflow::class) {
if (EntityWorkflow::class === $notification->getRelatedEntityClass()) {
$relatedEntity = $this->entityWorkflowRepository->findOneBy(['id' => $notification->getRelatedEntityId()]);
if ($relatedEntity->getCurrentStepCreatedBy() !== $this->security->getUser()) {
@@ -54,6 +55,6 @@ class WorkflowNotificationHandler implements NotificationHandlerInterface
public function supports(Notification $notification, array $options = []): bool
{
return $notification->getRelatedEntityClass() === EntityWorkflow::class;
return EntityWorkflow::class === $notification->getRelatedEntityClass();
}
}

View File

@@ -23,8 +23,7 @@ class RelatedEntityWorkflowSupportsStrategy implements WorkflowSupportStrategyIn
return false;
}
foreach ($workflow->getMetadataStore()->getWorkflowMetadata()['related_entity']
as $relatedEntityClass) {
foreach ($workflow->getMetadataStore()->getWorkflowMetadata()['related_entity'] as $relatedEntityClass) {
if ($subject->getRelatedEntityClass() === $relatedEntityClass) {
return true;
}

View File

@@ -18,7 +18,6 @@ use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use Symfony\Component\Workflow\WorkflowInterface;
use function count;
class EntityWorkflowCreationValidator extends \Symfony\Component\Validator\ConstraintValidator
{
@@ -55,7 +54,7 @@ class EntityWorkflowCreationValidator extends \Symfony\Component\Validator\Const
$matched = array_filter($workflows, static fn (WorkflowInterface $workflow) => $workflow->getName() === $value->getWorkflowName());
if (0 === count($matched)) {
if (0 === \count($matched)) {
$this->context->buildViolation($constraint->messageWorkflowNotAvailable)
->addViolation();
}

View File

@@ -16,7 +16,6 @@ use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use function count;
class StepDestValidValidator extends ConstraintValidator
{
@@ -35,12 +34,12 @@ class StepDestValidValidator extends ConstraintValidator
throw new UnexpectedValueException($value, EntityWorkflowStep::class);
}
if ($value->isFinal() && 0 < count($value->getDestUser())) {
if ($value->isFinal() && 0 < \count($value->getDestUser())) {
$this->context->buildViolation($constraint->messageDestNotAllowed)
->addViolation();
}
if (!$value->isFinal() && 0 === count($value->getDestUser())) {
if (!$value->isFinal() && 0 === \count($value->getDestUser())) {
$this->context->buildViolation($constraint->messageRequireDest)
->addViolation();
}