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 = '@person ';
|
||||||
|
|
||||||
$string .= empty($data['_default']) ? '' : $data['_default'] . ' ';
|
$string .= !isset($data['_default']) ? '' : $data['_default'] . ' ';
|
||||||
|
|
||||||
foreach (['firstname', 'lastname', 'gender', 'city'] as $key) {
|
foreach (['firstname', 'lastname', 'gender', 'city'] as $key) {
|
||||||
$string .= empty($data[$key]) ? '' : $key . ':' .
|
$string .= !isset($data[$key]) ? '' : $key . ':' .
|
||||||
// add quote if contains spaces
|
// add quote if contains spaces
|
||||||
(strpos($data[$key], ' ') !== false ? '"' . $data[$key] . '"' : $data[$key])
|
(strpos($data[$key], ' ') !== false ? '"' . $data[$key] . '"' : $data[$key])
|
||||||
. ' ';
|
. ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (['birthdate', 'birthdate-before', 'birthdate-after'] as $key) {
|
foreach (['birthdate', 'birthdate-before', 'birthdate-after'] as $key) {
|
||||||
$string .= empty($data[$key]) ?
|
$string .= !isset($data[$key]) ?
|
||||||
''
|
''
|
||||||
:
|
:
|
||||||
$key . ':' . $data[$key]->format('Y-m-d') . ' ';
|
$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;
|
return $string;
|
||||||
}
|
}
|
||||||
@ -163,7 +163,7 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
|
|||||||
$phonenumber = new PhoneNumber();
|
$phonenumber = new PhoneNumber();
|
||||||
$phonenumber->setNationalNumber($terms['phonenumber']);
|
$phonenumber->setNationalNumber($terms['phonenumber']);
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
throw new ParsingException("The data for {$key} is "
|
throw new ParsingException("The data for phonenumber is "
|
||||||
. 'not parsable', 0, $ex);
|
. 'not parsable', 0, $ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,15 +267,31 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
|
|||||||
'city' => $city,
|
'city' => $city,
|
||||||
] = $terms + array_fill_keys(self::POSSIBLE_KEYS, null);
|
] = $terms + array_fill_keys(self::POSSIBLE_KEYS, null);
|
||||||
|
|
||||||
foreach (['birthdateBefore', 'birthdateAfter', 'birthdate'] as $v) {
|
if (null !== $birthdate) {
|
||||||
if (null !== ${$v}) {
|
|
||||||
try {
|
try {
|
||||||
${$v} = new DateTime(${$v});
|
$birthdate = new DateTime($birthdate);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw new ParsingException('The date is '
|
throw new ParsingException('The date is '
|
||||||
. 'not parsable', 0, $e);
|
. '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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->personACLAwareRepository
|
return $this->personACLAwareRepository
|
||||||
@ -311,15 +327,31 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
|
|||||||
'city' => $city,
|
'city' => $city,
|
||||||
] = $terms + array_fill_keys(self::POSSIBLE_KEYS, null);
|
] = $terms + array_fill_keys(self::POSSIBLE_KEYS, null);
|
||||||
|
|
||||||
foreach (['birthdateBefore', 'birthdateAfter', 'birthdate'] as $v) {
|
if (null !== $birthdate) {
|
||||||
if (null !== ${$v}) {
|
|
||||||
try {
|
try {
|
||||||
${$v} = new DateTime(${$v});
|
$birthdate = new DateTime($birthdate);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw new ParsingException('The date is '
|
throw new ParsingException('The date is '
|
||||||
. 'not parsable', 0, $e);
|
. '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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->personACLAwareRepository
|
return $this->personACLAwareRepository
|
||||||
|
@ -78,15 +78,14 @@ class ParticipationOverlapValidator extends ConstraintValidator
|
|||||||
|
|
||||||
if ($overlaps->hasIntersections()) {
|
if ($overlaps->hasIntersections()) {
|
||||||
foreach ($overlaps->getIntersections() as [$start, $end, $ids]) {
|
foreach ($overlaps->getIntersections() as [$start, $end, $ids]) {
|
||||||
$msg = null === $end ? $constraint->message :
|
$msg = $constraint->message;
|
||||||
$constraint->message;
|
|
||||||
|
|
||||||
$this->context->buildViolation($msg)
|
$this->context->buildViolation($msg)
|
||||||
->setParameters([
|
->setParameters([
|
||||||
'{{ start }}' => $start->format('d-m-Y'),
|
'{{ start }}' => $start->format('d-m-Y'),
|
||||||
'{{ end }}' => null === $end ? null : $end->format('d-m-Y'),
|
'{{ end }}' => null === $end ? null : $end->format('d-m-Y'),
|
||||||
'{{ ids }}' => $ids,
|
'{{ ids }}' => $ids,
|
||||||
'{{ name }}' => $this->personRender->renderString($participation->getPerson(), []),
|
'{{ name }}' => $this->personRender->renderString($participations[0]->getPerson(), []),
|
||||||
])
|
])
|
||||||
->addViolation();
|
->addViolation();
|
||||||
}
|
}
|
||||||
|
@ -59,10 +59,6 @@ class ThirdPartyChoiceLoader implements ChoiceLoaderInterface
|
|||||||
$choices = [];
|
$choices = [];
|
||||||
|
|
||||||
foreach ($values as $value) {
|
foreach ($values as $value) {
|
||||||
if (null === $value || '' === $value) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$party = $this->partyRepository->find($value);
|
$party = $this->partyRepository->find($value);
|
||||||
|
|
||||||
if (false === in_array($this->center, $party->getCenters()->toArray(), true)) {
|
if (false === in_array($this->center, $party->getCenters()->toArray(), true)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user