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

@@ -16,23 +16,20 @@ use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Validator\Constraints\Entity\WorkflowStepUsersOnTransition;
use Chill\MainBundle\Workflow\Validator\EntityWorkflowCreation;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Iterator;
use RuntimeException;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Validator\Constraints as Assert;
use function count;
use function is_array;
/**
* @ORM\Entity
*
* @ORM\Table("chill_main_workflow_entity")
*
* @EntityWorkflowCreation(groups={"creation"})
*
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
* "entity_workflow": EntityWorkflow::class
* })
@@ -81,7 +78,9 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
@@ -98,19 +97,23 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\OneToMany(targetEntity=EntityWorkflowStep::class, mappedBy="entityWorkflow", orphanRemoval=true, cascade={"persist"})
*
* @ORM\OrderBy({"transitionAt": "ASC", "id": "ASC"})
*
* @Assert\Valid(traverse=true)
*
* @var Collection<EntityWorkflowStep>
*/
private Collection $steps;
/**
* @var null|array|EntityWorkflowStep[]
* @var array|EntityWorkflowStep[]|null
*/
private ?array $stepsChainedCache = null;
/**
* @ORM\ManyToMany(targetEntity=User::class)
*
* @ORM\JoinTable(name="chill_main_workflow_entity_subscriber_to_final")
*
* @var Collection<User>
@@ -119,6 +122,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
/**
* @ORM\ManyToMany(targetEntity=User::class)
*
* @ORM\JoinTable(name="chill_main_workflow_entity_subscriber_to_step")
*
* @var Collection<User>
@@ -220,7 +224,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
return null;
}
public function getCurrentStepCreatedAt(): ?DateTimeInterface
public function getCurrentStepCreatedAt(): ?\DateTimeInterface
{
if (null !== $previous = $this->getPreviousStepIfAny()) {
return $previous->getTransitionAt();
@@ -267,7 +271,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
{
$iterator = $this->steps->getIterator();
if ($iterator instanceof Iterator) {
if ($iterator instanceof \Iterator) {
$iterator->rewind();
while ($iterator->valid()) {
@@ -288,20 +292,17 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
return null;
}
throw new RuntimeException();
throw new \RuntimeException();
}
/**
* @return ArrayCollection|Collection
*/
public function getSteps(): \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection
public function getSteps(): ArrayCollection|Collection
{
return $this->steps;
}
public function getStepsChained(): array
{
if (is_array($this->stepsChainedCache)) {
if (\is_array($this->stepsChainedCache)) {
return $this->stepsChainedCache;
}
@@ -332,18 +333,12 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
return $steps;
}
/**
* @return ArrayCollection|Collection
*/
public function getSubscriberToFinal(): \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection
public function getSubscriberToFinal(): ArrayCollection|Collection
{
return $this->subscriberToFinal;
}
/**
* @return ArrayCollection|Collection
*/
public function getSubscriberToStep(): \Doctrine\Common\Collections\ArrayCollection|\Doctrine\Common\Collections\Collection
public function getSubscriberToStep(): ArrayCollection|Collection
{
return $this->subscriberToStep;
}
@@ -495,7 +490,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
private function getPreviousStepIfAny(): ?EntityWorkflowStep
{
if (1 === count($this->steps)) {
if (1 === \count($this->steps)) {
return null;
}

View File

@@ -19,6 +19,7 @@ use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*
* @ORM\Table("chill_main_workflow_entity_comment")
*/
class EntityWorkflowComment implements TrackCreationInterface, TrackUpdateInterface
@@ -39,7 +40,9 @@ class EntityWorkflowComment implements TrackCreationInterface, TrackUpdateInterf
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;

View File

@@ -12,17 +12,15 @@ declare(strict_types=1);
namespace Chill\MainBundle\Entity\Workflow;
use Chill\MainBundle\Entity\User;
use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use function count;
use function in_array;
/**
* @ORM\Entity
*
* @ORM\Table("chill_main_workflow_entity_step")
*/
class EntityWorkflowStep
@@ -34,7 +32,9 @@ class EntityWorkflowStep
/**
* @var Collection<User>
*
* @ORM\ManyToMany(targetEntity=User::class)
*
* @ORM\JoinTable(name="chill_main_workflow_entity_step_cc_user")
*/
private Collection $ccUser;
@@ -56,14 +56,18 @@ class EntityWorkflowStep
/**
* @var Collection<User>
*
* @ORM\ManyToMany(targetEntity=User::class)
*
* @ORM\JoinTable(name="chill_main_workflow_entity_step_user")
*/
private Collection $destUser;
/**
* @var Collection<User>
*
* @ORM\ManyToMany(targetEntity=User::class)
*
* @ORM\JoinTable(name="chill_main_workflow_entity_step_user_by_accesskey")
*/
private Collection $destUserByAccessKey;
@@ -80,7 +84,9 @@ class EntityWorkflowStep
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
private ?int $id = null;
@@ -108,10 +114,11 @@ class EntityWorkflowStep
/**
* @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null})
*/
private ?DateTimeImmutable $transitionAt = null;
private ?\DateTimeImmutable $transitionAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*
* @ORM\JoinColumn(nullable=true)
*/
private ?User $transitionBy = null;
@@ -140,7 +147,7 @@ class EntityWorkflowStep
public function addDestEmail(string $email): self
{
if (!in_array($email, $this->destEmail, true)) {
if (!\in_array($email, $this->destEmail, true)) {
$this->destEmail[] = $email;
}
@@ -247,7 +254,7 @@ class EntityWorkflowStep
return $this->transitionAfter;
}
public function getTransitionAt(): ?DateTimeImmutable
public function getTransitionAt(): ?\DateTimeImmutable
{
return $this->transitionAt;
}
@@ -385,7 +392,7 @@ class EntityWorkflowStep
return $this;
}
public function setTransitionAt(?DateTimeImmutable $transitionAt): EntityWorkflowStep
public function setTransitionAt(?\DateTimeImmutable $transitionAt): EntityWorkflowStep
{
$this->transitionAt = $transitionAt;
@@ -414,13 +421,13 @@ class EntityWorkflowStep
return;
if ($this->isFinalizeAfter()) {
if (0 !== count($this->getDestUser())) {
if (0 !== \count($this->getDestUser())) {
$context->buildViolation('workflow.No dest users when the workflow is finalized')
->atPath('finalizeAfter')
->addViolation();
}
} else {
if (0 === count($this->getDestUser())) {
if (0 === \count($this->getDestUser())) {
$context->buildViolation('workflow.The next step must count at least one dest')
->atPath('finalizeAfter')
->addViolation();