DX: fix cs

This commit is contained in:
Julien Fastré 2023-02-06 17:47:54 +01:00
parent 4b2c330d22
commit 70871176fc
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
29 changed files with 100 additions and 74 deletions

View File

@ -18,7 +18,7 @@ $finder
->notPath('tests/app')
->ignoreDotFiles(true)
->name('**.php')
;
;
$config = new PhpCsFixer\Config();
$config

View File

@ -651,8 +651,8 @@ final class ActivityController extends AbstractController
throw $this->createNotFoundException('Accompanying Period not found');
}
// TODO Add permission
// $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
// TODO Add permission
// $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
} else {
throw $this->createNotFoundException('Person or Accompanying Period not found');
}

View File

@ -58,7 +58,8 @@ class DateAggregator implements AggregatorInterface
break;
case 'year':
$fmt = 'YYYY'; $order = 'DESC';
$fmt = 'YYYY';
$order = 'DESC';
break; // order DESC does not works !

View File

@ -73,7 +73,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
};
case 'scopesNames':
return $this->translatableStringExportLabelHelper->getLabelMulti($key, $values, ListActivityHelper::MSG_KEY . 'course circles');
return $this->translatableStringExportLabelHelper->getLabelMulti($key, $values, ListActivityHelper::MSG_KEY . 'course circles');
default:
return $this->helper->getLabels($key, $values, $data);

View File

@ -53,6 +53,11 @@ class ResourceKindRepository implements ObjectRepository
->getResult();
}
public function findOneByKind(string $kind): ?ResourceKind
{
return $this->repository->findOneBy(['kind' => $kind]) ;
}
/**
* @return ResourceType[]
*/

View File

@ -512,7 +512,9 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
*/
public function getUsers(): Collection
{
return $this->getInvites()->map(static function (Invite $i) { return $i->getUser(); });
return $this->getInvites()->map(static function (Invite $i) {
return $i->getUser();
});
}
public function hasCalendarRange(): bool
@ -597,7 +599,9 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
}
$invite = $this->invites
->filter(static function (Invite $invite) use ($user) { return $invite->getUser() === $user; })
->filter(static function (Invite $invite) use ($user) {
return $invite->getUser() === $user;
})
->first();
$this->removeInvite($invite);

View File

@ -89,10 +89,14 @@ class CalendarToRemoteHandler implements MessageHandlerInterface
$newInvites = array_filter(
array_map(
function ($id) { return $this->inviteRepository->find($id); },
function ($id) {
return $this->inviteRepository->find($id);
},
$calendarMessage->getNewInvitesIds(),
),
static function (?Invite $invite) { return null !== $invite; }
static function (?Invite $invite) {
return null !== $invite;
}
);
$this->calendarConnector->syncCalendar(

View File

@ -167,7 +167,9 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
]
)->toArray();
$ids = array_map(static function ($item) { return $item['id']; }, $bareEvents['value']);
$ids = array_map(static function ($item) {
return $item['id'];
}, $bareEvents['value']);
$existingIdsInRange = $this->calendarRangeRepository->findRemoteIdsPresent($ids);
$existingIdsInCalendar = $this->calendarRepository->findRemoteIdsPresent($ids);

View File

