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,15 +16,11 @@ use Chill\PersonBundle\Entity\Household\HouseholdMember;
use Chill\PersonBundle\Entity\Household\Position;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Event\Person\PersonAddressMoveEvent;
use DateTimeImmutable;
use Doctrine\Common\Collections\Criteria;
use LogicException;
use Symfony\Component\Validator\ConstraintViolationList;
use Symfony\Component\Validator\ConstraintViolationListInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use function in_array;
use function spl_object_hash;
class MembersEditor
{
@@ -44,22 +40,22 @@ class MembersEditor
public function __construct(
private readonly ValidatorInterface $validator,
private readonly ?\Chill\PersonBundle\Entity\Household\Household $household,
private readonly ?Household $household,
private readonly EventDispatcherInterface $eventDispatcher
) {}
/**
* Add a person to the household
* Add a person to the household.
*
* The person is added to the household associated with this editor's instance.
*
* If the person is also a member of another household, or the same household at the same position, the person
* is not associated any more with the previous household.
*/
public function addMovement(DateTimeImmutable $date, Person $person, ?Position $position, ?bool $holder = false, ?string $comment = null): self
public function addMovement(\DateTimeImmutable $date, Person $person, ?Position $position, ?bool $holder = false, string $comment = null): self
{
if (null === $this->household) {
throw new LogicException('You must define a household first');
throw new \LogicException('You must define a household first');
}
$membership = (new HouseholdMember())
@@ -89,10 +85,10 @@ class MembersEditor
++$counter;
if ($participation->getEndDate() === null || $participation->getEndDate() > $date) {
if (null === $participation->getEndDate() || $participation->getEndDate() > $date) {
$participation->setEndDate($date);
$this->membershipsAffected[] = $participation;
$this->oldMembershipsHashes[] = spl_object_hash($participation);
$this->oldMembershipsHashes[] = \spl_object_hash($participation);
if ($participation->getHousehold() !== $this->household) {
$event->setPreviousMembership($participation);
@@ -108,7 +104,7 @@ class MembersEditor
foreach ($person->getHouseholdParticipationsNotShareHousehold() as $participation) {
if ($participation->getHousehold() === $this->household
&& $participation->getEndDate() === null || $participation->getEndDate() > $membership->getStartDate()
&& null === $participation->getEndDate() || $participation->getEndDate() > $membership->getStartDate()
&& $participation->getStartDate() <= $membership->getStartDate()
) {
$participation->setEndDate($membership->getStartDate());
@@ -122,7 +118,7 @@ class MembersEditor
}
if ($participation->getHousehold() === $this->household
&& ($participation->getEndDate() === null || $participation->getEndDate() > $membership->getStartDate())
&& (null === $participation->getEndDate() || $participation->getEndDate() > $membership->getStartDate())
&& $participation->getStartDate() <= $membership->getStartDate()
) {
if ($participation->getShareHousehold()) {
@@ -165,7 +161,7 @@ class MembersEditor
* @return $this
*/
public function leaveMovement(
DateTimeImmutable $date,
\DateTimeImmutable $date,
Person $person
): self {
$criteria = new Criteria();
@@ -209,7 +205,7 @@ class MembersEditor
}
foreach ($this->membershipsAffected as $m) {
if (in_array(spl_object_hash($m), $this->oldMembershipsHashes, true)) {
if (\in_array(\spl_object_hash($m), $this->oldMembershipsHashes, true)) {
$list->addAll($this->validator->validate($m, null, [self::VALIDATION_GROUP_AFFECTED]));
} else {
$list->addAll($this->validator->validate($m, null, [self::VALIDATION_GROUP_CREATED,

View File

@@ -19,7 +19,7 @@ class MembersEditorFactory
{
public function __construct(private readonly EventDispatcherInterface $eventDispatcher, private readonly ValidatorInterface $validator) {}
public function createEditor(?Household $household = null): MembersEditor
public function createEditor(Household $household = null): MembersEditor
{
return new MembersEditor($this->validator, $household, $this->eventDispatcher);
}