mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-31 12:03:48 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -13,8 +13,6 @@ namespace Chill\PersonBundle\Export\Helper;
|
||||
|
||||
use Chill\PersonBundle\Repository\PersonRepository;
|
||||
use Chill\PersonBundle\Templating\Entity\PersonRenderInterface;
|
||||
use function count;
|
||||
use const SORT_NUMERIC;
|
||||
|
||||
class LabelPersonHelper
|
||||
{
|
||||
@@ -33,7 +31,7 @@ class LabelPersonHelper
|
||||
|
||||
$decoded = json_decode((string) $value, null, 512, JSON_THROW_ON_ERROR);
|
||||
|
||||
if (0 === count($decoded)) {
|
||||
if (0 === \count($decoded)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -52,7 +50,7 @@ class LabelPersonHelper
|
||||
},
|
||||
array_unique(
|
||||
array_filter($decoded, static fn (?int $id) => null !== $id),
|
||||
SORT_NUMERIC
|
||||
\SORT_NUMERIC
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@@ -96,10 +96,10 @@ final readonly class ListAccompanyingPeriodHelper
|
||||
}
|
||||
|
||||
return match ($key) {
|
||||
'stepSince', 'openingDate', 'closingDate', 'referrerSince', 'acpCreatedAt', 'acpUpdatedAt' => $this->dateTimeHelper->getLabel('export.list.acp.' . $key),
|
||||
'stepSince', 'openingDate', 'closingDate', 'referrerSince', 'acpCreatedAt', 'acpUpdatedAt' => $this->dateTimeHelper->getLabel('export.list.acp.'.$key),
|
||||
'origin', 'closingMotive', 'job' => function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.list.acp.' . $key;
|
||||
return 'export.list.acp.'.$key;
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
@@ -108,10 +108,10 @@ final readonly class ListAccompanyingPeriodHelper
|
||||
|
||||
return $this->translatableStringHelper->localize(json_decode((string) $value, true, 512, JSON_THROW_ON_ERROR));
|
||||
},
|
||||
'acpCreatedBy', 'acpUpdatedBy', 'referrer' => $this->userHelper->getLabel($key, $values, 'export.list.acp.' . $key),
|
||||
'acpCreatedBy', 'acpUpdatedBy', 'referrer' => $this->userHelper->getLabel($key, $values, 'export.list.acp.'.$key),
|
||||
'locationPersonName', 'requestorPerson' => function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.list.acp.' . $key;
|
||||
return 'export.list.acp.'.$key;
|
||||
}
|
||||
|
||||
if (null === $value || null === $person = $this->personRepository->find($value)) {
|
||||
@@ -122,7 +122,7 @@ final readonly class ListAccompanyingPeriodHelper
|
||||
},
|
||||
'requestorThirdParty' => function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.list.acp.' . $key;
|
||||
return 'export.list.acp.'.$key;
|
||||
}
|
||||
|
||||
if (null === $value || null === $thirdparty = $this->thirdPartyRepository->find($value)) {
|
||||
@@ -133,7 +133,7 @@ final readonly class ListAccompanyingPeriodHelper
|
||||
},
|
||||
'scopes' => function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.list.acp.' . $key;
|
||||
return 'export.list.acp.'.$key;
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
@@ -150,7 +150,7 @@ final readonly class ListAccompanyingPeriodHelper
|
||||
},
|
||||
'socialIssues' => function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.list.acp.' . $key;
|
||||
return 'export.list.acp.'.$key;
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
@@ -184,7 +184,7 @@ final readonly class ListAccompanyingPeriodHelper
|
||||
},
|
||||
default => static function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.list.acp.' . $key;
|
||||
return 'export.list.acp.'.$key;
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
@@ -286,9 +286,9 @@ final readonly class ListAccompanyingPeriodHelper
|
||||
|
||||
$qb
|
||||
// scopes
|
||||
->addSelect('(SELECT AGGREGATE(scope.name) FROM ' . Scope::class . ' scope WHERE scope MEMBER OF acp.scopes) AS scopes')
|
||||
->addSelect('(SELECT AGGREGATE(scope.name) FROM '.Scope::class.' scope WHERE scope MEMBER OF acp.scopes) AS scopes')
|
||||
// social issues
|
||||
->addSelect('(SELECT AGGREGATE(socialIssue.id) FROM ' . SocialIssue::class . ' socialIssue WHERE socialIssue MEMBER OF acp.socialIssues) AS socialIssues');
|
||||
->addSelect('(SELECT AGGREGATE(socialIssue.id) FROM '.SocialIssue::class.' socialIssue WHERE socialIssue MEMBER OF acp.socialIssues) AS socialIssues');
|
||||
|
||||
// add parameter
|
||||
$qb->setParameter('calcDate', $calcDate);
|
||||
|
@@ -21,16 +21,11 @@ use Chill\MainBundle\Repository\UserRepositoryInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Repository\MaritalStatusRepositoryInterface;
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||
use RuntimeException;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function in_array;
|
||||
use function strlen;
|
||||
|
||||
/**
|
||||
* Helper for list person: provide:.
|
||||
@@ -88,7 +83,7 @@ class ListPersonHelper
|
||||
return [
|
||||
...array_filter(
|
||||
ListPersonHelper::FIELDS,
|
||||
fn (string $key) => !in_array($key, ['address_fields', 'lifecycleUpdate'], true)
|
||||
fn (string $key) => !\in_array($key, ['address_fields', 'lifecycleUpdate'], true)
|
||||
),
|
||||
...$this->addressHelper->getKeys(ExportAddressHelper::F_ALL, 'address_fields'),
|
||||
...['createdAt', 'createdBy', 'updatedAt', 'updatedBy'],
|
||||
@@ -98,10 +93,10 @@ class ListPersonHelper
|
||||
/**
|
||||
* @param array<value-of<self::FIELDS>> $fields
|
||||
*/
|
||||
public function addSelect(QueryBuilder $qb, array $fields, DateTimeImmutable $computedDate): void
|
||||
public function addSelect(QueryBuilder $qb, array $fields, \DateTimeImmutable $computedDate): void
|
||||
{
|
||||
foreach (ListPersonHelper::FIELDS as $f) {
|
||||
if (!in_array($f, $fields, true)) {
|
||||
if (!\in_array($f, $fields, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -125,7 +120,7 @@ class ListPersonHelper
|
||||
break;
|
||||
|
||||
case 'spokenLanguages':
|
||||
$qb->addSelect('(SELECT AGGREGATE(language.id) FROM ' . Language::class . ' language WHERE language MEMBER OF person.spokenLanguages) AS spokenLanguages');
|
||||
$qb->addSelect('(SELECT AGGREGATE(language.id) FROM '.Language::class.' language WHERE language MEMBER OF person.spokenLanguages) AS spokenLanguages');
|
||||
|
||||
break;
|
||||
|
||||
@@ -241,18 +236,17 @@ class ListPersonHelper
|
||||
}
|
||||
|
||||
// warning: won't work with DateTimeImmutable as we reset time a few lines later
|
||||
$date = DateTime::createFromFormat('Y-m-d', $value);
|
||||
$date = \DateTime::createFromFormat('Y-m-d', $value);
|
||||
$hasTime = false;
|
||||
|
||||
if (false === $date) {
|
||||
$date = DateTime::createFromFormat('Y-m-d H:i:s', $value);
|
||||
$date = \DateTime::createFromFormat('Y-m-d H:i:s', $value);
|
||||
$hasTime = true;
|
||||
}
|
||||
|
||||
// check that the creation could occurs.
|
||||
if (false === $date) {
|
||||
throw new Exception(sprintf('The value %s could '
|
||||
. 'not be converted to %s', $value, DateTime::class));
|
||||
throw new \Exception(sprintf('The value %s could not be converted to %s', $value, \DateTime::class));
|
||||
}
|
||||
|
||||
if (!$hasTime) {
|
||||
@@ -370,8 +364,8 @@ class ListPersonHelper
|
||||
};
|
||||
|
||||
default:
|
||||
if (!in_array($key, self::getAllPossibleFields(), true)) {
|
||||
throw new RuntimeException("this key is not supported by this helper: {$key}");
|
||||
if (!\in_array($key, self::getAllPossibleFields(), true)) {
|
||||
throw new \RuntimeException("this key is not supported by this helper: {$key}");
|
||||
}
|
||||
|
||||
// for fields which are associated with person
|
||||
@@ -385,9 +379,9 @@ class ListPersonHelper
|
||||
}
|
||||
}
|
||||
|
||||
private function addCurrentAddressAt(QueryBuilder $qb, DateTimeImmutable $date): void
|
||||
private function addCurrentAddressAt(QueryBuilder $qb, \DateTimeImmutable $date): void
|
||||
{
|
||||
if (!(in_array('personHouseholdAddress', $qb->getAllAliases(), true))) {
|
||||
if (!\in_array('personHouseholdAddress', $qb->getAllAliases(), true)) {
|
||||
$qb
|
||||
->leftJoin('person.householdAddresses', 'personHouseholdAddress')
|
||||
->andWhere(
|
||||
|
Reference in New Issue
Block a user