Merge branch 'refactor-using-rector-202303' into 'master'

DX: rector rules up to PHP7.3

See merge request Chill-Projet/chill-bundles!513
This commit is contained in:
Julien Fastré 2023-04-27 21:35:30 +00:00
commit b3d881c675
153 changed files with 374 additions and 416 deletions

View File

@ -90,9 +90,7 @@ class CountPerson implements ExportInterface
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{ {
// we gather all center the user choose. // we gather all center the user choose.
$centers = array_map(static function ($el) { $centers = array_map(static fn($el) => $el['center'], $acl);
return $el['center'];
}, $acl);
$qb = $this->entityManager->createQueryBuilder(); $qb = $this->entityManager->createQueryBuilder();

View File

@ -12,14 +12,49 @@ return static function (RectorConfig $rectorConfig): void {
__DIR__ . '/src', __DIR__ . '/src',
]); ]);
$rectorConfig->cacheClass(\Rector\Caching\ValueObject\Storage\FileCacheStorage::class); //$rectorConfig->cacheClass(\Rector\Caching\ValueObject\Storage\FileCacheStorage::class);
$rectorConfig->cacheDirectory(__DIR__.'/.cache/rector'); //$rectorConfig->cacheDirectory(__DIR__ . '/.cache/rector');
// register a single rule // register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
$rectorConfig->disableParallel();
// define sets of rules //define sets of rules
// $rectorConfig->sets([ $rectorConfig->sets([
// LevelSetList::UP_TO_PHP_74 LevelSetList::UP_TO_PHP_73
// ]); ]);
// skip some path...
$rectorConfig->skip([
// make rector stuck for some files
\Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector::class,
// we need to discuss this: are we going to have FALSE in tests instead of an error ?
\Rector\Php71\Rector\FuncCall\CountOnNullRector::class,
// must merge MR500 and review a typing of "ArrayCollection" in entities
\Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector::class,
// remove all PHP80 rules, in order to activate them one by one
\Rector\Php80\Rector\ClassMethod\AddParamBasedOnParentClassMethodRector::class,
\Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class,
\Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector::class,
\Rector\Php80\Rector\FuncCall\ClassOnObjectRector::class,
\Rector\Php80\Rector\ClassConstFetch\ClassOnThisVariableObjectRector::class,
\Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector::class,
\Rector\Php80\Rector\Class_\DoctrineAnnotationClassToAttributeRector::class,
\Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector::class,
\Rector\Php80\Rector\Ternary\GetDebugTypeRector::class,
\Rector\Php80\Rector\FunctionLike\MixedTypeRector::class,
\Rector\Php80\Rector\Property\NestedAnnotationToAttributeRector::class,
\Rector\Php80\Rector\FuncCall\Php8ResourceReturnToObjectRector::class,
\Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector::class,
\Rector\Php80\Rector\ClassMethod\SetStateToStaticRector::class,
\Rector\Php80\Rector\NotIdentical\StrContainsRector::class,
\Rector\Php80\Rector\Identical\StrEndsWithRector::class,
\Rector\Php80\Rector\Identical\StrStartsWithRector::class,
\Rector\Php80\Rector\Class_\StringableForToStringRector::class,
\Rector\Php80\Rector\FuncCall\TokenGetAllToObjectRector::class,
\Rector\Php80\Rector\FunctionLike\UnionTypesRector::class
]);
}; };

View File

@ -50,7 +50,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface
->findAll(); ->findAll();
foreach ($persons as $person) { foreach ($persons as $person) {
$activityNbr = mt_rand(0, 3); $activityNbr = random_int(0, 3);
for ($i = 0; $i < $activityNbr; ++$i) { for ($i = 0; $i < $activityNbr; ++$i) {
$activity = $this->newRandomActivity($person); $activity = $this->newRandomActivity($person);
@ -75,7 +75,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface
// ->setAttendee($this->faker->boolean()) // ->setAttendee($this->faker->boolean())
for ($i = 0; mt_rand(0, 4) > $i; ++$i) { for ($i = 0; random_int(0, 4) > $i; ++$i) {
$reason = $this->getRandomActivityReason(); $reason = $this->getRandomActivityReason();
if (null !== $reason) { if (null !== $reason) {

View File

@ -26,7 +26,7 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder() public function getConfigTreeBuilder()
{ {
$treeBuilder = new TreeBuilder('chill_activity'); $treeBuilder = new TreeBuilder('chill_activity');
$rootNode = $treeBuilder->getRootNode('chill_activity'); $rootNode = $treeBuilder->getRootNode();
$rootNode $rootNode
->children() ->children()

View File

@ -152,7 +152,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
return 'circle'; return 'circle';
} }
return $this->translatableStringHelper->localize(json_decode($value, true)); return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR));
}; };
case 'type_name': case 'type_name':
@ -161,7 +161,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
return 'activity type'; return 'activity type';
} }
return $this->translatableStringHelper->localize(json_decode($value, true)); return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR));
}; };
default: default:

View File

@ -179,7 +179,7 @@ class ListActivityHelper
} }
} }
$decoded = json_decode($value); $decoded = json_decode($value, null, 512, JSON_THROW_ON_ERROR);
return implode( return implode(
'|', '|',

View File

@ -32,7 +32,7 @@ class ActivityReasonCategoryType extends AbstractType
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefaults([ $resolver->setDefaults([
'data_class' => 'Chill\ActivityBundle\Entity\ActivityReasonCategory', 'data_class' => \Chill\ActivityBundle\Entity\ActivityReasonCategory::class,
]); ]);
} }

View File

@ -401,9 +401,7 @@ class ActivityType extends AbstractType
// the datetimetransformer will then handle timezone as GMT // the datetimetransformer will then handle timezone as GMT
$timezoneUTC = new DateTimeZone('GMT'); $timezoneUTC = new DateTimeZone('GMT');
/** @var DateTime $data */ /** @var DateTime $data */
$data = $formEvent->getData() === null ? $data = $formEvent->getData() ?? DateTime::createFromFormat('U', '300');
DateTime::createFromFormat('U', '300') :
$formEvent->getData();
$seconds = $data->getTimezone()->getOffset($data); $seconds = $data->getTimezone()->getOffset($data);
$data->setTimeZone($timezoneUTC); $data->setTimeZone($timezoneUTC);
$data->add(new DateInterval('PT' . $seconds . 'S')); $data->add(new DateInterval('PT' . $seconds . 'S'));

View File

