mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
DX: more code style fixes
This commit is contained in:
parent
5655f953d7
commit
055acbf43c
@ -369,8 +369,12 @@ final class ActivityControllerTest extends WebTestCase
|
||||
$center
|
||||
);
|
||||
$reachableScopesId = array_intersect(
|
||||
array_map(static function ($s) { return $s->getId(); }, $reachableScopesDelete),
|
||||
array_map(static function ($s) { return $s->getId(); }, $reachableScopesUpdate)
|
||||
array_map(static function ($s) {
|
||||
return $s->getId();
|
||||
}, $reachableScopesDelete),
|
||||
array_map(static function ($s) {
|
||||
return $s->getId();
|
||||
}, $reachableScopesUpdate)
|
||||
);
|
||||
|
||||
if (count($reachableScopesId) === 0) {
|
||||
|
@ -188,7 +188,9 @@ final class ActivityTypeTest extends KernelTestCase
|
||||
|
||||
// map all the values in an array
|
||||
$values = array_map(
|
||||
static function ($choice) { return $choice->value; },
|
||||
static function ($choice) {
|
||||
return $choice->value;
|
||||
},
|
||||
$view['activity']['durationTime']->vars['choices']
|
||||
);
|
||||
|
||||
|
@ -31,7 +31,9 @@ class ConfigRepository
|
||||
|
||||
public function getChargesKeys(bool $onlyActive = false): array
|
||||
{
|
||||
return array_map(static function ($element) { return $element['key']; }, $this->getCharges($onlyActive));
|
||||
return array_map(static function ($element) {
|
||||
return $element['key'];
|
||||
}, $this->getCharges($onlyActive));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,7 +52,9 @@ class ConfigRepository
|
||||
|
||||
public function getResourcesKeys(bool $onlyActive = false): array
|
||||
{
|
||||
return array_map(static function ($element) { return $element['key']; }, $this->getResources($onlyActive));
|
||||
return array_map(static function ($element) {
|
||||
return $element['key'];
|
||||
}, $this->getResources($onlyActive));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,14 +74,18 @@ class ConfigRepository
|
||||
private function getCharges(bool $onlyActive = false): array
|
||||
{
|
||||
return $onlyActive ?
|
||||
array_filter($this->charges, static function ($el) { return $el['active']; })
|
||||
array_filter($this->charges, static function ($el) {
|
||||
return $el['active'];
|
||||
})
|
||||
: $this->charges;
|
||||
}
|
||||
|
||||
private function getResources(bool $onlyActive = false): array
|
||||
{
|
||||
return $onlyActive ?
|
||||
array_filter($this->resources, static function ($el) { return $el['active']; })
|
||||
array_filter($this->resources, static function ($el) {
|
||||
return $el['active'];
|
||||
})
|
||||
: $this->resources;
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,9 @@ class SummaryBudget implements SummaryBudgetInterface
|
||||
];
|
||||
}
|
||||
|
||||
$personIds = $household->getCurrentPersons()->map(static function (Person $p) { return $p->getId(); });
|
||||
$personIds = $household->getCurrentPersons()->map(static function (Person $p) {
|
||||
return $p->getId();
|
||||
});
|
||||
$ids = implode(', ', array_fill(0, count($personIds), '?'));
|
||||
|
||||
$parameters = [...$personIds, $household->getId()];
|
||||
|
@ -239,7 +239,9 @@ final class ParticipationControllerTest extends WebTestCase
|
||||
$this->personsIdsCache = array_merge(
|
||||
$this->personsIdsCache,
|
||||
$event->getParticipations()->map(
|
||||
static function ($p) { return $p->getPerson()->getId(); }
|
||||
static function ($p) {
|
||||
return $p->getPerson()->getId();
|
||||
}
|
||||
)
|
||||
->toArray()
|
||||
);
|
||||
@ -303,7 +305,9 @@ final class ParticipationControllerTest extends WebTestCase
|
||||
$event = $this->getRandomEventWithMultipleParticipations();
|
||||
|
||||
$persons_id = implode(',', $event->getParticipations()->map(
|
||||
static function ($p) { return $p->getPerson()->getId(); }
|
||||
static function ($p) {
|
||||
return $p->getPerson()->getId();
|
||||
}
|
||||
)->toArray());
|
||||
|
||||
$crawler = $this->client->request(
|
||||
@ -329,7 +333,9 @@ final class ParticipationControllerTest extends WebTestCase
|
||||
$nbParticipations = $event->getParticipations()->count();
|
||||
// get the persons_id participating on this event
|
||||
$persons_id = $event->getParticipations()->map(
|
||||
static function ($p) { return $p->getPerson()->getId(); }
|
||||
static function ($p) {
|
||||
return $p->getPerson()->getId();
|
||||
}
|
||||
)->toArray();
|
||||
// exclude the existing persons_ids from the new person
|
||||
$this->personsIdsCache = array_merge($this->personsIdsCache, $persons_id);
|
||||
|
@ -177,7 +177,9 @@ class ExportAddressHelper
|
||||
$prefixes = array_merge(
|
||||
$prefixes,
|
||||
array_map(
|
||||
static function ($item) use ($prefix) { return $prefix . $item; },
|
||||
static function ($item) use ($prefix) {
|
||||
return $prefix . $item;
|
||||
},
|
||||
self::COLUMN_MAPPING[$key]
|
||||
)
|
||||
);
|
||||
|
@ -51,7 +51,9 @@ class EntityToJsonTransformer implements DataTransformerInterface
|
||||
}
|
||||
|
||||
return array_map(
|
||||
function ($item) { return $this->denormalizeOne($item); },
|
||||
function ($item) {
|
||||
return $this->denormalizeOne($item);
|
||||
},
|
||||
$denormalized
|
||||
);
|
||||
}
|
||||
|
@ -66,7 +66,9 @@ class ScopePickerType extends AbstractType
|
||||
$options['role'] instanceof Role ? $options['role']->getRole() : $options['role'],
|
||||
$options['center']
|
||||
),
|
||||
static function (Scope $s) { return $s->isActive(); }
|
||||
static function (Scope $s) {
|
||||
return $s->isActive();
|
||||
}
|
||||
);
|
||||
|
||||
if (0 === count($items)) {
|
||||
|
@ -134,7 +134,9 @@ final class NotificationTest extends KernelTestCase
|
||||
$this->assertEquals($senderId, $notification->getSender()->getId());
|
||||
$this->assertCount(count($addressesIds), $notification->getUnreadBy());
|
||||
|
||||
$unreadIds = $notification->getUnreadBy()->map(static function (User $u) { return $u->getId(); });
|
||||
$unreadIds = $notification->getUnreadBy()->map(static function (User $u) {
|
||||
return $u->getId();
|
||||
});
|
||||
|
||||
foreach ($addressesIds as $addresseeId) {
|
||||
$this->assertContains($addresseeId, $unreadIds);
|
||||
|
@ -96,7 +96,9 @@ final class ScopePickerTypeTest extends TypeTestCase
|
||||
|
||||
$translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class);
|
||||
$translatableStringHelper->localize(Argument::type('array'))->will(
|
||||
static function ($args) { return $args[0]['fr']; }
|
||||
static function ($args) {
|
||||
return $args[0]['fr'];
|
||||
}
|
||||
);
|
||||
|
||||
$type = new ScopePickerType(
|
||||
|
@ -211,7 +211,9 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
$centerA
|
||||
);
|
||||
|
||||
$usernames = array_map(static function (User $u) { return $u->getUsername(); }, $users);
|
||||
$usernames = array_map(static function (User $u) {
|
||||
return $u->getUsername();
|
||||
}, $users);
|
||||
|
||||
$this->assertContains('center a_social', $usernames);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ final class DefaultScopeResolverTest extends TestCase
|
||||
public function testHasScopeInterface()
|
||||
{
|
||||
$scope = new Scope();
|
||||
$entity = new class($scope) implements HasScopeInterface {
|
||||
$entity = new class ($scope) implements HasScopeInterface {
|
||||
public function __construct(Scope $scope)
|
||||
{
|
||||
$this->scope = $scope;
|
||||
@ -52,7 +52,7 @@ final class DefaultScopeResolverTest extends TestCase
|
||||
|
||||
public function testHasScopesInterface()
|
||||
{
|
||||
$entity = new class($scopeA = new Scope(), $scopeB = new Scope()) implements HasScopesInterface {
|
||||
$entity = new class ($scopeA = new Scope(), $scopeB = new Scope()) implements HasScopesInterface {
|
||||
public function __construct(Scope $scopeA, Scope $scopeB)
|
||||
{
|
||||
$this->scopes = [$scopeA, $scopeB];
|
||||
|
@ -34,7 +34,7 @@ final class ScopeResolverDispatcherTest extends TestCase
|
||||
public function testHasScopeInterface()
|
||||
{
|
||||
$scope = new Scope();
|
||||
$entity = new class($scope) implements HasScopeInterface {
|
||||
$entity = new class ($scope) implements HasScopeInterface {
|
||||
public function __construct(Scope $scope)
|
||||
{
|
||||
$this->scope = $scope;
|
||||
@ -52,7 +52,7 @@ final class ScopeResolverDispatcherTest extends TestCase
|
||||
|
||||
public function testHasScopesInterface()
|
||||
{
|
||||
$entity = new class($scopeA = new Scope(), $scopeB = new Scope()) implements HasScopesInterface {
|
||||
$entity = new class ($scopeA = new Scope(), $scopeB = new Scope()) implements HasScopesInterface {
|
||||
public function __construct(Scope $scopeA, Scope $scopeB)
|
||||
{
|
||||
$this->scopes = [$scopeA, $scopeB];
|
||||
|
@ -107,7 +107,9 @@ class NotificationOnTransition implements EventSubscriberInterface
|
||||
'dest' => $subscriber,
|
||||
'place' => $place,
|
||||
'workflow' => $workflow,
|
||||
'is_dest' => in_array($subscriber->getId(), array_map(static function (User $u) { return $u->getId(); }, $entityWorkflow->futureDestUsers), true),
|
||||
'is_dest' => in_array($subscriber->getId(), array_map(static function (User $u) {
|
||||
return $u->getId();
|
||||
}, $entityWorkflow->futureDestUsers), true),
|
||||
];
|
||||
|
||||
$notification = new Notification();
|
||||
|
@ -114,7 +114,7 @@ final class AccompanyingPeriodSocialIssueConsistencyEntityListenerTest extends T
|
||||
|
||||
protected function generateClass(AccompanyingPeriod $period, Collection $socialIssues): AccompanyingPeriodLinkedWithSocialIssuesEntityInterface
|
||||
{
|
||||
return new class($period, $socialIssues) implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterface {
|
||||
return new class ($period, $socialIssues) implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterface {
|
||||
public Collection $socialIssues;
|
||||
|
||||
public AccompanyingPeriod $period;
|
||||
|
@ -342,7 +342,9 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
|
||||
|
||||
// check that the person id is contained
|
||||
$participationsPersonsIds = array_map(
|
||||
static function ($participation) { return $participation->person->id; },
|
||||
static function ($participation) {
|
||||
return $participation->person->id;
|
||||
},
|
||||
$data->participations
|
||||
);
|
||||
|
||||
|
@ -294,23 +294,49 @@ final class PersonControllerUpdateTest extends WebTestCase
|
||||
public function validTextFieldsProvider()
|
||||
{
|
||||
return [
|
||||
['firstName', 'random Value', static function (Person $person) { return $person->getFirstName(); }],
|
||||
['lastName', 'random Value', static function (Person $person) { return $person->getLastName(); }],
|
||||
['firstName', 'random Value', static function (Person $person) {
|
||||
return $person->getFirstName();
|
||||
}],
|
||||
['lastName', 'random Value', static function (Person $person) {
|
||||
return $person->getLastName();
|
||||
}],
|
||||
// reminder: this value is capitalized
|
||||
['placeOfBirth', 'A PLACE', static function (Person $person) { return $person->getPlaceOfBirth(); }],
|
||||
['birthdate', '1980-12-15', static function (Person $person) { return $person->getBirthdate()->format('Y-m-d'); }],
|
||||
['placeOfBirth', 'A PLACE', static function (Person $person) {
|
||||
return $person->getPlaceOfBirth();
|
||||
}],
|
||||
['birthdate', '1980-12-15', static function (Person $person) {
|
||||
return $person->getBirthdate()->format('Y-m-d');
|
||||
}],
|
||||
// TODO test on phonenumber update
|
||||
// ['phonenumber', '+32123456789', static function (Person $person) { return $person->getPhonenumber(); }],
|
||||
['memo', 'jfkdlmq jkfldmsq jkmfdsq', static function (Person $person) { return $person->getMemo(); }],
|
||||
['countryOfBirth', 'BE', static function (Person $person) { return $person->getCountryOfBirth()->getCountryCode(); }],
|
||||
['nationality', 'FR', static function (Person $person) { return $person->getNationality()->getCountryCode(); }],
|
||||
['placeOfBirth', '', static function (Person $person) { return $person->getPlaceOfBirth(); }],
|
||||
['birthdate', '', static function (Person $person) { return $person->getBirthdate(); }],
|
||||
['memo', 'jfkdlmq jkfldmsq jkmfdsq', static function (Person $person) {
|
||||
return $person->getMemo();
|
||||
}],
|
||||
['countryOfBirth', 'BE', static function (Person $person) {
|
||||
return $person->getCountryOfBirth()->getCountryCode();
|
||||
}],
|
||||
['nationality', 'FR', static function (Person $person) {
|
||||
return $person->getNationality()->getCountryCode();
|
||||
}],
|
||||
['placeOfBirth', '', static function (Person $person) {
|
||||
return $person->getPlaceOfBirth();
|
||||
}],
|
||||
['birthdate', '', static function (Person $person) {
|
||||
return $person->getBirthdate();
|
||||
}],
|
||||
//['phonenumber', '', static function (Person $person) { return $person->getPhonenumber(); }],
|
||||
['memo', '', static function (Person $person) { return $person->getMemo(); }],
|
||||
['countryOfBirth', null, static function (Person $person) { return $person->getCountryOfBirth(); }],
|
||||
['nationality', null, static function (Person $person) { return $person->getNationality(); }],
|
||||
['gender', Person::FEMALE_GENDER, static function (Person $person) { return $person->getGender(); }],
|
||||
['memo', '', static function (Person $person) {
|
||||
return $person->getMemo();
|
||||
}],
|
||||
['countryOfBirth', null, static function (Person $person) {
|
||||
return $person->getCountryOfBirth();
|
||||
}],
|
||||
['nationality', null, static function (Person $person) {
|
||||
return $person->getNationality();
|
||||
}],
|
||||
['gender', Person::FEMALE_GENDER, static function (Person $person) {
|
||||
return $person->getGender();
|
||||
}],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -197,12 +197,24 @@ final class PersonControllerUpdateWithHiddenFieldsTest extends WebTestCase
|
||||
public function validTextFieldsProvider()
|
||||
{
|
||||
return [
|
||||
['firstName', 'random Value', static function (Person $person) { return $person->getFirstName(); }],
|
||||
['lastName', 'random Value', static function (Person $person) { return $person->getLastName(); }],
|
||||
['birthdate', '15-12-1980', static function (Person $person) { return $person->getBirthdate()->format('d-m-Y'); }],
|
||||
['memo', 'jfkdlmq jkfldmsq jkmfdsq', static function (Person $person) { return $person->getMemo(); }],
|
||||
['birthdate', '', static function (Person $person) { return $person->getBirthdate(); }],
|
||||
['gender', Person::FEMALE_GENDER, static function (Person $person) { return $person->getGender(); }],
|
||||
['firstName', 'random Value', static function (Person $person) {
|
||||
return $person->getFirstName();
|
||||
}],
|
||||
['lastName', 'random Value', static function (Person $person) {
|
||||
return $person->getLastName();
|
||||
}],
|
||||
['birthdate', '15-12-1980', static function (Person $person) {
|
||||
return $person->getBirthdate()->format('d-m-Y');
|
||||
}],
|
||||
['memo', 'jfkdlmq jkfldmsq jkmfdsq', static function (Person $person) {
|
||||
return $person->getMemo();
|
||||
}],
|
||||
['birthdate', '', static function (Person $person) {
|
||||
return $person->getBirthdate();
|
||||
}],
|
||||
['gender', Person::FEMALE_GENDER, static function (Person $person) {
|
||||
return $person->getGender();
|
||||
}],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,9 @@ final class MembersEditorTest extends TestCase
|
||||
$this->assertCount(1, $notSharing);
|
||||
$this->assertCount(1, $sharings);
|
||||
|
||||
$getPerson = static function (HouseholdMember $m) { return $m->getPerson(); };
|
||||
$getPerson = static function (HouseholdMember $m) {
|
||||
return $m->getPerson();
|
||||
};
|
||||
|
||||
$this->assertContains($person, $notSharing->map($getPerson));
|
||||
}
|
||||
@ -151,7 +153,9 @@ final class MembersEditorTest extends TestCase
|
||||
$this->assertCount(1, $notSharing);
|
||||
$this->assertCount(0, $sharings);
|
||||
|
||||
$getPerson = static function (HouseholdMember $m) { return $m->getPerson(); };
|
||||
$getPerson = static function (HouseholdMember $m) {
|
||||
return $m->getPerson();
|
||||
};
|
||||
|
||||
$this->assertContains($person, $notSharing->map($getPerson));
|
||||
}
|
||||
|
@ -118,7 +118,9 @@ final class RelationshipDocGenNormalizerTest extends TestCase
|
||||
{
|
||||
$translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class);
|
||||
$translatableStringHelper->localize(Argument::type('array'))->will(
|
||||
static function ($args) { return $args[0][array_keys($args[0])[0]]; }
|
||||
static function ($args) {
|
||||
return $args[0][array_keys($args[0])[0]];
|
||||
}
|
||||
);
|
||||
|
||||
$normalizer = new RelationshipDocGenNormalizer(
|
||||
|
@ -67,7 +67,9 @@ final class TimelineProviderTest extends WebTestCase
|
||||
self::$em
|
||||
->getRepository(\Chill\MainBundle\Entity\Scope::class)
|
||||
->findAll(),
|
||||
static function (Scope $scope) { return $scope->getName()['en'] === 'social'; }
|
||||
static function (Scope $scope) {
|
||||
return $scope->getName()['en'] === 'social';
|
||||
}
|
||||
);
|
||||
|
||||
$report = (new Report())
|
||||
|
Loading…
x
Reference in New Issue
Block a user