@ -215,7 +215,7 @@ class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface
$qb
->where(
$qb->expr()->orX(
// the calendar where the person is the main person:
// the calendar where the person is the main person:
$qb->expr()->eq('c.person', ':person'),
// when the calendar is in a reachable period, and contains person
$qb->expr()->andX(

View File

@ -96,7 +96,7 @@ final class CalendarTypeTest extends TypeTestCase
];
$calendar = new Calendar();
$calendar->setMainUser(new class() extends User {
$calendar->setMainUser(new class () extends User {
public function getId()
{
return '1';
@ -114,8 +114,12 @@ final class CalendarTypeTest extends TypeTestCase
$this->assertEquals(8, $calendar->getCalendarRange()->getId());
$this->assertEquals(9, $calendar->getLocation()->getId());
$this->assertEquals(true, $calendar->getSendSMS());
$this->assertContains(2, $calendar->getUsers()->map(static function (User $u) { return $u->getId(); }));
$this->assertContains(3, $calendar->getUsers()->map(static function (User $u) { return $u->getId(); }));
$this->assertContains(2, $calendar->getUsers()->map(static function (User $u) {
return $u->getId();
}));
$this->assertContains(3, $calendar->getUsers()->map(static function (User $u) {
return $u->getId();
}));
}
protected function getExtensions()
@ -147,7 +151,9 @@ final class CalendarTypeTest extends TypeTestCase
->will(static function ($args) {
return implode(
',',
array_map(static function ($p) { return $p->getId(); }, $args[0])
array_map(static function ($p) {
return $p->getId();
}, $args[0])
);
});
$transformer->transform(Argument::exact(null))
@ -156,7 +162,9 @@ final class CalendarTypeTest extends TypeTestCase
->will(static function ($args) {
return implode(
',',
array_map(static function ($p) { return $p->getId(); }, $args[0]->toArray())
array_map(static function ($p) {
return $p->getId();
}, $args[0]->toArray())
);
});
$transformer->reverseTransform(Argument::type('string'))

View File

@ -174,8 +174,8 @@ class EventSearch extends AbstractSearch
}
if (
(isset($terms['name']) || isset($terms['_default']))
&& (!empty($terms['name']) || !empty($terms['_default']))
(isset($terms['name']) || isset($terms['_default']))
&& (!empty($terms['name']) || !empty($terms['_default']))
) {
// the form with name:"xyz" has precedence
$name = $terms['name'] ?? $terms['_default'];

View File

@ -50,8 +50,8 @@ class LoadLanguages extends AbstractFixture implements ContainerAwareInterface,
foreach (Intl::getLanguageBundle()->getLanguageNames() as $code => $language) {
if (
!in_array($code, $this->regionalVersionToInclude, true)
&& !in_array($code, $this->ancientToExclude, true)
!in_array($code, $this->regionalVersionToInclude, true)
&& !in_array($code, $this->ancientToExclude, true)
) {
$lang = (new Language())
->setId($code)

View File

@ -274,7 +274,7 @@ class Configuration implements ConfigurationInterface
->end()
->end() // end of root/children
->end() // end of root
;
;
$rootNode->children()
->arrayNode('add_address')->addDefaultsIfNotSet()->children()

View File

@ -42,7 +42,9 @@ class IdToEntityDataTransformer implements DataTransformerInterface
{
$this->repository = $repository;
$this->multiple = $multiple;
$this->getId = $getId ?? static function (object $o) { return $o->getId(); };
$this->getId = $getId ?? static function (object $o) {
return $o->getId();
};
}
/**

View File

@ -137,8 +137,8 @@ class WorkflowStepType extends AbstractType
$meta = $workflow->getMetadataStore()->getPlaceMetadata($to);
if (
!array_key_exists('isFinal', $meta) || false === $meta['isFinal']
) {
!array_key_exists('isFinal', $meta) || false === $meta['isFinal']
) {
$toFinal = false;
}
}

View File

@ -124,12 +124,12 @@ class PaginatorFactory
return array_merge(
$this->router->getContext()->getParameters(),
// get the route parameters
$this->requestStack
->getCurrentRequest()
->attributes->get('_route_params'),
$this->requestStack
->getCurrentRequest()
->attributes->get('_route_params'),
// get the query parameters
$this->requestStack
->getCurrentRequest()->query->all()
$this->requestStack
->getCurrentRequest()->query->all()
);
}
}

View File

@ -267,15 +267,15 @@ final class ExportManagerTest extends KernelTestCase
)
->willReturn(static function ($value) {
switch ($value) {
case 0:
case 1:
return $value;
case 0:
case 1:
return $value;
case '_header':
return 'export';
case '_header':
return 'export';
default: throw new RuntimeException(sprintf('The value %s is not valid', $value));
}
default: throw new RuntimeException(sprintf('The value %s is not valid', $value));
}
});
$export->getQueryKeys(Argument::Type('array'))->willReturn(['export']);
@ -307,15 +307,15 @@ final class ExportManagerTest extends KernelTestCase
)
->willReturn(static function ($value) {
switch ($value) {
case '_header': return 'foo_header';
case '_header': return 'foo_header';
case 'cat a': return 'label cat a';
case 'cat a': return 'label cat a';
case 'cat b': return 'label cat b';
case 'cat b': return 'label cat b';
default:
throw new RuntimeException(sprintf('This value (%s) is not valid', $value));
}
default:
throw new RuntimeException(sprintf('This value (%s) is not valid', $value));
}
});
$aggregator->addRole()->willReturn(null);
//$aggregator->addRole()->shouldBeCalled();

View File

@ -77,13 +77,13 @@ final class IdToEntityDataTransformerTest extends TestCase
public function testTransformMulti()
{
$o1 = new class() {
$o1 = new class () {
public function getId()
{
return 1;
}
};
$o2 = new class() {
$o2 = new class () {
public function getId()
{
return 2;
@ -104,7 +104,7 @@ final class IdToEntityDataTransformerTest extends TestCase
public function testTransformSingle()
{
$o = new class() {
$o = new class () {
public function getId()
{
return 1;

View File

@ -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];

View File

@ -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];

View File

@ -63,18 +63,18 @@ class RoleScopeScopePresence extends ConstraintValidator
//if the role scope should have a scope
if (
!in_array($value->getRole(), $this->roleProvider->getRolesWithoutScopes(), true)
&& $value->getScope() === null
) {
!in_array($value->getRole(), $this->roleProvider->getRolesWithoutScopes(), true)
&& $value->getScope() === null
) {
$this->context->buildViolation($constraint->messagePresenceRequired)
->setParameter('%role%', $this->translator->trans($value->getRole()))
->addViolation();
$this->logger->debug('the role scope should have a scope, but scope is null. Violation build.');
} elseif // if the scope should be null
(
in_array($value->getRole(), $this->roleProvider->getRolesWithoutScopes(), true)
&& null !== $value->getScope()
) {
(
in_array($value->getRole(), $this->roleProvider->getRolesWithoutScopes(), true)
&& null !== $value->getScope()
) {
$this->context->buildViolation($constraint->messageNullRequired)
->setParameter('%role%', $this->translator->trans($value->getRole()))
->addViolation();

View File

@ -343,7 +343,7 @@ final class ImportPeopleFromCSVCommand extends Command
$person->setMobilenumber($value);
break;
// we just keep the column number for those data
// we just keep the column number for those data
case 'postalcode':
$postalCodeValue = $value;

View File

@ -129,7 +129,7 @@ class Configuration implements ConfigurationInterface
->defaultValue(false)
->end()
->end() // children of 'root', parent = root
;
;
return $treeBuilder;
}

View File

@ -746,7 +746,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
foreach ($this->getAccompanyingPeriodParticipations()
->map(fn (AccompanyingPeriodParticipation $app) => $app->getAccompanyingPeriod())
as $period
) {
) {
if (!$result->contains($period)) {
$result->add($period);
}

View File

@ -65,9 +65,9 @@ class AccompanyingPeriodType extends AbstractType
$accompanyingPeriod = $options['data'];
if (
('close' === $options['period_action'])
|| ('create' === $options['period_action'])
|| ('update' === $options['period_action'] && !$accompanyingPeriod->isOpen())
('close' === $options['period_action'])
|| ('create' === $options['period_action'])
|| ('update' === $options['period_action'] && !$accompanyingPeriod->isOpen())
) {
$builder->add('closingDate', DateType::class, [
'required' => true,

View File

@ -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;

View File

@ -248,7 +248,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface
->getRepository(\Chill\MainBundle\Entity\Country::class);
// load all countries in a single query
$countryRepository->findBy(['countryCode' => $values]);
$countryRepository->findBy(['countryCode' => $values]);
return function ($value) use ($key, $countryRepository) {
if ('_header' === $value) {

View File

@ -92,7 +92,7 @@ final class TimelineProviderTest extends WebTestCase
{
//static::$em->refresh($this->person);
//static::$em->refresh($this->report);
// static::$em->remove($this->person);
// static::$em->remove($this->person);
//static::$em->remove($this->report);
}

View File

@ -69,15 +69,15 @@ class Convert
$content = $this->storedObjectManager->read($storedObject);
$url = sprintf('%s/cool/convert-to/pdf', $this->collaboraDomain);
$form = new FormDataPart([
'data' => new DataPart($content, $storedObject->getUuid()->toString(), $storedObject->getType()),
]);
$response = $this->httpClient->request('POST', $url, [
'headers' => $form->getPreparedHeaders()->toArray(),
'body' => $form->bodyToString(),
'timeout' => 10,
]);
$url = sprintf('%s/cool/convert-to/pdf', $this->collaboraDomain);
$form = new FormDataPart([
'data' => new DataPart($content, $storedObject->getUuid()->toString(), $storedObject->getType()),
]);
$response = $this->httpClient->request('POST', $url, [
'headers' => $form->getPreparedHeaders()->toArray(),
'body' => $form->bodyToString(),
'timeout' => 10,
]);
try {
return new Response($response->getContent(), Response::HTTP_OK, [