@ -79,15 +79,15 @@ final class TranslatableActivityReasonTest extends TypeTestCase
$request = $prophet->prophesize(); $request = $prophet->prophesize();
$translator = $prophet->prophesize(); $translator = $prophet->prophesize();
$request->willExtend('Symfony\Component\HttpFoundation\Request'); $request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
$request->getLocale()->willReturn($fallbackLocale); $request->getLocale()->willReturn($fallbackLocale);
$requestStack->willExtend('Symfony\Component\HttpFoundation\RequestStack'); $requestStack->willExtend(\Symfony\Component\HttpFoundation\RequestStack::class);
$requestStack->getCurrentRequest()->will(static function () use ($request) { $requestStack->getCurrentRequest()->will(static function () use ($request) {
return $request; return $request;
}); });
$translator->willExtend('Symfony\Component\Translation\Translator'); $translator->willExtend(\Symfony\Component\Translation\Translator::class);
$translator->getFallbackLocales()->willReturn($locale); $translator->getFallbackLocales()->willReturn($locale);
return new TranslatableStringHelper( return new TranslatableStringHelper(

View File

@ -160,7 +160,7 @@ final class ActivityVoterTest extends KernelTestCase
{ {
$token = $this->prophet->prophesize(); $token = $this->prophet->prophesize();
$token $token
->willImplement('\Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); ->willImplement('\\' . \Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class);
if (null === $user) { if (null === $user) {
$token->getUser()->willReturn(null); $token->getUser()->willReturn(null);

View File

@ -22,7 +22,7 @@ class Configuration implements ConfigurationInterface
{ {
$treeBuilder = new TreeBuilder('chill_aside_activity'); $treeBuilder = new TreeBuilder('chill_aside_activity');
$treeBuilder->getRootNode('chill_aside_activity') $treeBuilder->getRootNode()
->children() ->children()
->arrayNode('form') ->arrayNode('form')
->canBeEnabled() ->canBeEnabled()

View File

@ -95,9 +95,7 @@ final class AsideActivityFormType extends AbstractType
// the datetimetransformer will then handle timezone as GMT // the datetimetransformer will then handle timezone as GMT
$timezoneUTC = new DateTimeZone('GMT'); $timezoneUTC = new DateTimeZone('GMT');
/** @var DateTimeImmutable $data */ /** @var DateTimeImmutable $data */
$data = $formEvent->getData() === null ? $data = $formEvent->getData() ?? DateTime::createFromFormat('U', '300');
DateTime::createFromFormat('U', '300') :
$formEvent->getData();
$seconds = $data->getTimezone()->getOffset($data); $seconds = $data->getTimezone()->getOffset($data);
$data->setTimeZone($timezoneUTC); $data->setTimeZone($timezoneUTC);
$data->add(new DateInterval('PT' . $seconds . 'S')); $data->add(new DateInterval('PT' . $seconds . 'S'));

View File

@ -116,7 +116,7 @@ abstract class AbstractElementController extends AbstractController
$indexPage = 'chill_budget_elements_household_index'; $indexPage = 'chill_budget_elements_household_index';
} }
$entity = null !== $element->getPerson() ? $element->getPerson() : $element->getHousehold(); $entity = $element->getPerson() ?? $element->getHousehold();
$form = $this->createForm($this->getType(), $element); $form = $this->createForm($this->getType(), $element);
$form->add('submit', SubmitType::class); $form->add('submit', SubmitType::class);

View File

@ -19,7 +19,7 @@ class CalculatorCompilerPass implements CompilerPassInterface
{ {
public function process(ContainerBuilder $container) public function process(ContainerBuilder $container)
{ {
$manager = $container->getDefinition('Chill\BudgetBundle\Calculator\CalculatorManager'); $manager = $container->getDefinition(\Chill\BudgetBundle\Calculator\CalculatorManager::class);
foreach ($container->findTaggedServiceIds('chill_budget.calculator') as $id => $tags) { foreach ($container->findTaggedServiceIds('chill_budget.calculator') as $id => $tags) {
foreach ($tags as $tag) { foreach ($tags as $tag) {

View File

@ -19,7 +19,7 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder() public function getConfigTreeBuilder()
{ {
$treeBuilder = new TreeBuilder('chill_budget'); $treeBuilder = new TreeBuilder('chill_budget');
$rootNode = $treeBuilder->getRootNode('chill_budget'); $rootNode = $treeBuilder->getRootNode();
$rootNode $rootNode
->children() ->children()

View File

@ -60,7 +60,7 @@ class MapAndSubscribeUserCalendarCommand extends Command
public function execute(InputInterface $input, OutputInterface $output): int public function execute(InputInterface $input, OutputInterface $output): int
{ {
$this->logger->info(__CLASS__ . ' execute command'); $this->logger->info(self::class . ' execute command');
$limit = 50; $limit = 50;
$offset = 0; $offset = 0;
@ -71,7 +71,7 @@ class MapAndSubscribeUserCalendarCommand extends Command
$created = 0; $created = 0;
$renewed = 0; $renewed = 0;
$this->logger->info(__CLASS__ . ' the number of user to get - renew', [ $this->logger->info(self::class . ' the number of user to get - renew', [
'total' => $total, 'total' => $total,
'expiration' => $expiration->format(DateTimeImmutable::ATOM), 'expiration' => $expiration->format(DateTimeImmutable::ATOM),
]); ]);
@ -92,7 +92,7 @@ class MapAndSubscribeUserCalendarCommand extends Command
// we first try to renew an existing subscription, if any. // we first try to renew an existing subscription, if any.
// if not, or if it fails, we try to create a new one // if not, or if it fails, we try to create a new one
if ($this->mapCalendarToUser->hasActiveSubscription($user)) { if ($this->mapCalendarToUser->hasActiveSubscription($user)) {
$this->logger->debug(__CLASS__ . ' renew a subscription for', [ $this->logger->debug(self::class . ' renew a subscription for', [
'userId' => $user->getId(), 'userId' => $user->getId(),
'username' => $user->getUsernameCanonical(), 'username' => $user->getUsernameCanonical(),
]); ]);
@ -104,7 +104,7 @@ class MapAndSubscribeUserCalendarCommand extends Command
if (0 !== $expirationTs) { if (0 !== $expirationTs) {
++$renewed; ++$renewed;
} else { } else {
$this->logger->warning(__CLASS__ . ' could not renew subscription for a user', [ $this->logger->warning(self::class . ' could not renew subscription for a user', [
'userId' => $user->getId(), 'userId' => $user->getId(),
'username' => $user->getUsernameCanonical(), 'username' => $user->getUsernameCanonical(),
]); ]);
@ -112,7 +112,7 @@ class MapAndSubscribeUserCalendarCommand extends Command
} }
if (!$this->mapCalendarToUser->hasActiveSubscription($user)) { if (!$this->mapCalendarToUser->hasActiveSubscription($user)) {
$this->logger->debug(__CLASS__ . ' create a subscription for', [ $this->logger->debug(self::class . ' create a subscription for', [
'userId' => $user->getId(), 'userId' => $user->getId(),
'username' => $user->getUsernameCanonical(), 'username' => $user->getUsernameCanonical(),
]); ]);
@ -124,7 +124,7 @@ class MapAndSubscribeUserCalendarCommand extends Command
if (0 !== $expirationTs) { if (0 !== $expirationTs) {
++$created; ++$created;
} else { } else {
$this->logger->warning(__CLASS__ . ' could not create subscription for a user', [ $this->logger->warning(self::class . ' could not create subscription for a user', [
'userId' => $user->getId(), 'userId' => $user->getId(),
'username' => $user->getUsernameCanonical(), 'username' => $user->getUsernameCanonical(),
]); ]);
@ -139,7 +139,7 @@ class MapAndSubscribeUserCalendarCommand extends Command
$this->em->clear(); $this->em->clear();
} }
$this->logger->warning(__CLASS__ . ' process executed', [ $this->logger->warning(self::class . ' process executed', [
'created' => $created, 'created' => $created,
'renewed' => $renewed, 'renewed' => $renewed,
]); ]);

View File

@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder() public function getConfigTreeBuilder()
{ {
$treeBuilder = new TreeBuilder('chill_calendar'); $treeBuilder = new TreeBuilder('chill_calendar');
$rootNode = $treeBuilder->getRootNode('chill_calendar'); $rootNode = $treeBuilder->getRootNode();
$rootNode $rootNode
->children() ->children()

View File

@ -77,7 +77,7 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface
$user = $this->userRepository->find($changeNotificationMessage->getUserId()); $user = $this->userRepository->find($changeNotificationMessage->getUserId());
if (null === $user) { if (null === $user) {
$this->logger->warning(__CLASS__ . ' notification concern non-existent user, skipping'); $this->logger->warning(self::class . ' notification concern non-existent user, skipping');
return; return;
} }
@ -86,7 +86,7 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface
$secret = $this->mapCalendarToUser->getSubscriptionSecret($user); $secret = $this->mapCalendarToUser->getSubscriptionSecret($user);
if ($secret !== ($notification['clientState'] ?? -1)) { if ($secret !== ($notification['clientState'] ?? -1)) {
$this->logger->warning(__CLASS__ . ' could not validate secret, skipping'); $this->logger->warning(self::class . ' could not validate secret, skipping');
continue; continue;
} }
@ -101,7 +101,7 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface
$this->calendarSyncer->handleCalendarSync($calendar, $notification, $user); $this->calendarSyncer->handleCalendarSync($calendar, $notification, $user);
$this->em->flush(); $this->em->flush();
} else { } else {
$this->logger->info(__CLASS__ . ' id not found in any calendar nor calendar range'); $this->logger->info(self::class . ' id not found in any calendar nor calendar range');
} }
} }

View File

@ -59,7 +59,7 @@ class CalendarRangeSyncer
} }
$calendarRange->preventEnqueueChanges = true; $calendarRange->preventEnqueueChanges = true;
$this->logger->info(__CLASS__ . ' remove a calendar range because deleted on remote calendar'); $this->logger->info(self::class . ' remove a calendar range because deleted on remote calendar');
$this->em->remove($calendarRange); $this->em->remove($calendarRange);
break; break;
@ -71,7 +71,7 @@ class CalendarRangeSyncer
$notification['resource'] $notification['resource']
)->toArray(); )->toArray();
} catch (ClientExceptionInterface $clientException) { } catch (ClientExceptionInterface $clientException) {
$this->logger->warning(__CLASS__ . ' could not retrieve event from ms graph. Already deleted ?', [ $this->logger->warning(self::class . ' could not retrieve event from ms graph. Already deleted ?', [
'calendarRangeId' => $calendarRange->getId(), 'calendarRangeId' => $calendarRange->getId(),
'remoteEventId' => $notification['resource'], 'remoteEventId' => $notification['resource'],
]); ]);
@ -82,7 +82,7 @@ class CalendarRangeSyncer
$lastModified = RemoteEventConverter::convertStringDateWithTimezone($new['lastModifiedDateTime']); $lastModified = RemoteEventConverter::convertStringDateWithTimezone($new['lastModifiedDateTime']);
if ($calendarRange->getRemoteAttributes()['lastModifiedDateTime'] === $lastModified->getTimestamp()) { if ($calendarRange->getRemoteAttributes()['lastModifiedDateTime'] === $lastModified->getTimestamp()) {
$this->logger->info(__CLASS__ . ' change key is equals. Source is probably a local update', [ $this->logger->info(self::class . ' change key is equals. Source is probably a local update', [
'calendarRangeId' => $calendarRange->getId(), 'calendarRangeId' => $calendarRange->getId(),
'remoteEventId' => $notification['resource'], 'remoteEventId' => $notification['resource'],
]); ]);

View File

@ -79,7 +79,7 @@ class CalendarSyncer
$notification['resource'] $notification['resource']
)->toArray(); )->toArray();
} catch (ClientExceptionInterface $clientException) { } catch (ClientExceptionInterface $clientException) {
$this->logger->warning(__CLASS__ . ' could not retrieve event from ms graph. Already deleted ?', [ $this->logger->warning(self::class . ' could not retrieve event from ms graph. Already deleted ?', [
'calendarId' => $calendar->getId(), 'calendarId' => $calendar->getId(),
'remoteEventId' => $notification['resource'], 'remoteEventId' => $notification['resource'],
]); ]);
@ -96,7 +96,7 @@ class CalendarSyncer
); );
if ($calendar->getRemoteAttributes()['lastModifiedDateTime'] === $lastModified->getTimestamp()) { if ($calendar->getRemoteAttributes()['lastModifiedDateTime'] === $lastModified->getTimestamp()) {
$this->logger->info(__CLASS__ . ' change key is equals. Source is probably a local update', [ $this->logger->info(self::class . ' change key is equals. Source is probably a local update', [
'calendarRangeId' => $calendar->getId(), 'calendarRangeId' => $calendar->getId(),
'remoteEventId' => $notification['resource'], 'remoteEventId' => $notification['resource'],
]); ]);

View File

@ -66,6 +66,6 @@ class BulkCalendarShortMessageSender
$this->em->refresh($calendar); $this->em->refresh($calendar);
} }
$this->logger->info(__CLASS__ . 'a bulk of messages was sent', ['count_calendars' => $countCalendars, 'count_sms' => $countSms]); $this->logger->info(self::class . 'a bulk of messages was sent', ['count_calendars' => $countCalendars, 'count_sms' => $countSms]);
} }
} }

View File

@ -192,9 +192,7 @@ class CreateFieldsOnGroupCommand extends Command
foreach ($languages as $lang) { foreach ($languages as $lang) {
//todo replace with service to find lang when available //todo replace with service to find lang when available
$names[] = (isset($cf->getName()[$lang])) ? $names[] = $cf->getName()[$lang] ?? 'Not available in this language';
$cf->getName()[$lang] :
'Not available in this language';
} }
if ($this->validator->validate($cf)) { if ($this->validator->validate($cf)) {
@ -249,9 +247,7 @@ class CreateFieldsOnGroupCommand extends Command
foreach ($languages as $lang) { foreach ($languages as $lang) {
//todo replace with service to find lang when available //todo replace with service to find lang when available
$row[] = (isset($customFieldGroup->getName()[$lang])) ? $row[] = $customFieldGroup->getName()[$lang] ?? 'Not available in this language';
$customFieldGroup->getName()[$lang] :
'Not available in this language';
} }
$rows[] = $row; $rows[] = $row;
} }

View File

@ -294,7 +294,7 @@ class CustomFieldChoice extends AbstractCustomField
public function render($value, CustomField $customField, $documentType = 'html') public function render($value, CustomField $customField, $documentType = 'html')
{ {
//extract the data. They are under a _choice key if they are stored with allow_other //extract the data. They are under a _choice key if they are stored with allow_other
$data = (isset($value['_choices'])) ? $value['_choices'] : $value; $data = $value['_choices'] ?? $value;
$selected = (is_array($data)) ? $data : [$data]; $selected = (is_array($data)) ? $data : [$data];
$choices = $customField->getOptions()[self::CHOICES]; $choices = $customField->getOptions()[self::CHOICES];

View File

@ -104,7 +104,7 @@ class LoadOption extends AbstractFixture implements OrderedFixtureInterface
$manager->persist($parent); $manager->persist($parent);
//Load children //Load children
$expected_nb_children = mt_rand(10, 50); $expected_nb_children = random_int(10, 50);
for ($i = 0; $i < $expected_nb_children; ++$i) { for ($i = 0; $i < $expected_nb_children; ++$i) {
$companyName = $this->fakerFr->company; $companyName = $this->fakerFr->company;
@ -144,7 +144,7 @@ class LoadOption extends AbstractFixture implements OrderedFixtureInterface
$manager->persist($parent); $manager->persist($parent);
//Load children //Load children
$expected_nb_children = mt_rand(10, 50); $expected_nb_children = random_int(10, 50);
for ($i = 0; $i < $expected_nb_children; ++$i) { for ($i = 0; $i < $expected_nb_children; ++$i) {
$manager->persist($this->createChildOption($parent, [ $manager->persist($this->createChildOption($parent, [

View File

@ -25,7 +25,7 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder() public function getConfigTreeBuilder()
{ {
$treeBuilder = new TreeBuilder('chill_custom_fields'); $treeBuilder = new TreeBuilder('chill_custom_fields');
$rootNode = $treeBuilder->getRootNode('chill_custom_fields'); $rootNode = $treeBuilder->getRootNode();
$classInfo = 'The class which may receive custom fields'; $classInfo = 'The class which may receive custom fields';
$nameInfo = 'The name which will appears in the user interface. May be translatable'; $nameInfo = 'The name which will appears in the user interface. May be translatable';

View File

@ -119,7 +119,7 @@ class CustomFieldType extends AbstractType
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefaults([ $resolver->setDefaults([
'data_class' => 'Chill\CustomFieldsBundle\Entity\CustomField', 'data_class' => \Chill\CustomFieldsBundle\Entity\CustomField::class,
]); ]);
$resolver->setRequired(['type', 'group_widget']) $resolver->setRequired(['type', 'group_widget'])

View File

@ -108,7 +108,7 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface
//echo json_encode($customFieldsArrayRet); //echo json_encode($customFieldsArrayRet);
return json_encode($customFieldsArrayRet); return json_encode($customFieldsArrayRet, JSON_THROW_ON_ERROR);
} }
public function transform($customFieldsJSON) public function transform($customFieldsJSON)

View File

@ -38,7 +38,7 @@ class ChoicesListType extends AbstractType
$formData = $form->getData(); $formData = $form->getData();
if (null === $formData['slug']) { if (null === $formData['slug']) {
$slug = uniqid(mt_rand(), true); $slug = uniqid(random_int(0, mt_getrandmax()), true);
$data['slug'] = $slug; $data['slug'] = $slug;
$event->setData($data); $event->setData($data);

View File

@ -49,7 +49,7 @@ class CustomFieldType extends AbstractType
{ {
$resolver $resolver
->setRequired(['group']) ->setRequired(['group'])
->addAllowedTypes('group', ['Chill\CustomFieldsBundle\Entity\CustomFieldsGroup']); ->addAllowedTypes('group', [\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class]);
} }
public function getBlockPrefix() public function getBlockPrefix()

View File

@ -49,7 +49,7 @@ class CustomFieldsHelper
public function isEmptyValue(array $fields, CustomField $customField) public function isEmptyValue(array $fields, CustomField $customField)
{ {
$slug = $customField->getSlug(); $slug = $customField->getSlug();
$rawValue = (isset($fields[$slug])) ? $fields[$slug] : null; $rawValue = $fields[$slug] ?? null;
$customFieldType = $this->provider->getCustomFieldByType($customField->getType()); $customFieldType = $this->provider->getCustomFieldByType($customField->getType());
$deserializedValue = $customFieldType->deserialize($rawValue, $customField); $deserializedValue = $customFieldType->deserialize($rawValue, $customField);
@ -71,7 +71,7 @@ class CustomFieldsHelper
public function renderCustomField(array $fields, CustomField $customField, $documentType = 'html') public function renderCustomField(array $fields, CustomField $customField, $documentType = 'html')
{ {
$slug = $customField->getSlug(); $slug = $customField->getSlug();
$rawValue = (isset($fields[$slug])) ? $fields[$slug] : null; $rawValue = $fields[$slug] ?? null;
$customFieldType = $this->provider->getCustomFieldByType($customField->getType()); $customFieldType = $this->provider->getCustomFieldByType($customField->getType());
return $customFieldType->render($rawValue, $customField, $documentType); return $customFieldType->render($rawValue, $customField, $documentType);

View File

@ -52,7 +52,7 @@ final class CustomFieldsGroupControllerTest extends WebTestCase
// Fill in the form and submit it // Fill in the form and submit it
$form = $crawler->selectButton('Créer')->form([ $form = $crawler->selectButton('Créer')->form([
'custom_fields_group[name][fr]' => 'Test', 'custom_fields_group[name][fr]' => 'Test',
'custom_fields_group[entity]' => 'Chill\PersonBundle\Entity\Person', 'custom_fields_group[entity]' => \Chill\PersonBundle\Entity\Person::class,
]); ]);
$crawler = $client->submit($form); $crawler = $client->submit($form);

View File

@ -34,12 +34,12 @@ trait CustomFieldTestHelper
$kernel = static::$kernel; $kernel = static::$kernel;
//check a kernel is accessible //check a kernel is accessible
$customFieldsGroup = $this->createMock('Chill\CustomFieldsBundle\Entity\CustomFieldsGroup'); $customFieldsGroup = $this->createMock(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class);
$customFieldsGroup->expects($this->once()) $customFieldsGroup->expects($this->once())
->method('getActiveCustomFields') ->method('getActiveCustomFields')
->will($this->returnValue([$field])); ->will($this->returnValue([$field]));
$request = $this->createMock('Symfony\Component\HttpFoundation\Request'); $request = $this->createMock(\Symfony\Component\HttpFoundation\Request::class);
$request->expects($this->any()) $request->expects($this->any())
->method('getLocale') ->method('getLocale')
->will($this->returnValue($locale)); ->will($this->returnValue($locale));

View File

@ -41,11 +41,11 @@ final class CustomFieldsTextTest extends WebTestCase
$customField = $this->customFieldProvider->getCustomFieldByType('text'); $customField = $this->customFieldProvider->getCustomFieldByType('text');
$this->assertInstanceOf( $this->assertInstanceOf(
'Chill\CustomFieldsBundle\CustomFields\CustomFieldInterface', \Chill\CustomFieldsBundle\CustomFields\CustomFieldInterface::class,
$customField $customField
); );
$this->assertInstanceOf( $this->assertInstanceOf(
'Chill\CustomFieldsBundle\CustomFields\CustomFieldText', \Chill\CustomFieldsBundle\CustomFields\CustomFieldText::class,
$customField $customField
); );
} }

View File

@ -46,7 +46,7 @@ final class CustomFieldRenderingTwigTest extends KernelTestCase
// set locale to fr // set locale to fr
$prophet = new \Prophecy\Prophet(); $prophet = new \Prophecy\Prophet();
$request = $prophet->prophesize(); $request = $prophet->prophesize();
$request->willExtend('Symfony\Component\HttpFoundation\Request'); $request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
$request->getLocale()->willReturn('fr'); $request->getLocale()->willReturn('fr');
self::$kernel->getContainer()->get('request_stack') self::$kernel->getContainer()->get('request_stack')
->push($request->reveal()); ->push($request->reveal());

View File

@ -48,7 +48,7 @@ final class CustomFieldsGroupRenderingTwigTest extends KernelTestCase
// set locale to fr // set locale to fr
$prophet = new \Prophecy\Prophet(); $prophet = new \Prophecy\Prophet();
$request = $prophet->prophesize(); $request = $prophet->prophesize();
$request->willExtend('Symfony\Component\HttpFoundation\Request'); $request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
$request->getLocale()->willReturn('fr'); $request->getLocale()->willReturn('fr');
self::$kernel->getContainer()->get('request_stack') self::$kernel->getContainer()->get('request_stack')
->push($request->reveal()); ->push($request->reveal());

View File

@ -44,7 +44,7 @@ final class RelatorioDriver implements DriverInterface
{ {
$form = new FormDataPart( $form = new FormDataPart(
[ [
'variables' => json_encode($data), 'variables' => json_encode($data, JSON_THROW_ON_ERROR),
'template' => new DataPart($template, $templateName ?? uniqid('template_'), $resourceType), 'template' => new DataPart($template, $templateName ?? uniqid('template_'), $resourceType),
] ]
); );
@ -61,7 +61,7 @@ final class RelatorioDriver implements DriverInterface
$content = $e->getResponse()->getContent(false); $content = $e->getResponse()->getContent(false);
if (400 === $e->getResponse()->getStatusCode()) { if (400 === $e->getResponse()->getStatusCode()) {
$content = json_decode($content, true); $content = json_decode($content, true, 512, JSON_THROW_ON_ERROR);
$this->logger->error('relatorio: template error', [ $this->logger->error('relatorio: template error', [
'error' => $content['message'] ?? '_not defined', 'error' => $content['message'] ?? '_not defined',
]); ]);

View File

@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder() public function getConfigTreeBuilder()
{ {
$treeBuilder = new TreeBuilder('chill_doc_store'); $treeBuilder = new TreeBuilder('chill_doc_store');
$rootNode = $treeBuilder->getRootNode('chill_doc_store'); $rootNode = $treeBuilder->getRootNode();
// Here you should define the parameters that are allowed to // Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for // configure your bundle. See the documentation linked above for

View File

@ -95,7 +95,7 @@ class StoredObjectType extends AbstractType
return null; return null;
} }
return json_decode($value, true); return json_decode($value, true, 512, JSON_THROW_ON_ERROR);
} }
public function reverseTransformObject($object) public function reverseTransformObject($object)
@ -120,7 +120,7 @@ class StoredObjectType extends AbstractType
return null; return null;
} }
return json_encode($object); return json_encode($object, JSON_THROW_ON_ERROR);
} }
public function transformObject($object = null) public function transformObject($object = null)

View File

@ -43,7 +43,7 @@ class LoadParticipation extends AbstractFixture implements OrderedFixtureInterfa
for ($i = 0; $i < $expectedNumber; ++$i) { for ($i = 0; $i < $expectedNumber; ++$i) {
$event = (new Event()) $event = (new Event())
->setDate($this->faker->dateTimeBetween('-2 years', '+6 months')) ->setDate($this->faker->dateTimeBetween('-2 years', '+6 months'))
->setName($this->faker->words(mt_rand(2, 4), true)) ->setName($this->faker->words(random_int(2, 4), true))
->setType($this->getReference(LoadEventTypes::$refs[array_rand(LoadEventTypes::$refs)])) ->setType($this->getReference(LoadEventTypes::$refs[array_rand(LoadEventTypes::$refs)]))
->setCenter($center) ->setCenter($center)
->setCircle( ->setCircle(
@ -75,7 +75,7 @@ class LoadParticipation extends AbstractFixture implements OrderedFixtureInterfa
/** @var \Chill\PersonBundle\Entity\Person $person */ /** @var \Chill\PersonBundle\Entity\Person $person */
foreach ($people as $person) { foreach ($people as $person) {
$nb = mt_rand(0, 3); $nb = random_int(0, 3);
for ($i = 0; $i < $nb; ++$i) { for ($i = 0; $i < $nb; ++$i) {
$event = $events[array_rand($events)]; $event = $events[array_rand($events)];

View File

@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder() public function getConfigTreeBuilder()
{ {
$treeBuilder = new TreeBuilder('chill_event'); $treeBuilder = new TreeBuilder('chill_event');
$rootNode = $treeBuilder->getRootNode('chill_event'); $rootNode = $treeBuilder->getRootNode();
// Here you should define the parameters that are allowed to // Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for // configure your bundle. See the documentation linked above for

View File

@ -54,7 +54,7 @@ class EventType extends AbstractType
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefaults([ $resolver->setDefaults([
'data_class' => 'Chill\EventBundle\Entity\Event', 'data_class' => \Chill\EventBundle\Entity\Event::class,
]); ]);
$resolver $resolver
->setRequired(['center', 'role']) ->setRequired(['center', 'role'])

View File

@ -36,7 +36,7 @@ class EventTypeType extends AbstractType
public function setDefaultOptions(OptionsResolverInterface $resolver) public function setDefaultOptions(OptionsResolverInterface $resolver)
{ {
$resolver->setDefaults([ $resolver->setDefaults([
'data_class' => 'Chill\EventBundle\Entity\EventType', 'data_class' => \Chill\EventBundle\Entity\EventType::class,
]); ]);
} }
} }

View File

@ -55,7 +55,7 @@ class RoleType extends AbstractType
public function setDefaultOptions(OptionsResolverInterface $resolver) public function setDefaultOptions(OptionsResolverInterface $resolver)
{ {
$resolver->setDefaults([ $resolver->setDefaults([
'data_class' => 'Chill\EventBundle\Entity\Role', 'data_class' => \Chill\EventBundle\Entity\Role::class,
]); ]);
} }
} }

View File

@ -38,7 +38,7 @@ class StatusType extends AbstractType
public function setDefaultOptions(OptionsResolverInterface $resolver) public function setDefaultOptions(OptionsResolverInterface $resolver)
{ {
$resolver->setDefaults([ $resolver->setDefaults([
'data_class' => 'Chill\EventBundle\Entity\Status', 'data_class' => \Chill\EventBundle\Entity\Status::class,
]); ]);
} }
} }

View File

@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder() public function getConfigTreeBuilder()
{ {
$treeBuilder = new TreeBuilder('chill_amli_family_members'); $treeBuilder = new TreeBuilder('chill_amli_family_members');
$rootNode = $treeBuilder->getRootNode('chill_amli_family_members'); $rootNode = $treeBuilder->getRootNode();
$rootNode $rootNode
->children() ->children()

View File

@ -102,11 +102,7 @@ class LoadPostalCodesCommand extends Command
try { try {
$this->addPostalCode($row, $output); $this->addPostalCode($row, $output);
++$num; ++$num;
} catch (ExistingPostalCodeException $ex) { } catch (ExistingPostalCodeException|CountryCodeNotFoundException|PostalCodeNotValidException $ex) {
$output->writeln('<warning> on line ' . $line . ' : ' . $ex->getMessage() . '</warning>');
} catch (CountryCodeNotFoundException $ex) {
$output->writeln('<warning> on line ' . $line . ' : ' . $ex->getMessage() . '</warning>');
} catch (PostalCodeNotValidException $ex) {
$output->writeln('<warning> on line ' . $line . ' : ' . $ex->getMessage() . '</warning>'); $output->writeln('<warning> on line ' . $line . ' : ' . $ex->getMessage() . '</warning>');
} }
++$line; ++$line;

View File

@ -164,7 +164,7 @@ class ExportController extends AbstractController
{ {
$this->denyAccessUnlessGranted(SavedExportVoter::GENERATE, $savedExport); $this->denyAccessUnlessGranted(SavedExportVoter::GENERATE, $savedExport);
$key = md5(uniqid((string) mt_rand(), false)); $key = md5(uniqid((string) random_int(0, mt_getrandmax()), false));
$this->redis->setEx($key, 3600, serialize($savedExport->getOptions())); $this->redis->setEx($key, 3600, serialize($savedExport->getOptions()));
@ -481,7 +481,7 @@ class ExportController extends AbstractController
'alias' => $alias, 'alias' => $alias,
]; ];
unset($parameters['_token']); unset($parameters['_token']);
$key = md5(uniqid((string) mt_rand(), false)); $key = md5(uniqid((string) random_int(0, mt_getrandmax()), false));
$this->redis->setEx($key, 3600, serialize($parameters)); $this->redis->setEx($key, 3600, serialize($parameters));
@ -665,7 +665,7 @@ class ExportController extends AbstractController
$this->logger->notice('[export] choices for an export unserialized', [ $this->logger->notice('[export] choices for an export unserialized', [
'key' => $key, 'key' => $key,
'rawData' => json_encode($rawData), 'rawData' => json_encode($rawData, JSON_THROW_ON_ERROR),
]); ]);
return $rawData; return $rawData;

View File

@ -109,10 +109,8 @@ class SearchController extends AbstractController
->getHasAdvancedFormSearchServices(); ->getHasAdvancedFormSearchServices();
if (count($advancedSearchProviders) === 1) { if (count($advancedSearchProviders) === 1) {
reset($advancedSearchProviders);
return $this->redirectToRoute('chill_main_advanced_search', [ return $this->redirectToRoute('chill_main_advanced_search', [
'name' => key($advancedSearchProviders), 'name' => array_key_first($advancedSearchProviders),
]); ]);
} }

View File

@ -69,7 +69,7 @@ class LoadAddressReferences extends AbstractFixture implements ContainerAwareInt
$ar->setRefId($this->faker->numerify('ref-id-######')); $ar->setRefId($this->faker->numerify('ref-id-######'));
$ar->setStreet($this->faker->streetName); $ar->setStreet($this->faker->streetName);
$ar->setStreetNumber((string) mt_rand(0, 199)); $ar->setStreetNumber((string) random_int(0, 199));
$ar->setPoint($this->getRandomPoint()); $ar->setPoint($this->getRandomPoint());
$ar->setPostcode($this->getReference( $ar->setPostcode($this->getReference(
LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)] LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)]
@ -89,8 +89,8 @@ class LoadAddressReferences extends AbstractFixture implements ContainerAwareInt
{ {
$lonBrussels = 4.35243; $lonBrussels = 4.35243;
$latBrussels = 50.84676; $latBrussels = 50.84676;
$lon = $lonBrussels + 0.01 * mt_rand(-5, 5); $lon = $lonBrussels + 0.01 * random_int(-5, 5);
$lat = $latBrussels + 0.01 * mt_rand(-5, 5); $lat = $latBrussels + 0.01 * random_int(-5, 5);
return Point::fromLonLat($lon, $lat); return Point::fromLonLat($lon, $lat);
} }

View File

@ -38,11 +38,7 @@ class MenuCompilerPass implements CompilerPassInterface
} }
usort($services, static function ($a, $b) { usort($services, static function ($a, $b) {
if ($a['priority'] === $b['priority']) { return $a['priority'] <=> $b['priority'];
return 0;
}
return ($a['priority'] < $b['priority']) ? -1 : 1;
}); });
foreach ($services as $service) { foreach ($services as $service) {

View File

@ -34,7 +34,7 @@ class ShortMessageCompilerPass implements CompilerPassInterface
{ {
public function process(ContainerBuilder $container) public function process(ContainerBuilder $container)
{ {
$config = $container->resolveEnvPlaceholders($container->getParameter('chill_main.short_messages', null), true); $config = $container->resolveEnvPlaceholders($container->getParameter('chill_main.short_messages'), true);
// weird fix for special characters // weird fix for special characters
$config['dsn'] = str_replace(['%%'], ['%'], $config['dsn']); $config['dsn'] = str_replace(['%%'], ['%'], $config['dsn']);
$dsn = parse_url($config['dsn']); $dsn = parse_url($config['dsn']);
@ -43,7 +43,7 @@ class ShortMessageCompilerPass implements CompilerPassInterface
if ('null' === $dsn['scheme'] || false === $config['enabled']) { if ('null' === $dsn['scheme'] || false === $config['enabled']) {
$defaultTransporter = new Reference(NullShortMessageSender::class); $defaultTransporter = new Reference(NullShortMessageSender::class);
} elseif ('ovh' === $dsn['scheme']) { } elseif ('ovh' === $dsn['scheme']) {
if (!class_exists('\Ovh\Api')) { if (!class_exists('\\' . \Ovh\Api::class)) {
throw new RuntimeException('Class \\Ovh\\Api not found'); throw new RuntimeException('Class \\Ovh\\Api not found');
} }
@ -66,17 +66,17 @@ class ShortMessageCompilerPass implements CompilerPassInterface
$ovh = new Definition(); $ovh = new Definition();
$ovh $ovh
->setClass('\Ovh\Api') ->setClass('\\' . \Ovh\Api::class)
->setArgument(0, $dsn['user']) ->setArgument(0, $dsn['user'])
->setArgument(1, $dsn['pass']) ->setArgument(1, $dsn['pass'])
->setArgument(2, $dsn['host']) ->setArgument(2, $dsn['host'])
->setArgument(3, $dsn['queries']['consumer_key']); ->setArgument(3, $dsn['queries']['consumer_key']);
$container->setDefinition('Ovh\Api', $ovh); $container->setDefinition(\Ovh\Api::class, $ovh);
$ovhSender = new Definition(); $ovhSender = new Definition();
$ovhSender $ovhSender
->setClass(OvhShortMessageSender::class) ->setClass(OvhShortMessageSender::class)
->setArgument(0, new Reference('Ovh\Api')) ->setArgument(0, new Reference(\Ovh\Api::class))
->setArgument(1, $dsn['queries']['service_name']) ->setArgument(1, $dsn['queries']['service_name'])
->setArgument(2, $dsn['queries']['sender']) ->setArgument(2, $dsn['queries']['sender'])
->setArgument(3, new Reference(LoggerInterface::class)) ->setArgument(3, new Reference(LoggerInterface::class))

View File

@ -37,7 +37,7 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder() public function getConfigTreeBuilder()
{ {
$treeBuilder = new TreeBuilder('chill_main'); $treeBuilder = new TreeBuilder('chill_main');
$rootNode = $treeBuilder->getRootNode('chill_main'); $rootNode = $treeBuilder->getRootNode();
$rootNode $rootNode
->children() ->children()

View File

@ -193,8 +193,7 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface
/** @var WidgetFactoryInterface $factory */ /** @var WidgetFactoryInterface $factory */
$factory = $this->widgetServices[$alias]; $factory = $this->widgetServices[$alias];
// get the config (under the key which equals to widget_alias // get the config (under the key which equals to widget_alias
$config = isset($param[$factory->getWidgetAlias()]) ? $config = $param[$factory->getWidgetAlias()] ?? [];
$param[$factory->getWidgetAlias()] : [];
// register the service into the container // register the service into the container
$serviceId = $this->registerServiceIntoContainer( $serviceId = $this->registerServiceIntoContainer(
$container, $container,

View File

@ -139,7 +139,7 @@ trait AddWidgetConfigurationTrait
protected function addWidgetsConfiguration(string $place, ContainerBuilder $containerBuilder) protected function addWidgetsConfiguration(string $place, ContainerBuilder $containerBuilder)
{ {
$treeBuilder = new TreeBuilder($place); $treeBuilder = new TreeBuilder($place);
$root = $treeBuilder->getRootNode($place) $root = $treeBuilder->getRootNode()
->canBeUnset() ->canBeUnset()
->info('register widgets on place "' . $place . '"'); ->info('register widgets on place "' . $place . '"');
@ -170,7 +170,7 @@ trait AddWidgetConfigurationTrait
// adding the possible config on each widget under the widget_alias // adding the possible config on each widget under the widget_alias
foreach ($this->filterWidgetByPlace($place) as $factory) { foreach ($this->filterWidgetByPlace($place) as $factory) {
$builder = new TreeBuilder($factory->getWidgetAlias()); $builder = new TreeBuilder($factory->getWidgetAlias());
$widgetOptionsRoot = $builder->getRootNode($factory->getWidgetAlias()); $widgetOptionsRoot = $builder->getRootNode();
$widgetOptionsRoot->canBeUnset() $widgetOptionsRoot->canBeUnset()
->info(sprintf( ->info(sprintf(
'the configuration for the widget "%s" (only required if this widget is set in widget_alias)', 'the configuration for the widget "%s" (only required if this widget is set in widget_alias)',

View File

@ -41,7 +41,7 @@ class Point implements JsonSerializable
public static function fromGeoJson(string $geojson): self public static function fromGeoJson(string $geojson): self
{ {
$a = json_decode($geojson); $a = json_decode($geojson, null, 512, JSON_THROW_ON_ERROR);
if (null === $a) { if (null === $a) {
throw PointException::badJsonString($geojson); throw PointException::badJsonString($geojson);
@ -96,7 +96,7 @@ class Point implements JsonSerializable
{ {
$array = $this->toArrayGeoJson(); $array = $this->toArrayGeoJson();
return json_encode($array); return json_encode($array, JSON_THROW_ON_ERROR);
} }
public function toWKT(): string public function toWKT(): string

View File

@ -570,9 +570,9 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
* @return Address * @return Address
* @deprecated * @deprecated
*/ */
public function setStreetAddress1($streetAddress1) public function setStreetAddress1(?string $streetAddress1): self
{ {
$this->street = null === $streetAddress1 ? '' : $streetAddress1; $this->street = (string) $streetAddress1;
return $this; return $this;
} }
@ -584,9 +584,9 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
* @deprecated * @deprecated
* @return Address * @return Address
*/ */
public function setStreetAddress2($streetAddress2) public function setStreetAddress2(?string $streetAddress2): self
{ {
$this->streetNumber = null === $streetAddress2 ? '' : $streetAddress2; $this->streetNumber = (string) $streetAddress2;
return $this; return $this;
} }

View File

@ -45,7 +45,7 @@ class PrivateCommentEmbeddable
public function merge(PrivateCommentEmbeddable $newComment): self public function merge(PrivateCommentEmbeddable $newComment): self
{ {
$currentComments = null === $this->getComments() ? [] : $this->getComments(); $currentComments = $this->getComments() ?? [];
$mergedComments = $newComment->getComments() + $currentComments; $mergedComments = $newComment->getComments() + $currentComments;

View File

@ -435,7 +435,7 @@ class SpreadSheetFormatter implements FormatterInterface
* Get the displayable result. * Get the displayable result.
* *
* @param string $key * @param string $key
* @param string $value * @param mixed $value
* *
* @return string * @return string
*/ */
@ -445,7 +445,7 @@ class SpreadSheetFormatter implements FormatterInterface
$this->initializeCache($key); $this->initializeCache($key);
} }
$value = null === $value ? '' : $value; $value = $value ?? '';
return call_user_func($this->cacheDisplayableResult[$key], $value); return call_user_func($this->cacheDisplayableResult[$key], $value);
} }

View File

@ -29,7 +29,7 @@ class AggregateStringHelper
return implode( return implode(
'|', '|',
json_decode($value, true) json_decode($value, true, 512, JSON_THROW_ON_ERROR)
); );
}; };
} }

View File

@ -310,7 +310,7 @@ class ExportAddressHelper
return ''; return '';
} }
return $this->translatableStringHelper->localize(json_decode($value, true)); return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR));
}; };
case 'isNoAddress': case 'isNoAddress':
@ -369,7 +369,7 @@ class ExportAddressHelper
return ''; return '';
} }
$decodedValues = json_decode($value, true); $decodedValues = json_decode($value, true, 512, JSON_THROW_ON_ERROR);
switch (count($decodedValues)) { switch (count($decodedValues)) {
case 0: case 0:

View File

@ -39,7 +39,7 @@ class TranslatableStringExportLabelHelper
return ''; return '';
} }
return $this->translatableStringHelper->localize(json_decode($value, true)); return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR));
}; };
} }
@ -54,7 +54,7 @@ class TranslatableStringExportLabelHelper
return ''; return '';
} }
$decoded = json_decode($value, true); $decoded = json_decode($value, true, 512, JSON_THROW_ON_ERROR);
return implode( return implode(
'|', '|',

View File

@ -54,7 +54,7 @@ class UserHelper
return ''; return '';
} }
$decoded = json_decode($value); $decoded = json_decode($value, null, 512, JSON_THROW_ON_ERROR);
if (0 === count($decoded)) { if (0 === count($decoded)) {
return ''; return '';

View File

@ -1,44 +0,0 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Form;
use Chill\MainBundle\Search\SearchProvider;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class AdvancedSearchType extends AbstractType
{
/**
* @var SearchProvider
*/
protected $searchProvider;
public function __construct(SearchProvider $searchProvider)
{
$this->searchProvider = $searchProvider;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$this->searchProvider
->getHasAdvancedFormByName($options['search_service'])
->createSearchForm($builder);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setRequired('search_service')
->setAllowedTypes('search_service', ['string']);
}
}

View File

@ -30,7 +30,7 @@ class CenterType extends AbstractType
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefaults([ $resolver->setDefaults([
'data_class' => 'Chill\MainBundle\Entity\Center', 'data_class' => \Chill\MainBundle\Entity\Center::class,
]); ]);
} }

View File

@ -75,7 +75,7 @@ final class LocationFormType extends AbstractType
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefaults([ $resolver->setDefaults([
'data_class' => 'Chill\MainBundle\Entity\Location', 'data_class' => \Chill\MainBundle\Entity\Location::class,
]); ]);
} }

View File

@ -60,7 +60,7 @@ class PermissionsGroupType extends AbstractType
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefaults([ $resolver->setDefaults([
'data_class' => 'Chill\MainBundle\Entity\PermissionsGroup', 'data_class' => \Chill\MainBundle\Entity\PermissionsGroup::class,
]); ]);
} }

View File

@ -36,7 +36,7 @@ class ScopeType extends AbstractType
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefaults([ $resolver->setDefaults([
'data_class' => 'Chill\MainBundle\Entity\Scope', 'data_class' => \Chill\MainBundle\Entity\Scope::class,
]); ]);
} }

View File

@ -83,8 +83,8 @@ trait AppendScopeChoiceTypeTrait
{ {
$resolver $resolver
->setRequired(['center', 'role']) ->setRequired(['center', 'role'])
->setAllowedTypes('center', 'Chill\MainBundle\Entity\Center') ->setAllowedTypes('center', \Chill\MainBundle\Entity\Center::class)
->setAllowedTypes('role', 'Symfony\Component\Security\Core\Role\Role'); ->setAllowedTypes('role', 'string');
} }
/** /**

View File

@ -23,12 +23,12 @@ class ComposedGroupCenterType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$builder->add('permissionsgroup', EntityType::class, [ $builder->add('permissionsgroup', EntityType::class, [
'class' => 'Chill\MainBundle\Entity\PermissionsGroup', 'class' => \Chill\MainBundle\Entity\PermissionsGroup::class,
'choice_label' => static function (PermissionsGroup $group) { 'choice_label' => static function (PermissionsGroup $group) {
return $group->getName(); return $group->getName();
}, },
])->add('center', EntityType::class, [ ])->add('center', EntityType::class, [
'class' => 'Chill\MainBundle\Entity\Center', 'class' => \Chill\MainBundle\Entity\Center::class,
'choice_label' => static function (Center $center) { 'choice_label' => static function (Center $center) {
return $center->getName(); return $center->getName();
}, },
@ -37,7 +37,7 @@ class ComposedGroupCenterType extends AbstractType
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefault('data_class', 'Chill\MainBundle\Entity\GroupCenter'); $resolver->setDefault('data_class', \Chill\MainBundle\Entity\GroupCenter::class);
} }
public function getBlockPrefix() public function getBlockPrefix()

View File

@ -99,6 +99,6 @@ class ComposedRoleScopeType extends AbstractType
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefault('data_class', 'Chill\MainBundle\Entity\RoleScope'); $resolver->setDefault('data_class', \Chill\MainBundle\Entity\RoleScope::class);
} }
} }

View File

@ -43,7 +43,7 @@ class EntityToJsonTransformer implements DataTransformerInterface
public function reverseTransform($value) public function reverseTransform($value)
{ {
$denormalized = json_decode($value, true); $denormalized = json_decode($value, true, 512, JSON_THROW_ON_ERROR);
if ($this->multiple) { if ($this->multiple) {
if (null === $denormalized) { if (null === $denormalized) {

View File

@ -77,7 +77,7 @@ class Select2CountryType extends AbstractType
asort($choices, SORT_STRING | SORT_FLAG_CASE); asort($choices, SORT_STRING | SORT_FLAG_CASE);
$resolver->setDefaults([ $resolver->setDefaults([
'class' => 'Chill\MainBundle\Entity\Country', 'class' => \Chill\MainBundle\Entity\Country::class,
'choices' => array_combine(array_values($choices), array_keys($choices)), 'choices' => array_combine(array_values($choices), array_keys($choices)),
'preferred_choices' => array_combine(array_values($preferredChoices), array_keys($preferredChoices)), 'preferred_choices' => array_combine(array_values($preferredChoices), array_keys($preferredChoices)),
]); ]);

View File

@ -73,7 +73,7 @@ class Select2LanguageType extends AbstractType
asort($choices, SORT_STRING | SORT_FLAG_CASE); asort($choices, SORT_STRING | SORT_FLAG_CASE);
$resolver->setDefaults([ $resolver->setDefaults([
'class' => 'Chill\MainBundle\Entity\Language', 'class' => \Chill\MainBundle\Entity\Language::class,
'choices' => array_combine(array_values($choices), array_keys($choices)), 'choices' => array_combine(array_values($choices), array_keys($choices)),
'preferred_choices' => array_combine(array_values($preferredChoices), array_keys($preferredChoices)), 'preferred_choices' => array_combine(array_values($preferredChoices), array_keys($preferredChoices)),
]); ]);

View File

@ -167,7 +167,7 @@ class UserType extends AbstractType
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefaults([ $resolver->setDefaults([
'data_class' => 'Chill\MainBundle\Entity\User', 'data_class' => \Chill\MainBundle\Entity\User::class,
]); ]);
$resolver $resolver

View File

@ -203,7 +203,7 @@ class WorkflowStepType extends AbstractType
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver $resolver
->setDefined('class', EntityWorkflowStep::class) ->setDefined('class')
->setRequired('transition') ->setRequired('transition')
->setAllowedTypes('transition', 'bool') ->setAllowedTypes('transition', 'bool')
->setRequired('entity_workflow') ->setRequired('entity_workflow')

View File

@ -78,9 +78,8 @@ class PaginatorFactory
$totalItems, $totalItems,
$this->getCurrentItemsPerPage(), $this->getCurrentItemsPerPage(),
$this->getCurrentPageNumber(), $this->getCurrentPageNumber(),
null === $route ? $this->getCurrentRoute() : $route, $route ?? $this->getCurrentRoute(),
null === $routeParameters ? $this->getCurrentRouteParameters() : $routeParameters ?? $this->getCurrentRouteParameters(),
$routeParameters,
$this->router, $this->router,
self::DEFAULT_CURRENT_PAGE_KEY, self::DEFAULT_CURRENT_PAGE_KEY,
self::DEFAULT_ITEM_PER_NUMBER_KEY self::DEFAULT_ITEM_PER_NUMBER_KEY

View File

@ -224,7 +224,7 @@ final class PhonenumberHelper implements PhoneNumberHelperInterface
return null; return null;
} }
$validation = json_decode($response->getBody()->getContents())->carrier->type; $validation = json_decode($response->getBody()->getContents(), null, 512, JSON_THROW_ON_ERROR)->carrier->type;
$item $item
->set($validation) ->set($validation)

View File

@ -20,4 +20,6 @@ interface HasAdvancedSearchFormInterface extends SearchInterface
public function convertFormDataToQuery(array $data); public function convertFormDataToQuery(array $data);
public function convertTermsToFormData(array $terms); public function convertTermsToFormData(array $terms);
public function getAdvancedSearchTitle(): string;
} }

View File

@ -33,7 +33,7 @@ use function count;
class SearchProvider class SearchProvider
{ {
/** /**
* @var HasAdvancedSearchForm[] * @var HasAdvancedSearchFormInterface[]
*/ */
private $hasAdvancedFormSearchServices = []; private $hasAdvancedFormSearchServices = [];
@ -91,11 +91,7 @@ class SearchProvider
{ {
//sort the array //sort the array
uasort($this->searchServices, static function (SearchInterface $a, SearchInterface $b) { uasort($this->searchServices, static function (SearchInterface $a, SearchInterface $b) {
if ($a->getOrder() === $b->getOrder()) { return $a->getOrder() <=> $b->getOrder();
return 0;
}
return ($a->getOrder() < $b->getOrder()) ? -1 : 1;
}); });
return $this->searchServices; return $this->searchServices;
@ -105,13 +101,9 @@ class SearchProvider
* return searchservice with an advanced form, defined in service * return searchservice with an advanced form, defined in service
* definition. * definition.
* *
* @param string $name
*
* @throws UnknowSearchNameException * @throws UnknowSearchNameException
*
* @return HasAdvancedSearchForm
*/ */
public function getHasAdvancedFormByName($name) public function getHasAdvancedFormByName(string $name): HasAdvancedSearchFormInterface
{ {
if (array_key_exists($name, $this->hasAdvancedFormSearchServices)) { if (array_key_exists($name, $this->hasAdvancedFormSearchServices)) {
return $this->hasAdvancedFormSearchServices[$name]; return $this->hasAdvancedFormSearchServices[$name];
@ -123,12 +115,8 @@ class SearchProvider
public function getHasAdvancedFormSearchServices() public function getHasAdvancedFormSearchServices()
{ {
//sort the array //sort the array
uasort($this->hasAdvancedFormSearchServices, static function (SearchInterface $a, SearchInterface $b) { uasort($this->hasAdvancedFormSearchServices, static function (HasAdvancedSearchFormInterface $a, HasAdvancedSearchFormInterface $b): int {
if ($a->getOrder() === $b->getOrder()) { return $a->getOrder() <=> $b->getOrder();
return 0;
}
return ($a->getOrder() < $b->getOrder()) ? -1 : 1;
}); });
return $this->hasAdvancedFormSearchServices; return $this->hasAdvancedFormSearchServices;

View File

@ -41,7 +41,7 @@ class RefreshAddressToGeographicalUnitMaterializedViewCronJob implements CronJob
return $cronJobExecution->getLastStart() < $now->sub(new DateInterval('P1D')) return $cronJobExecution->getLastStart() < $now->sub(new DateInterval('P1D'))
// introduce a random component to ensure a roll when multiple instances are hosted on same machines // introduce a random component to ensure a roll when multiple instances are hosted on same machines
&& mt_rand(0, 10) === 0; && random_int(0, 10) === 0;
} }
public function getKey(): string public function getKey(): string

View File

@ -66,11 +66,11 @@ class PostalCodeBEFromBestAddress
gzclose($uncompressedStream); gzclose($uncompressedStream);
unlink($tmpname); unlink($tmpname);
$this->logger->info(__CLASS__ . ' list of postal code downloaded'); $this->logger->info(self::class . ' list of postal code downloaded');
$this->baseImporter->finalize(); $this->baseImporter->finalize();
$this->logger->info(__CLASS__ . ' postal code fetched', ['offset' => $offset ?? 0]); $this->logger->info(self::class . ' postal code fetched', ['offset' => $offset ?? 0]);
} }
private function getFileDownloadUrl(string $lang): string private function getFileDownloadUrl(string $lang): string

View File

@ -73,7 +73,7 @@ class PostalCodeFRFromOpenData
$this->baseImporter->finalize(); $this->baseImporter->finalize();
fclose($tmpfile); fclose($tmpfile);
$this->logger->info(__CLASS__ . ' postal code fetched', ['offset' => $offset ?? 0]); $this->logger->info(self::class . ' postal code fetched', ['offset' => $offset ?? 0]);
} }
private function handleRecord(array $record): void private function handleRecord(array $record): void

View File

@ -243,7 +243,7 @@ abstract class AbstractAggregatorTest extends KernelTestCase
$result = $results[0]; $result = $results[0];
$this->assertTrue( $this->assertTrue(
$result instanceof Traversable || is_array($result), is_iterable($result),
'test that each row in the result is traversable or an array' 'test that each row in the result is traversable or an array'
); );

View File

@ -230,7 +230,7 @@ abstract class AbstractExportTest extends WebTestCase
$result = $results[0]; $result = $results[0];
$this->assertTrue( $this->assertTrue(
$result instanceof Traversable || is_array($result), is_iterable($result),
'test that each row in the result is traversable or an array' 'test that each row in the result is traversable or an array'
); );

View File

@ -38,7 +38,7 @@ trait PrepareCenterTrait
} }
$center = $this->centerProphet->prophesize(); $center = $this->centerProphet->prophesize();
$center->willExtend('\Chill\MainBundle\Entity\Center'); $center->willExtend('\\' . \Chill\MainBundle\Entity\Center::class);
$center->getId()->willReturn($id); $center->getId()->willReturn($id);
$center->getName()->willReturn($name); $center->getName()->willReturn($name);

View File

@ -38,7 +38,7 @@ trait PrepareCircleTrait
} }
$scope = $this->circleProphet->prophesize(); $scope = $this->circleProphet->prophesize();
$scope->willExtend('\Chill\MainBundle\Entity\Scope'); $scope->willExtend('\\' . \Chill\MainBundle\Entity\Scope::class);
$scope->getId()->willReturn($id); $scope->getId()->willReturn($id);
$scope->getName()->willReturn($name); $scope->getName()->willReturn($name);

View File

@ -84,7 +84,7 @@ class AddressToReferenceMatcherControllerTest extends WebTestCase
/** @var Address $address */ /** @var Address $address */
$address = $em->createQuery('SELECT a FROM '.Address::class.' a') $address = $em->createQuery('SELECT a FROM '.Address::class.' a')
->setFirstResult(rand(0, $nb)) ->setFirstResult(random_int(0, $nb))
->setMaxResults(1) ->setMaxResults(1)
->getSingleResult(); ->getSingleResult();
@ -108,7 +108,7 @@ class AddressToReferenceMatcherControllerTest extends WebTestCase
$ref = $em->createQuery('SELECT a FROM '.AddressReference::class.' a') $ref = $em->createQuery('SELECT a FROM '.AddressReference::class.' a')
->setMaxResults(1) ->setMaxResults(1)
->setFirstResult(rand(0, $nb)) ->setFirstResult(random_int(0, $nb))
->getSingleResult(); ->getSingleResult();
$address = Address::createFromAddressReference($ref); $address = Address::createFromAddressReference($ref);

View File

@ -44,7 +44,7 @@ class GeographicalUnitByAddressApiControllerTest extends WebTestCase
$nb = $em->createQuery('SELECT COUNT(a) FROM '.Address::class.' a')->getSingleScalarResult(); $nb = $em->createQuery('SELECT COUNT(a) FROM '.Address::class.' a')->getSingleScalarResult();
/** @var \Chill\MainBundle\Entity\Address $random */ /** @var \Chill\MainBundle\Entity\Address $random */
$random = $em->createQuery('SELECT a FROM '.Address::class.' a') $random = $em->createQuery('SELECT a FROM '.Address::class.' a')
->setFirstResult(rand(0, $nb)) ->setFirstResult(random_int(0, $nb))
->setMaxResults(1) ->setMaxResults(1)
->getSingleResult(); ->getSingleResult();

View File

@ -44,7 +44,7 @@ final class PermissionApiControllerTest extends WebTestCase
$this->assertResponseIsSuccessful(); $this->assertResponseIsSuccessful();
$data = json_decode($client->getResponse()->getContent(), true); $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR);
$this->assertFalse($data['roles']['FOO_ROLE']); $this->assertFalse($data['roles']['FOO_ROLE']);
} }
@ -67,7 +67,7 @@ final class PermissionApiControllerTest extends WebTestCase
$this->assertResponseIsSuccessful(); $this->assertResponseIsSuccessful();
$data = json_decode($client->getResponse()->getContent(), true); $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR);
$this->assertTrue($data['roles']['ROLE_USER']); $this->assertTrue($data['roles']['ROLE_USER']);
$this->assertFalse($data['roles']['ROLE_ADMIN']); $this->assertFalse($data['roles']['ROLE_ADMIN']);
} }

View File

@ -35,7 +35,7 @@ final class PostalCodeApiControllerTest extends WebTestCase
$this->assertResponseIsSuccessful(); $this->assertResponseIsSuccessful();
$data = json_decode($client->getResponse()->getContent(), true); $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR);
$this->assertEquals('Fontenay Le Comte', $data['results'][0]['name']); $this->assertEquals('Fontenay Le Comte', $data['results'][0]['name']);

View File

@ -47,7 +47,7 @@ final class UserApiControllerTest extends WebTestCase
$this->assertResponseIsSuccessful(); $this->assertResponseIsSuccessful();
$data = json_decode($client->getResponse()->getContent(), true); $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR);
$this->assertTrue(array_key_exists('count', $data)); $this->assertTrue(array_key_exists('count', $data));
$this->assertGreaterThan(0, $data['count']); $this->assertGreaterThan(0, $data['count']);
$this->assertTrue(array_key_exists('results', $data)); $this->assertTrue(array_key_exists('results', $data));

View File

@ -198,10 +198,10 @@ final class ExportManagerTest extends KernelTestCase
//create a formatter //create a formatter
$formatterFoo = $this->prophet->prophesize(); $formatterFoo = $this->prophet->prophesize();
$formatterFoo->willImplement('Chill\MainBundle\Export\FormatterInterface'); $formatterFoo->willImplement(\Chill\MainBundle\Export\FormatterInterface::class);
$formatterFoo->getType()->willReturn('foo'); $formatterFoo->getType()->willReturn('foo');
$formatterBar = $this->prophet->prophesize(); $formatterBar = $this->prophet->prophesize();
$formatterBar->willImplement('Chill\MainBundle\Export\FormatterInterface'); $formatterBar->willImplement(\Chill\MainBundle\Export\FormatterInterface::class);
$formatterBar->getType()->willReturn('bar'); $formatterBar->getType()->willReturn('bar');
$exportManager->addFormatter($formatterFoo->reveal(), 'foo'); $exportManager->addFormatter($formatterFoo->reveal(), 'foo');
$exportManager->addFormatter($formatterBar->reveal(), 'bar'); $exportManager->addFormatter($formatterBar->reveal(), 'bar');
@ -380,12 +380,12 @@ final class ExportManagerTest extends KernelTestCase
//create a filter and add it to ExportManager //create a filter and add it to ExportManager
$agg = $this->prophet->prophesize(); $agg = $this->prophet->prophesize();
$agg->willImplement('Chill\MainBundle\Export\AggregatorInterface'); $agg->willImplement(\Chill\MainBundle\Export\AggregatorInterface::class);
$exportManager->addAggregator($agg->reveal(), 'dummy'); $exportManager->addAggregator($agg->reveal(), 'dummy');
$obtained = $exportManager->getAggregator('dummy'); $obtained = $exportManager->getAggregator('dummy');
$this->assertInstanceof('Chill\MainBundle\Export\AggregatorInterface', $obtained); $this->assertInstanceof(\Chill\MainBundle\Export\AggregatorInterface::class, $obtained);
} }
public function testGetAggregatorNonExistant() public function testGetAggregatorNonExistant()
@ -403,11 +403,11 @@ final class ExportManagerTest extends KernelTestCase
//create three filters and add them to ExportManager //create three filters and add them to ExportManager
$aggFoo = $this->prophet->prophesize(); $aggFoo = $this->prophet->prophesize();
$aggFoo->willImplement('Chill\MainBundle\Export\AggregatorInterface'); $aggFoo->willImplement(\Chill\MainBundle\Export\AggregatorInterface::class);
$aggBar = $this->prophet->prophesize(); $aggBar = $this->prophet->prophesize();
$aggBar->willImplement('Chill\MainBundle\Export\AggregatorInterface'); $aggBar->willImplement(\Chill\MainBundle\Export\AggregatorInterface::class);
$aggFooBar = $this->prophet->prophesize(); $aggFooBar = $this->prophet->prophesize();
$aggFooBar->willImplement('Chill\MainBundle\Export\AggregatorInterface'); $aggFooBar->willImplement(\Chill\MainBundle\Export\AggregatorInterface::class);
$exportManager->addAggregator($aggFoo->reveal(), 'foo'); $exportManager->addAggregator($aggFoo->reveal(), 'foo');
$exportManager->addAggregator($aggBar->reveal(), 'bar'); $exportManager->addAggregator($aggBar->reveal(), 'bar');
$exportManager->addAggregator($aggFooBar->reveal(), 'foobar'); $exportManager->addAggregator($aggFooBar->reveal(), 'foobar');
@ -477,12 +477,12 @@ final class ExportManagerTest extends KernelTestCase
//create a filter and add it to ExportManager //create a filter and add it to ExportManager
$filter = $this->prophet->prophesize(); $filter = $this->prophet->prophesize();
$filter->willImplement('Chill\MainBundle\Export\FilterInterface'); $filter->willImplement(\Chill\MainBundle\Export\FilterInterface::class);
$exportManager->addFilter($filter->reveal(), 'dummy'); $exportManager->addFilter($filter->reveal(), 'dummy');
$obtained = $exportManager->getFilter('dummy'); $obtained = $exportManager->getFilter('dummy');
$this->assertInstanceof('Chill\MainBundle\Export\FilterInterface', $obtained); $this->assertInstanceof(\Chill\MainBundle\Export\FilterInterface::class, $obtained);
} }
public function testGetFilterNonExistant() public function testGetFilterNonExistant()
@ -500,11 +500,11 @@ final class ExportManagerTest extends KernelTestCase
//create three filters and add them to ExportManager //create three filters and add them to ExportManager
$filterFoo = $this->prophet->prophesize(); $filterFoo = $this->prophet->prophesize();
$filterFoo->willImplement('Chill\MainBundle\Export\FilterInterface'); $filterFoo->willImplement(\Chill\MainBundle\Export\FilterInterface::class);
$filterBar = $this->prophet->prophesize(); $filterBar = $this->prophet->prophesize();
$filterBar->willImplement('Chill\MainBundle\Export\FilterInterface'); $filterBar->willImplement(\Chill\MainBundle\Export\FilterInterface::class);
$filterFooBar = $this->prophet->prophesize(); $filterFooBar = $this->prophet->prophesize();
$filterFooBar->willImplement('Chill\MainBundle\Export\FilterInterface'); $filterFooBar->willImplement(\Chill\MainBundle\Export\FilterInterface::class);
$exportManager->addFilter($filterFoo->reveal(), 'foo'); $exportManager->addFilter($filterFoo->reveal(), 'foo');
$exportManager->addFilter($filterBar->reveal(), 'bar'); $exportManager->addFilter($filterBar->reveal(), 'bar');
$exportManager->addFilter($filterFooBar->reveal(), 'foobar'); $exportManager->addFilter($filterFooBar->reveal(), 'foobar');
@ -522,12 +522,12 @@ final class ExportManagerTest extends KernelTestCase
//create a formatter //create a formatter
$formatter = $this->prophet->prophesize(); $formatter = $this->prophet->prophesize();
$formatter->willImplement('Chill\MainBundle\Export\FormatterInterface'); $formatter->willImplement(\Chill\MainBundle\Export\FormatterInterface::class);
$exportManager->addFormatter($formatter->reveal(), 'dummy'); $exportManager->addFormatter($formatter->reveal(), 'dummy');
$obtained = $exportManager->getFormatter('dummy'); $obtained = $exportManager->getFormatter('dummy');
$this->assertInstanceOf('Chill\MainBundle\Export\FormatterInterface', $obtained); $this->assertInstanceOf(\Chill\MainBundle\Export\FormatterInterface::class, $obtained);
} }
public function testIsGrantedForElementWithExportAndUserIsGranted() public function testIsGrantedForElementWithExportAndUserIsGranted()
@ -536,7 +536,7 @@ final class ExportManagerTest extends KernelTestCase
$user = $this->prepareUser([]); $user = $this->prepareUser([]);
$authorizationChecker = $this->prophet->prophesize(); $authorizationChecker = $this->prophet->prophesize();
$authorizationChecker->willImplement('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'); $authorizationChecker->willImplement(\Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface::class);
$authorizationChecker->isGranted('CHILL_STAT_DUMMY', $center) $authorizationChecker->isGranted('CHILL_STAT_DUMMY', $center)
->willReturn(true); ->willReturn(true);
@ -564,7 +564,7 @@ final class ExportManagerTest extends KernelTestCase
$user = $this->prepareUser([]); $user = $this->prepareUser([]);
$authorizationChecker = $this->prophet->prophesize(); $authorizationChecker = $this->prophet->prophesize();
$authorizationChecker->willImplement('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'); $authorizationChecker->willImplement(\Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface::class);
$authorizationChecker->isGranted('CHILL_STAT_DUMMY', $center) $authorizationChecker->isGranted('CHILL_STAT_DUMMY', $center)
->willReturn(true); ->willReturn(true);
$authorizationChecker->isGranted('CHILL_STAT_DUMMY', $centerB) $authorizationChecker->isGranted('CHILL_STAT_DUMMY', $centerB)

View File

@ -101,7 +101,7 @@ final class PickCenterTypeTest extends TypeTestCase
$prophet = new \Prophecy\Prophet(); $prophet = new \Prophecy\Prophet();
$prophecyCenter = $prophet->prophesize(); $prophecyCenter = $prophet->prophesize();
$prophecyCenter->willExtend('\Chill\MainBundle\Entity\Center'); $prophecyCenter->willExtend('\\' . \Chill\MainBundle\Entity\Center::class);
$prophecyCenter->getId()->willReturn($id); $prophecyCenter->getId()->willReturn($id);
$prophecyCenter->getName()->willReturn($name); $prophecyCenter->getName()->willReturn($name);
@ -122,18 +122,18 @@ final class PickCenterTypeTest extends TypeTestCase
//create a center transformer //create a center transformer
$centerTransformerProphecy = $prophet->prophesize(); $centerTransformerProphecy = $prophet->prophesize();
$centerTransformerProphecy $centerTransformerProphecy
->willExtend('Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer'); ->willExtend(\Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer::class);
$transformer = $centerTransformerProphecy->reveal(); $transformer = $centerTransformerProphecy->reveal();
$tokenProphecy = $prophet->prophesize(); $tokenProphecy = $prophet->prophesize();
$tokenProphecy $tokenProphecy
->willImplement('\Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); ->willImplement('\\' . \Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class);
$tokenProphecy->getUser()->willReturn($user); $tokenProphecy->getUser()->willReturn($user);
$token = $tokenProphecy->reveal(); $token = $tokenProphecy->reveal();
$tokenStorageProphecy = $prophet->prophesize(); $tokenStorageProphecy = $prophet->prophesize();
$tokenStorageProphecy $tokenStorageProphecy
->willExtend('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage'); ->willExtend(\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage::class);
$tokenStorageProphecy->getToken()->willReturn($token); $tokenStorageProphecy->getToken()->willReturn($token);
$tokenStorage = $tokenStorageProphecy->reveal(); $tokenStorage = $tokenStorageProphecy->reveal();

View File

@ -26,7 +26,7 @@ final class AbstractSearchTest extends \PHPUnit\Framework\TestCase
protected function setUp(): void protected function setUp(): void
{ {
$this->stub = $this->getMockForAbstractClass('Chill\MainBundle\Search\AbstractSearch'); $this->stub = $this->getMockForAbstractClass(\Chill\MainBundle\Search\AbstractSearch::class);
} }
public function testParseDateRegular() public function testParseDateRegular()

View File

@ -245,7 +245,7 @@ final class SearchProviderTest extends TestCase
private function createDefaultSearchService($result, $order) private function createDefaultSearchService($result, $order)
{ {
$mock = $this $mock = $this
->getMockForAbstractClass('Chill\MainBundle\Search\AbstractSearch'); ->getMockForAbstractClass(\Chill\MainBundle\Search\AbstractSearch::class);
//set the mock as default //set the mock as default
$mock->expects($this->any()) $mock->expects($this->any())
@ -267,7 +267,7 @@ final class SearchProviderTest extends TestCase
private function createNonDefaultDomainSearchService($result, $order, $domain) private function createNonDefaultDomainSearchService($result, $order, $domain)
{ {
$mock = $this $mock = $this
->getMockForAbstractClass('Chill\MainBundle\Search\AbstractSearch'); ->getMockForAbstractClass(\Chill\MainBundle\Search\AbstractSearch::class);
//set the mock as default //set the mock as default
$mock->expects($this->any()) $mock->expects($this->any())

View File

@ -279,8 +279,8 @@ final class AuthorizationHelperTest extends KernelTestCase
]); ]);
$helper = $this->getAuthorizationHelper(); $helper = $this->getAuthorizationHelper();
$entity = $this->getProphet()->prophesize(); $entity = $this->getProphet()->prophesize();
$entity->willImplement('\Chill\MainBundle\Entity\HasCenterInterface'); $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
$entity->willImplement('\Chill\MainBundle\Entity\HasScopeInterface'); $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasScopeInterface::class);
$entity->getCenter()->willReturn($center); $entity->getCenter()->willReturn($center);
$entity->getScope()->willReturn($scope); $entity->getScope()->willReturn($scope);
@ -386,7 +386,7 @@ final class AuthorizationHelperTest extends KernelTestCase
]); ]);
$helper = $this->getAuthorizationHelper(); $helper = $this->getAuthorizationHelper();
$entity = $this->getProphet()->prophesize(); $entity = $this->getProphet()->prophesize();
$entity->willImplement('\Chill\MainBundle\Entity\HasCenterInterface'); $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
$entity->getCenter()->willReturn($center); $entity->getCenter()->willReturn($center);
$this->assertTrue($helper->userHasAccess( $this->assertTrue($helper->userHasAccess(
@ -410,7 +410,7 @@ final class AuthorizationHelperTest extends KernelTestCase
$helper = $this->getAuthorizationHelper(); $helper = $this->getAuthorizationHelper();
$entity = $this->getProphet()->prophesize(); $entity = $this->getProphet()->prophesize();
$entity->willImplement('\Chill\MainBundle\Entity\HasCenterInterface'); $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
$entity->getCenter()->willReturn($center); $entity->getCenter()->willReturn($center);
$this->assertTrue($helper->userHasAccess( $this->assertTrue($helper->userHasAccess(
@ -434,8 +434,8 @@ final class AuthorizationHelperTest extends KernelTestCase
]); ]);
$helper = $this->getAuthorizationHelper(); $helper = $this->getAuthorizationHelper();
$entity = $this->getProphet()->prophesize(); $entity = $this->getProphet()->prophesize();
$entity->willImplement('\Chill\MainBundle\Entity\HasCenterInterface'); $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
$entity->willImplement('\Chill\MainBundle\Entity\HasScopeInterface'); $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasScopeInterface::class);
$entity->getCenter()->willReturn($centerB); $entity->getCenter()->willReturn($centerB);
$entity->getScope()->willReturn($scope); $entity->getScope()->willReturn($scope);
@ -455,7 +455,7 @@ final class AuthorizationHelperTest extends KernelTestCase
]); ]);
$helper = $this->getAuthorizationHelper(); $helper = $this->getAuthorizationHelper();
$entity = $this->getProphet()->prophesize(); $entity = $this->getProphet()->prophesize();
$entity->willImplement('\Chill\MainBundle\Entity\HasCenterInterface'); $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
$entity->getCenter()->willReturn($center); $entity->getCenter()->willReturn($center);
$this->assertFalse($helper->userHasAccess($user, $entity->reveal(), 'CHILL_ROLE')); $this->assertFalse($helper->userHasAccess($user, $entity->reveal(), 'CHILL_ROLE'));
@ -474,8 +474,8 @@ final class AuthorizationHelperTest extends KernelTestCase
]); ]);
$helper = $this->getAuthorizationHelper(); $helper = $this->getAuthorizationHelper();
$entity = $this->getProphet()->prophesize(); $entity = $this->getProphet()->prophesize();
$entity->willImplement('\Chill\MainBundle\Entity\HasCenterInterface'); $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
$entity->willImplement('\Chill\MainBundle\Entity\HasScopeInterface'); $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasScopeInterface::class);
$entity->getCenter()->willReturn($center); $entity->getCenter()->willReturn($center);
$entity->getScope()->willReturn($scope); $entity->getScope()->willReturn($scope);
@ -506,7 +506,7 @@ final class AuthorizationHelperTest extends KernelTestCase
]); ]);
$helper = $this->getAuthorizationHelper(); $helper = $this->getAuthorizationHelper();
$entity = $this->getProphet()->prophesize(); $entity = $this->getProphet()->prophesize();
$entity->willImplement('\Chill\MainBundle\Entity\HasCenterInterface'); $entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
$entity->getCenter()->willReturn($centerA); $entity->getCenter()->willReturn($centerA);
$this->assertFalse($helper->userHasAccess($user, $entity->reveal(), 'CHILL_ROLE')); $this->assertFalse($helper->userHasAccess($user, $entity->reveal(), 'CHILL_ROLE'));

