mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
DX: fix phpstan errors
This commit is contained in:
parent
e5c183aa44
commit
fa481fd795
@ -116,23 +116,23 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
|
||||
{
|
||||
$string = '@person ';
|
||||
|
||||
$string .= empty($data['_default']) ? '' : $data['_default'] . ' ';
|
||||
$string .= !isset($data['_default']) ? '' : $data['_default'] . ' ';
|
||||
|
||||
foreach (['firstname', 'lastname', 'gender', 'city'] as $key) {
|
||||
$string .= empty($data[$key]) ? '' : $key . ':' .
|
||||
$string .= !isset($data[$key]) ? '' : $key . ':' .
|
||||
// add quote if contains spaces
|
||||
(strpos($data[$key], ' ') !== false ? '"' . $data[$key] . '"' : $data[$key])
|
||||
. ' ';
|
||||
}
|
||||
|
||||
foreach (['birthdate', 'birthdate-before', 'birthdate-after'] as $key) {
|
||||
$string .= empty($data[$key]) ?
|
||||
$string .= !isset($data[$key]) ?
|
||||
''
|
||||
:
|
||||
$key . ':' . $data[$key]->format('Y-m-d') . ' ';
|
||||
}
|
||||
|
||||
$string .= empty($data['phonenumber']) ? '' : 'phonenumber:' . $data['phonenumber']->getNationalNumber();
|
||||
$string .= !isset($data['phonenumber']) ? '' : 'phonenumber:' . $data['phonenumber']->getNationalNumber();
|
||||
|
||||
return $string;
|
||||
}
|
||||
@ -163,7 +163,7 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
|
||||
$phonenumber = new PhoneNumber();
|
||||
$phonenumber->setNationalNumber($terms['phonenumber']);
|
||||
} catch (Exception $ex) {
|
||||
throw new ParsingException("The data for {$key} is "
|
||||
throw new ParsingException("The data for phonenumber is "
|
||||
. 'not parsable', 0, $ex);
|
||||
}
|
||||
|
||||
@ -267,14 +267,30 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
|
||||
'city' => $city,
|
||||
] = $terms + array_fill_keys(self::POSSIBLE_KEYS, null);
|
||||
|
||||
foreach (['birthdateBefore', 'birthdateAfter', 'birthdate'] as $v) {
|
||||
if (null !== ${$v}) {
|
||||
try {
|
||||
${$v} = new DateTime(${$v});
|
||||
} catch (Exception $e) {
|
||||
throw new ParsingException('The date is '
|
||||
. 'not parsable', 0, $e);
|
||||
}
|
||||
if (null !== $birthdate) {
|
||||
try {
|
||||
$birthdate = new DateTime($birthdate);
|
||||
} catch (Exception $e) {
|
||||
throw new ParsingException('The date is '
|
||||
. 'not parsable', 0, $e);
|
||||
}
|
||||
}
|
||||
|
||||
if (null !== $birthdateBefore) {
|
||||
try {
|
||||
$birthdateBefore = new DateTime($birthdateBefore);
|
||||
} catch (Exception $e) {
|
||||
throw new ParsingException('The date is '
|
||||
. 'not parsable', 0, $e);
|
||||
}
|
||||
}
|
||||
|
||||
if (null !== $birthdateAfter) {
|
||||
try {
|
||||
$birthdateAfter = new DateTime($birthdateAfter);
|
||||
} catch (Exception $e) {
|
||||
throw new ParsingException('The date is '
|
||||
. 'not parsable', 0, $e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,14 +327,30 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
|
||||
'city' => $city,
|
||||
] = $terms + array_fill_keys(self::POSSIBLE_KEYS, null);
|
||||
|
||||
foreach (['birthdateBefore', 'birthdateAfter', 'birthdate'] as $v) {
|
||||
if (null !== ${$v}) {
|
||||
try {
|
||||
${$v} = new DateTime(${$v});
|
||||
} catch (Exception $e) {
|
||||
throw new ParsingException('The date is '
|
||||
. 'not parsable', 0, $e);
|
||||
}
|
||||
if (null !== $birthdate) {
|
||||
try {
|
||||
$birthdate = new DateTime($birthdate);
|
||||
} catch (Exception $e) {
|
||||
throw new ParsingException('The date is '
|
||||
. 'not parsable', 0, $e);
|
||||
}
|
||||
}
|
||||
|
||||
if (null !== $birthdateBefore) {
|
||||
try {
|
||||
$birthdateBefore = new DateTime($birthdateBefore);
|
||||
} catch (Exception $e) {
|
||||
throw new ParsingException('The date is '
|
||||
. 'not parsable', 0, $e);
|
||||
}
|
||||
}
|
||||
|
||||
if (null !== $birthdateAfter) {
|
||||
try {
|
||||
$birthdateAfter = new DateTime($birthdateAfter);
|
||||
} catch (Exception $e) {
|
||||
throw new ParsingException('The date is '
|
||||
. 'not parsable', 0, $e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,15 +78,14 @@ class ParticipationOverlapValidator extends ConstraintValidator
|
||||
|
||||
if ($overlaps->hasIntersections()) {
|
||||
foreach ($overlaps->getIntersections() as [$start, $end, $ids]) {
|
||||
$msg = null === $end ? $constraint->message :
|
||||
$constraint->message;
|
||||
$msg = $constraint->message;
|
||||
|
||||
$this->context->buildViolation($msg)
|
||||
->setParameters([
|
||||
'{{ start }}' => $start->format('d-m-Y'),
|
||||
'{{ end }}' => null === $end ? null : $end->format('d-m-Y'),
|
||||
'{{ ids }}' => $ids,
|
||||
'{{ name }}' => $this->personRender->renderString($participation->getPerson(), []),
|
||||
'{{ name }}' => $this->personRender->renderString($participations[0]->getPerson(), []),
|
||||
])
|
||||
->addViolation();
|
||||
}
|
||||
|
@ -59,10 +59,6 @@ class ThirdPartyChoiceLoader implements ChoiceLoaderInterface
|
||||
$choices = [];
|
||||
|
||||
foreach ($values as $value) {
|
||||
if (null === $value || '' === $value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$party = $this->partyRepository->find($value);
|
||||
|
||||
if (false === in_array($this->center, $party->getCenters()->toArray(), true)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user