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') ->notPath('tests/app')
->ignoreDotFiles(true) ->ignoreDotFiles(true)
->name('**.php') ->name('**.php')
; ;
$config = new PhpCsFixer\Config(); $config = new PhpCsFixer\Config();
$config $config

View File

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

View File

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

View File

@ -73,7 +73,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
}; };
case 'scopesNames': 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: default:
return $this->helper->getLabels($key, $values, $data); return $this->helper->getLabels($key, $values, $data);

View File

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

View File

@ -512,7 +512,9 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
*/ */
public function getUsers(): Collection 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 public function hasCalendarRange(): bool
@ -597,7 +599,9 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
} }
$invite = $this->invites $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(); ->first();
$this->removeInvite($invite); $this->removeInvite($invite);

View File

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

View File

@ -167,7 +167,9 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
] ]
)->toArray(); )->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); $existingIdsInRange = $this->calendarRangeRepository->findRemoteIdsPresent($ids);
$existingIdsInCalendar = $this->calendarRepository->findRemoteIdsPresent($ids); $existingIdsInCalendar = $this->calendarRepository->findRemoteIdsPresent($ids);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -42,7 +42,9 @@ class IdToEntityDataTransformer implements DataTransformerInterface
{ {
$this->repository = $repository; $this->repository = $repository;
$this->multiple = $multiple; $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); $meta = $workflow->getMetadataStore()->getPlaceMetadata($to);
if ( if (
!array_key_exists('isFinal', $meta) || false === $meta['isFinal'] !array_key_exists('isFinal', $meta) || false === $meta['isFinal']
) { ) {
$toFinal = false; $toFinal = false;
} }
} }

View File

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

View File

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

View File

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

View File

@ -33,7 +33,7 @@ final class DefaultScopeResolverTest extends TestCase
public function testHasScopeInterface() public function testHasScopeInterface()
{ {
$scope = new Scope(); $scope = new Scope();
$entity = new class($scope) implements HasScopeInterface { $entity = new class ($scope) implements HasScopeInterface {
public function __construct(Scope $scope) public function __construct(Scope $scope)
{ {
$this->scope = $scope; $this->scope = $scope;
@ -52,7 +52,7 @@ final class DefaultScopeResolverTest extends TestCase
public function testHasScopesInterface() 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) public function __construct(Scope $scopeA, Scope $scopeB)
{ {
$this->scopes = [$scopeA, $scopeB]; $this->scopes = [$scopeA, $scopeB];

View File

@ -34,7 +34,7 @@ final class ScopeResolverDispatcherTest extends TestCase
public function testHasScopeInterface() public function testHasScopeInterface()
{ {
$scope = new Scope(); $scope = new Scope();
$entity = new class($scope) implements HasScopeInterface { $entity = new class ($scope) implements HasScopeInterface {
public function __construct(Scope $scope) public function __construct(Scope $scope)
{ {
$this->scope = $scope; $this->scope = $scope;
@ -52,7 +52,7 @@ final class ScopeResolverDispatcherTest extends TestCase
public function testHasScopesInterface() 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) public function __construct(Scope $scopeA, Scope $scopeB)
{ {
$this->scopes = [$scopeA, $scopeB]; $this->scopes = [$scopeA, $scopeB];

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -114,7 +114,7 @@ final class AccompanyingPeriodSocialIssueConsistencyEntityListenerTest extends T
protected function generateClass(AccompanyingPeriod $period, Collection $socialIssues): AccompanyingPeriodLinkedWithSocialIssuesEntityInterface 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 Collection $socialIssues;
public AccompanyingPeriod $period; public AccompanyingPeriod $period;

View File

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

View File

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

View File

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