View File

@ -64,7 +64,7 @@ final class GeographicalUnitBaseImporterTest extends KernelTestCase
$this->assertEquals($results['unitrefid'], 'layer_one'); $this->assertEquals($results['unitrefid'], 'layer_one');
$this->assertEquals($results['unitname'], 'Layer one'); $this->assertEquals($results['unitname'], 'Layer one');
$this->assertEquals(json_decode($results['layername'], true), ['fr' => 'Test Layer']); $this->assertEquals(json_decode($results['layername'], true, 512, JSON_THROW_ON_ERROR), ['fr' => 'Test Layer']);
$this->assertEquals($results['layerrefid'], 'test'); $this->assertEquals($results['layerrefid'], 'test');
$this->assertEquals($results['geom'], 'MULTIPOLYGON(((30 20,45 40,10 40,30 20)),((15 5,40 10,10 20,5 10,15 5)))'); $this->assertEquals($results['geom'], 'MULTIPOLYGON(((30 20,45 40,10 40,30 20)),((15 5,40 10,10 20,5 10,15 5)))');
@ -93,7 +93,7 @@ final class GeographicalUnitBaseImporterTest extends KernelTestCase
$this->assertEquals($results['unitrefid'], 'layer_one'); $this->assertEquals($results['unitrefid'], 'layer_one');
$this->assertEquals($results['unitname'], 'Layer one fixed'); $this->assertEquals($results['unitname'], 'Layer one fixed');
$this->assertEquals(json_decode($results['layername'], true), ['fr' => 'Test Layer fixed']); $this->assertEquals(json_decode($results['layername'], true, 512, JSON_THROW_ON_ERROR), ['fr' => 'Test Layer fixed']);
$this->assertEquals($results['layerrefid'], 'test'); $this->assertEquals($results['layerrefid'], 'test');
$this->assertEquals($results['geom'], 'MULTIPOLYGON(((130 120,45 40,10 40,130 120)),((0 0,15 5,40 10,10 20,0 0)))'); $this->assertEquals($results['geom'], 'MULTIPOLYGON(((130 120,45 40,10 40,130 120)),((0 0,15 5,40 10,10 20,0 0)))');
} }

