mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-06 23:04:58 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -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