mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -21,8 +21,6 @@ use Symfony\Component\Validator\ConstraintValidator;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedValueException;
|
||||
|
||||
use function in_array;
|
||||
|
||||
class AccompanyingPeriodValidityValidator extends ConstraintValidator
|
||||
{
|
||||
public function __construct(private readonly ActivityRepository $activityRepository, private readonly SocialIssueRender $socialIssueRender, private readonly TokenStorageInterface $token) {}
|
||||
@@ -70,7 +68,7 @@ class AccompanyingPeriodValidityValidator extends ConstraintValidator
|
||||
}
|
||||
|
||||
foreach ($socialIssuesByKey as $key => $si) {
|
||||
if (!in_array($key, $periodIssuesWithAncestors, true)) {
|
||||
if (!\in_array($key, $periodIssuesWithAncestors, true)) {
|
||||
$this->context
|
||||
->buildViolation(
|
||||
$constraint->messageSocialIssueCannotBeDeleted
|
||||
|
@@ -32,7 +32,7 @@ class LocationValidityValidator extends ConstraintValidator
|
||||
throw new UnexpectedValueException($period, AccompanyingPeriod::class);
|
||||
}
|
||||
|
||||
if ($period->getLocationStatus() === 'person') {
|
||||
if ('person' === $period->getLocationStatus()) {
|
||||
if (
|
||||
null === $period->getOpenParticipationContainsPerson(
|
||||
$period->getPersonLocation()
|
||||
@@ -48,8 +48,8 @@ class LocationValidityValidator extends ConstraintValidator
|
||||
}
|
||||
|
||||
if (
|
||||
$period->getStep() !== AccompanyingPeriod::STEP_DRAFT
|
||||
&& $period->getLocationStatus() === 'none'
|
||||
AccompanyingPeriod::STEP_DRAFT !== $period->getStep()
|
||||
&& 'none' === $period->getLocationStatus()
|
||||
) {
|
||||
$this->context
|
||||
->buildViolation(
|
||||
|
@@ -20,8 +20,6 @@ use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
|
||||
use function count;
|
||||
|
||||
class ParticipationOverlapValidator extends ConstraintValidator
|
||||
{
|
||||
private const MAX_PARTICIPATION = 1;
|
||||
@@ -38,11 +36,11 @@ class ParticipationOverlapValidator extends ConstraintValidator
|
||||
throw new UnexpectedTypeException($participations, 'This should be a collection');
|
||||
}
|
||||
|
||||
if (count($participations) <= self::MAX_PARTICIPATION) {
|
||||
if (\count($participations) <= self::MAX_PARTICIPATION) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (0 === count($participations)) {
|
||||
if (0 === \count($participations)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,7 +57,7 @@ class ParticipationOverlapValidator extends ConstraintValidator
|
||||
}
|
||||
|
||||
foreach ($participationList as $group) {
|
||||
if (count($group) > 1) {
|
||||
if (\count($group) > 1) {
|
||||
$overlaps = new DateRangeCovering(self::MAX_PARTICIPATION, $participations[0]->getStartDate()->getTimezone());
|
||||
|
||||
foreach ($group as $p) {
|
||||
|
@@ -19,9 +19,6 @@ use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
|
||||
use function count;
|
||||
use function in_array;
|
||||
|
||||
class ResourceDuplicateCheckValidator extends ConstraintValidator
|
||||
{
|
||||
public function __construct(private readonly PersonRenderInterface $personRender, private readonly ThirdPartyRender $thirdpartyRender) {}
|
||||
@@ -36,7 +33,7 @@ class ResourceDuplicateCheckValidator extends ConstraintValidator
|
||||
throw new UnexpectedTypeException($resources, Collection::class);
|
||||
}
|
||||
|
||||
if (0 === count($resources)) {
|
||||
if (0 === \count($resources)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -44,9 +41,9 @@ class ResourceDuplicateCheckValidator extends ConstraintValidator
|
||||
|
||||
foreach ($resources as $resource) {
|
||||
$id = ($resource->getResource() instanceof Person ? 'p' :
|
||||
't') . $resource->getResource()->getId();
|
||||
't').$resource->getResource()->getId();
|
||||
|
||||
if (in_array($id, $resourceList, true)) {
|
||||
if (\in_array($id, $resourceList, true)) {
|
||||
$this->context->buildViolation($constraint->message)
|
||||
->setParameter('{{ name }}', $resource->getResource() instanceof Person ? $this->personRender->renderString($resource->getResource(), []) :
|
||||
$this->thirdpartyRender->renderString($resource->getResource(), []))
|
||||
|
@@ -18,8 +18,6 @@ use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Validate that a person does not belong to two household at
|
||||
* the same time.
|
||||
@@ -36,7 +34,7 @@ class HouseholdMembershipSequentialValidator extends ConstraintValidator
|
||||
|
||||
$participations = $person->getHouseholdParticipationsShareHousehold();
|
||||
|
||||
if ($participations->count() === 0) {
|
||||
if (0 === $participations->count()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -52,7 +50,7 @@ class HouseholdMembershipSequentialValidator extends ConstraintValidator
|
||||
if ($covers->hasIntersections()) {
|
||||
foreach ($covers->getIntersections() as [$start, $end, $metadata]) {
|
||||
$participation = $participations[$metadata[0]];
|
||||
$nbHousehold = count($metadata);
|
||||
$nbHousehold = \count($metadata);
|
||||
|
||||
$this->context
|
||||
->buildViolation($constraint->message)
|
||||
|
@@ -11,18 +11,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Validator\Constraints\Person;
|
||||
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use LogicException;
|
||||
use Symfony\Component\Clock\ClockInterface;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
|
||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
use function get_class;
|
||||
use function gettype;
|
||||
use function is_object;
|
||||
|
||||
class BirthdateValidator extends ConstraintValidator
|
||||
{
|
||||
@@ -43,9 +36,8 @@ class BirthdateValidator extends ConstraintValidator
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$value instanceof DateTime) {
|
||||
throw new LogicException('The input should a be a \DateTime interface,'
|
||||
. (get_debug_type($value)));
|
||||
if (!$value instanceof \DateTime) {
|
||||
throw new \LogicException('The input should a be a \DateTime interface,'.get_debug_type($value));
|
||||
}
|
||||
|
||||
if (!$constraint instanceof Birthdate) {
|
||||
@@ -69,15 +61,15 @@ class BirthdateValidator extends ConstraintValidator
|
||||
}
|
||||
}
|
||||
|
||||
private function getLimitDate(): DateTime
|
||||
private function getLimitDate(): \DateTime
|
||||
{
|
||||
$interval = new DateInterval($this->interval_spec);
|
||||
$interval = new \DateInterval($this->interval_spec);
|
||||
|
||||
return DateTime::createFromImmutable($this->clock->now()->sub($interval));
|
||||
return \DateTime::createFromImmutable($this->clock->now()->sub($interval));
|
||||
}
|
||||
|
||||
private function getBelowLimitDate(): DateTime
|
||||
private function getBelowLimitDate(): \DateTime
|
||||
{
|
||||
return DateTime::createFromImmutable($this->clock->now()->sub(new DateInterval($this->below_interval)));
|
||||
return \DateTime::createFromImmutable($this->clock->now()->sub(new \DateInterval($this->below_interval)));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user