View File

@ -49,18 +49,18 @@ final class Version20180709181423 extends AbstractMigration
$this->addSql('CREATE UNIQUE INDEX UNIQ_1483A5E9885281E ON users (emailCanonical)'); $this->addSql('CREATE UNIQUE INDEX UNIQ_1483A5E9885281E ON users (emailCanonical)');
$this->addSql( $this->addSql(
<<<'SQL' <<<'SQL_WRAP'
CREATE OR REPLACE FUNCTION canonicalize_user_on_update() RETURNS TRIGGER AS CREATE OR REPLACE FUNCTION canonicalize_user_on_update() RETURNS TRIGGER AS
$BODY$ $BODY$
BEGIN BEGIN
IF NEW.username <> OLD.username OR NEW.email <> OLD.email OR OLD.emailcanonical IS NULL OR OLD.usernamecanonical IS NULL THEN IF NEW.username <> OLD.username OR NEW.email <> OLD.email OR OLD.emailcanonical IS NULL OR OLD.usernamecanonical IS NULL THEN
UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id; UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id;
END IF; END IF;
RETURN NEW; RETURN NEW;
END; END;
$BODY$ LANGUAGE PLPGSQL $BODY$ LANGUAGE PLPGSQL
SQL SQL_WRAP
); );
$this->addSql( $this->addSql(
@ -74,16 +74,16 @@ final class Version20180709181423 extends AbstractMigration
); );
$this->addSql( $this->addSql(
<<<'SQL' <<<'SQL_WRAP'
CREATE OR REPLACE FUNCTION canonicalize_user_on_insert() RETURNS TRIGGER AS CREATE OR REPLACE FUNCTION canonicalize_user_on_insert() RETURNS TRIGGER AS
$BODY$ $BODY$
BEGIN BEGIN
UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id; UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id;
RETURN NEW; RETURN NEW;
END; END;
$BODY$ LANGUAGE PLPGSQL; $BODY$ LANGUAGE PLPGSQL;
SQL SQL_WRAP
); );
$this->addSql( $this->addSql(

View File

@ -165,7 +165,7 @@ final class PersonController extends AbstractController
$cFGroup = null; $cFGroup = null;
$cFDefaultGroup = $this->em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsDefaultGroup::class) $cFDefaultGroup = $this->em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsDefaultGroup::class)
->findOneByEntity('Chill\\PersonBundle\\Entity\\Person'); ->findOneByEntity(\Chill\PersonBundle\Entity\Person::class);
if ($cFDefaultGroup) { if ($cFDefaultGroup) {
$cFGroup = $cFDefaultGroup->getCustomFieldsGroup(); $cFGroup = $cFDefaultGroup->getCustomFieldsGroup();

View File

@ -120,7 +120,7 @@ class ReassignAccompanyingPeriodController extends AbstractController
$assignForm->handleRequest($request); $assignForm->handleRequest($request);
if ($assignForm->isSubmitted() && $assignForm->isValid()) { if ($assignForm->isSubmitted() && $assignForm->isValid()) {
$assignPeriodIds = json_decode($assignForm->get('periods')->getData(), true); $assignPeriodIds = json_decode($assignForm->get('periods')->getData(), true, 512, JSON_THROW_ON_ERROR);
$userTo = $assignForm->get('userTo')->getData(); $userTo = $assignForm->get('userTo')->getData();
$userFrom = $assignForm->get('userFrom')->getData(); $userFrom = $assignForm->get('userFrom')->getData();
@ -179,7 +179,7 @@ class ReassignAccompanyingPeriodController extends AbstractController
{ {
$defaultData = [ $defaultData = [
'userFrom' => $userFrom, 'userFrom' => $userFrom,
'periods' => json_encode($periodIds), 'periods' => json_encode($periodIds, JSON_THROW_ON_ERROR),
]; ];
$builder = $this->formFactory->createNamedBuilder('reassign', FormType::class, $defaultData); $builder = $this->formFactory->createNamedBuilder('reassign', FormType::class, $defaultData);

Some files were not shown because too many files have changed in this diff Show More